OSDN Git Service

fix test
authoryasushiito <yas@pen-chan.jp>
Thu, 26 Jun 2014 23:50:02 +0000 (08:50 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 26 Jun 2014 23:50:02 +0000 (08:50 +0900)
Gemfile
app/controllers/application_controller.rb
spec/controller_helper.rb [deleted file]
spec/controllers/scrolls_controller_spec.rb
spec/deprecations.txt [new file with mode: 0644]
spec/spec_helper.rb
spec/support/controller_macros.rb

diff --git a/Gemfile b/Gemfile
index 47e8459..79ddea3 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -72,7 +72,7 @@ end
 group :test do
   gem 'autotest'
   gem 'webmock'
-  gem 'rspec',   '~> 2.0'
+  gem 'rspec'
    gem 'rspec-rails'
    gem 'cucumber'
    gem 'cucumber-rails', require: false
index 4eb49ec..bb8f2fe 100644 (file)
@@ -73,7 +73,6 @@ class ApplicationController < ActionController::Base
     else
       respond_to do |format|
         format.html { redirect_to main_app.new_author_path, :status => :found }
-        format.js { render "authors/new" }
         format.json { 
           raise ActiveRecord::Forbidden
         }
@@ -88,7 +87,6 @@ class ApplicationController < ActionController::Base
     else
       respond_to do |format|
         format.html { redirect_to main_app.new_artist_path, :status => :found }
-        format.js { render "artists/new" }
         format.json { 
           raise ActiveRecord::Forbidden
         }
diff --git a/spec/controller_helper.rb b/spec/controller_helper.rb
deleted file mode 100644 (file)
index 086b5d8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-module ControllerMacros
-  def list_should_return_filer_or_json action, params = {}
-    # html\8c`\8e®: 
-    # \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
-    # filer\83e\83\93\83v\83\8c\81[\83g\82ð\95`\89æ\82·\82é
-    get action, params
-    response.should be_success 
-    response.should render_template("templates/r/filer/filer")
-    # json\8c`\8e®
-    # \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
-    # json\83f\81[\83^\82ð\95Ô\82·
-    get action, params.merge(:format => :json)
-    response.should be_success 
-    lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-  end
-  
-  def announce_sign_in_at_get action, params = {}
-    # html\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h302 Found\82ð\95Ô\82·
-    get action, params
-    response.status.should eq 302
-    response.should redirect_to '/users/sign_in'
-    # json\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h401 Unauthorized\82ð\95Ô\82·
-    get action, params.merge(:format => :json)
-    response.status.should eq 401
-    response.message.should match(/Unauthorized/)
-  end
-  
-  def return_ok_at_get action, params = {}
-    # html\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
-    get action, params
-    response.should be_success 
-    # json\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
-    get action, params.merge(:format => :json)
-    response.should be_success 
-  end
-  
-end
-
index 9a93a82..78ad23a 100644 (file)
@@ -4,55 +4,89 @@ require 'spec_helper'
 describe ScrollsController do
   before do
     @admin =FactoryGirl.create :admin
+    @author_yas =  FactoryGirl.create :yas_with_scrolls
+    @user_yas = @author_yas.user
+    @user_rom = FactoryGirl.create :user_rom
   end
-  
+
 if Manifest.manifest.magic_numbers['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
-      @author_yas =  FactoryGirl.create :yas_with_scrolls
-      @user_yas = @author_yas.user
     end
     
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       before do
         sign_in @user_yas
       end
+      it 'ステータス OKを返して、ファイラーまたはjsonデータを返す。' do
+        list_should_return_filer_or_json :index
+      end
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
+        get :index
+        expect(assigns(:my_model_class)).to be Scroll
+      end
+      it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
+        get :index
+        expect(assigns(:list).item_name).to eq('scroll')
+        expect(assigns(:list).list_name).to eq('public')
+      end
       it '@itemsにリストを取得している' do
         get :index
-        except(assigns(:items).size).to be >= 3
+        expect(assigns(:items).size).to be >= 3
       end
-      it 'ステータスコード200 OKを返す' do
-        list_should_return_filer_or_json :index
+      context 'html形式' do
+        it '@filerにファイラーを取得している' do
+          get :index
+          expect(assigns(:filer).class).to be Locmare::Filer
+        end
+      end
+      context 'json形式' do
+        it '@filerにファイラーをセットしていない' do
+          get :index, format: :json
+          expect(assigns(:filer)).to be nil
+        end
       end
     end
-    context '権限' do
-      it 'ユーザ権限はないが管理者権限があるとき 200 OKを返す' do
+    context '件数取得' do
+      before do
+        sign_in @user_yas
+      end
+      it 'ステータス OKを返す' do
+        return_ok_at_get :count, format: :json
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :count, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
+        end
+      end
+    end
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
         return_ok_at_get :index
+        return_ok_at_get :index, format: :json
       end
-      it 'ユーザだが作家登録していないとき 200 OKを返す' do
-        @user_rom = FactoryGirl.create :user_rom
+      it '創作活動してないROM専の読者にも通常通り応答する' do
         sign_in @user_rom
         return_ok_at_get :index
+        return_ok_at_get :index, format: :json
       end
-      it 'sign_inを返す' do
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
         announce_sign_in_at_get :index
       end
     end
   end
   describe '作家フィルタ一覧及びカウント' do
     before do
-      @author_yas =  FactoryGirl.create :yas_with_scrolls
-      @user_yas = @author_yas.user
-      @scroll = @author_yas.scrolls.first
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       before do
         sign_in @user_yas
       end
       it '@itemsにリストを取得している' do
         get :by_author
-        except(assigns(:items).size).to be >= 3
+        expect(assigns(:items).size).to be >= 3
       end
       it 'ステータスコード200 OKを返す' do
         list_should_return_filer_or_json :by_author, id: @author_yas.id
@@ -61,12 +95,13 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     context '権限' do
       it 'ユーザ権限はないが管理者権限があるとき 200 OKを返す' do
         sign_in @admin
-        return_ok_at_get :by_author
+        return_ok_at_get :by_author, id: @author_yas.id
+        return_ok_at_get :by_author, id: @author_yas.id, format: :json
       end
       it 'ユーザだが作家登録していないとき 200 OKを返す' do
-        @user_rom = FactoryGirl.create :user_rom, id: @author_yas.id
         sign_in @user_rom
-        return_ok_at_get :by_author
+        return_ok_at_get :by_author, id: @author_yas.id
+        return_ok_at_get :by_author, id: @author_yas.id, format: :json
       end
       it 'sign_inを返す' do
         announce_sign_in_at_get :by_author, id: @author_yas.id
@@ -76,323 +111,191 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
   
   describe '単体表示に於いて' do
     before do
-      @author_yas =  FactoryGirl.create :yas_with_scrolls
-      @user_yas = @author_yas.user
-      sign_in @user_yas
-      @scroll = @author_yas.scrolls.first
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :show, :id => @scroll.id
-        response.should be_success
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      it '@itemにアレを取得している' do
-        get :show, :id => @scroll.id
-        assigns(:item).id.should eq(@scroll.id)
+      it '[html, json, prof]でステータスコード200 OKを返す' do
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
+        return_ok_at_get :show, id: @item_id, format: :prof
+      end
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
+        get :show, id: @item_id
+        expect(assigns(:my_model_class)).to be Scroll
+      end
+      it '@itemにリクエストしたアイテムを取得している' do
+        get :show, id: @item_id
+        expect(assigns(:item)).to eq(@item)
       end
       context 'html形式' do
         it 'showテンプレートを描画する' do
-          get :show, :id => @scroll.id
-          response.should render_template("show")
+          get :show, id: @item_id
+          expect(response).to render_template("show")
         end
       end
       context 'json形式' do
         it 'jsonデータを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+          get :show, id: @item_id, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
-      end
-      context 'prof形式' do
-        it 'profilerを描画する' do
-          get :show, :id => @scroll.id, :format => :prof
-          response.should render_template("templates/r/profiler/profiler")
+        it 'プロファイラーは必要ないので@profilerに用意していない' do
+          get :show, id: @item_id, format: :json
+          expect(assigns(:profiler)).to be nil
         end
       end
-    end
-    context 'ユーザ権限がないとき' do
-      before do
-        sign_out @user_yas
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :show, :id => @scroll.id
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :show, :id => @scroll.id
-          response.body.should redirect_to '/users/sign_in'
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          response.message.should match(/Unauthorized/)
+      context 'prof形式' do
+        it 'プロファイラーテンプレートを描画する' do
+          get :show, id: @item_id, format: :prof
+          expect(response).to render_template("templates/r/profiler/profiler")
         end
       end
     end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user_yas
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :show, :id => @scroll.id
-        response.should be_success 
-      end
-    end
-    context 'ユーザだが作家登録していないとき' do
-      before do
-        sign_out @user_yas
-        @user_ghost = FactoryGirl.create :user_ghost
-        sign_in @user_ghost
-      end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :show, :id => @scroll.id
-          response.should be_success
-        end
-      end
-    end
-=begin
-    context '対象スクロールがないとき' do
-      context 'html形式' do
-        it '例外404 not_foundを返す' do
-          lambda{
-            get :show, :id => 0
-          }.should raise_error(ActiveRecord::RecordNotFound)
-        end
-      end
-      context 'json形式' do
-        it '例外404 not_foundを返す' do
-          lambda{ 
-            get :show, :id => 0, :format => :json
-          }.should raise_error(ActiveRecord::RecordNotFound)
-        end
-      end
-    end
-    context '非公開スクロールを見ようとしたとき' do
-      context 'html形式' do
-        it '例外403 forbiddenを返す' do
-          Scroll.any_instance.stub(:visible?).with(any_args()).and_return(false)
-          hidden = FactoryGirl.create :hidden_scroll, :author_id => @author.id
-          lambda{
-            get :show, :id => hidden
-          }.should raise_error(ActiveRecord::Forbidden)
-        end
+      it '創作活動してないROM専の読者にも通常通り応答する' do
+        sign_in @user_rom
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
       end
-      context 'json形式' do
-        it '例外403 forbiddenを返す' do
-          Scroll.any_instance.stub(:visible?).with(any_args()).and_return(false)
-          hidden = FactoryGirl.create :hidden_scroll, :author_id => @author.id
-          lambda{
-            get :show, :id => hidden, :format => :json
-          }.should raise_error(ActiveRecord::Forbidden)
-        end
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :show, id: @item_id
       end
     end
-=end
   end
   
-  describe '閲覧に於いて' do
+  describe 'プレイリストに於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @author.id
-      Scroll.stub(:show).with(@scroll.id.to_s, [@user, nil]).and_return(@scroll)
-      Scroll.stub(:show).with(@scroll.id.to_s, [nil, @admin]).and_return(@scroll)
-      ScrollPanel.stub(:count).and_return(10)
-      ScrollPanel.stub(:play_list).with(any_args).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
-      sign_in @user
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'つつがなく終わるとき' do
-      it '@scroll_panelsにリストを取得している' do
-        get :play, :id => @scroll.id
-        assigns(:scroll_panels).should have_at_least(3).items
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :play, :id => @scroll.id
-          response.should be_success 
-        end
-        it 'scrollテンプレートを描画する' do
-          get :play, :id => @scroll.id
-          response.should render_template("scroll")
-        end
+      it '[html, json]でステータス OKを返す' do
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      context 'json形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.should be_success 
-        end
-        it 'jsonデータを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
+      it 'コントローラのマニフェストからScrollPanelモデルを@my_model_classに取得している' do
+        # リクエストの対象はスクロールであるが、返されるのはスクコマのリストである。
+        # くれぐれも間違えないように。 
+        get :play, :id => @item_id
+        expect(assigns(:my_model_class)).to be ScrollPanel
       end
-    end
-    context 'ユーザ権限がないとき' do
-      before do
-        sign_out @user
+      it '@itemにリクエストしたスクロールを取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:item)).to eq(@item)
+      end
+      it 'リストグループのマニフェストからプレイリストの取得処理を@listに取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:list).item_name).to eq('scroll_panel')
+        expect(assigns(:list).list_name).to eq('play')
+      end
+      it '@itemsにプレイリストを取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:items).size).to be >= 3
+        expect(assigns(:count)).to be >= 3
+        expect(assigns(:pager)).to be nil
       end
       context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :play, :id => @scroll.id
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :play, :id => @scroll.id
-          response.should redirect_to '/users/sign_in'
+        it 'playテンプレートを描画する' do
+          get :play, :id => @item_id
+          expect(response).to render_template("play")
         end
       end
       context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.message.should match(/Unauthorized/)
+        it 'jsonデータを返す' do
+          get :play, :id => @item_id, :format => :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
       end
     end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :play, :id => @scroll.id
-        response.should be_success 
-      end
-    end
-    context 'ユーザだが作家登録していないとき' do
-      before do
-        @author.destroy
+      it '創作活動してないROM専の読者にも通常通り応答する' do
+        sign_in @user_rom
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :play, :id => @scroll.id
-        response.should be_success 
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :play, id: @item_id
       end
     end
   end
-
-  describe 'スクロール数取得に於いて' do
+  
+  describe '新規作成フォーム表示に於いて' do
     before do
-      Scroll.should_receive(:visible_count).and_return(3)
-#      sign_in @user
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :count, :format => :json
-        response.should be_success 
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      context 'json形式' do
-        it 'jsonデータを返す' do
-          get :count, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'データがHash構造になっていてスクロール数が1である' do
-          get :count, :format => :json
-          json = JSON.parse response.body
-          json["count"].should == 3
-        end
+      it '[html, json]でステータス OKを返す' do
+        return_ok_at_get :new
+        return_ok_at_get :new, format: :json
       end
-    end
-  end
-
-  describe '新規作成フォーム表示に於いて' do
-    before do
-      sign_in @user
-    end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
         get :new
-        response.should be_success 
+        expect(assigns(:my_model_class)).to be Scroll
       end
-      it '@scrollに新規データを用意している' do
+      it '@itemに新規データを用意している' do
         get :new
-        assigns(:scroll).should be_a_new(Scroll)
+        expect(assigns(:item)).to eq(@item)
       end
-      it 'スクロールモデルにデフォルト値補充を依頼している' do
-        Scroll.any_instance.should_receive(:supply_default).exactly(1)
+      it '@formに入力フォーム(Bucket)を取得している' do
+        get :new
+        expect(assigns(:form).item).to eq(@item)
+        expect(assigns(:form).mounted).to eq(true)
+        expect(assigns(:form).submit).to eq(true)
+      end
+      it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
+        expect_any_instance_of(Scroll).to receive(:supply_default)
+        expect_any_instance_of(Scroll).to receive(:boosts)
         get :new
       end
       context 'html形式' do
-        it 'newテンプレートを描画する' do
+        it 'formテンプレートを描画する' do
           get :new
-          response.should render_template("new")
-        end
-      end
-      context 'js形式' do
-        it 'new.jsテンプレートを描画する' do
-          get :new, :format => :js
-          response.should render_template("new")
+          expect(response).to render_template("templates/r/form/form")
         end
       end
       context 'json形式' do
         it 'jsonデータを返す' do
-          get :new, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'スクロールモデルにjson単体出力オプションを問い合わせている' do
-          Scroll.should_receive(:show_json_opt).exactly(1)
-          get :new, :format => :json
+          get :new, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
       end
     end
-    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84とき' do
+    context 'ã\82µã\82¤ã\83³ã\82¤ã\83³ã\81®ç\8a¶æ\85\8bã\81\8cä¾\8bå¤\96ç\9a\84ã\81ªとき' do
       before do
-        sign_out @user
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :new
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :new
-          response.body.should redirect_to '/users/sign_in'
-        end
+        sign_in @user_rom
       end
-      context 'js形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :new, :format => :js
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :new, :format => :js
-          response.message.should match(/Unauthorized/)
-        end
+      it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
+        get :new
+        expect(response.status).to eq(302)
+        expect(response).to redirect_to new_author_path
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :new, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :new, :format => :json
-          response.message.should match(/Unauthorized/)
-        end
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :new, id: @item_id
       end
-    end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user
+      it 'ユーザではなく管理者でもサインインページに遷移する' do
         sign_in @admin
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :new
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :new
-          response.body.should redirect_to '/users/sign_in'
-        end
+        announce_sign_in_at_get :new, id: @item_id
       end
     end
     context 'ユーザだが作家登録していないとき' do
@@ -404,7 +307,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
           get :new, @attr
           response.status.should eq 302
         end
-        it '作家登録ページへ遷移する' do
+        it '' do
           get :new, @attr
           response.body.should redirect_to new_author_path
         end
@@ -435,7 +338,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
         post :create, :scroll => @attr
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it "@scrollに作成されたスクロールを保持していて、それがDBにある" do
         post :create, :scroll => @attr
         assigns(:scroll).should be_a(Scroll)
@@ -564,7 +467,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
       sign_in @user
       Scroll.stub(:edit).and_return(@scroll)
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :edit, :id => @scroll.id
         response.should be_success 
@@ -678,7 +581,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
         assigns(:scroll).id.should eq(@scroll.id)
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it '更新される' do
         put :update, :id => @scroll.id, :scroll => @attr
         Scroll.find(@scroll.id).visible.should eq 0
@@ -810,7 +713,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
         assigns(:scroll).id.should eq(@scroll.id)
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it '削除される' do
         lambda {
           delete :destroy, :id => @scroll.id
@@ -929,7 +832,7 @@ else
       Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :index
         response.should be_success 
@@ -976,7 +879,7 @@ else
       Scroll.stub(:show).and_return(@scroll)
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :show, :id => @scroll.id
         response.should be_success
@@ -1021,7 +924,7 @@ else
       Scroll.should_receive(:visible_count).and_return(3)
       sign_out @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :count, :format => :json
         response.should be_success 
@@ -1039,7 +942,7 @@ else
     before do
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :new
         response.should be_success 
@@ -1105,7 +1008,7 @@ else
       sign_in @user
       @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'normal')
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Scroll.any_instance.stub(:save).and_return(true)
@@ -1163,7 +1066,7 @@ else
       sign_in @user
       Scroll.stub(:edit).and_return(@scroll)
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :edit, :id => @scroll.id
         response.should be_success 
@@ -1214,7 +1117,7 @@ else
       @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'updated title', :visible => 0)
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
@@ -1261,7 +1164,7 @@ else
       @scroll = FactoryGirl.create :scroll, :author => @author
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         before do
           Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
diff --git a/spec/deprecations.txt b/spec/deprecations.txt
new file mode 100644 (file)
index 0000000..e69de29
index c0569b6..fb8d32b 100644 (file)
@@ -2,8 +2,7 @@
 ENV["RAILS_ENV"] ||= 'test'
 require File.expand_path("../../config/environment", __FILE__)
 require 'rspec/rails'
-require 'rspec/autorun'
-require File.dirname(__FILE__) + '/controller_helper'
+require File.dirname(__FILE__) + '/support/controller_macros'
 
 # Requires supporting ruby files with custom matchers and macros, etc,
 # in spec/support/ and its subdirectories.
@@ -11,6 +10,7 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
 Dir.glob(File.dirname(__FILE__) + '/factories/*.rb').each {|f| require f }
 
 RSpec.configure do |config|
+  config.deprecation_stream = File.open(File.dirname(__FILE__) + '/deprecations.txt', 'w')
   # == Mock Framework
   #
   # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
index 3b4d0e7..11440f4 100644 (file)
@@ -1,2 +1,55 @@
 module ControllerMacros\r
-end
+  def list_should_return_filer_or_json action, params = {}\r
+    # html形式: \r
+    # ステータスコード200 OKを返す\r
+    # filerテンプレートを描画する\r
+    get action, params\r
+    expect(response).to be_success\r
+    expect(response).to render_template("templates/r/filer/filer")\r
+    # json形式\r
+    # ステータスコード200 OKを返す\r
+    # jsonデータを返す\r
+    get action, params.merge(:format => :json)\r
+    expect(response).to be_success\r
+    expect {JSON.parse(response.body)}.not_to raise_error\r
+  end\r
+  \r
+  def announce_sign_in_at_get action, params = {}\r
+    # html形式: ステータスコード302 Foundを返す\r
+    get action, params\r
+    expect(response.status).to eq(302)\r
+    expect(response).to redirect_to '/users/sign_in'\r
+    # json形式: ステータスコード401 Unauthorizedを返す\r
+    get action, params.merge(:format => :json)\r
+    expect(response.status).to eq(401)\r
+    expect(response.message).to match(/Unauthorized/)\r
+  end\r
+  \r
+  def return_ok_at_get action, params = {}\r
+    # ステータスコード200 OKを返す\r
+    get action, params\r
+    expect(response).to be_success\r
+  end\r
+  \r
+  def show_action_return_profiler item_id\r
+    # prof形式: ステータスコード200 OKを返す\r
+    get :show, :id => item_id, :format => :prof\r
+    expect(response).to be_success\r
+    # json形式: ステータスコード200 OKを返す\r
+    get action, params.merge(:format => :json)\r
+    expect(response).to be_success\r
+  end\r
+  \r
+  def announce_regist_owner_in_at_get action, params = {}\r
+    # html形式: ステータスコード302 Foundを返す\r
+    get action, params\r
+    expect(response.status).to eq(302)\r
+    expect(response).to redirect_to '/users/sign_in'\r
+    # json形式: ステータスコード401 Unauthorizedを返す\r
+    get action, params.merge(:format => :json)\r
+    expect(response.status).to eq(401)\r
+    expect(response.message).to match(/Unauthorized/)\r
+  end\r
+  \r
+end\r
+\r