OSDN Git Service

fix: any
[pettanr/pettanr.git] / spec / controllers / scrolls_controller_spec.rb
index bd76f30..e828f7d 100644 (file)
@@ -7,154 +7,301 @@ describe ScrollsController do
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @my_model_class =  Scroll   #操作モデル
   end
 
 if Manifest.manifest.magic_numbers['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
       factory_contents :scroll_hello, @author_yas
+      @query = { }
+      @query_format_json = @query.merge(:format => :json)
     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
-        expect(assigns(:items).size).to be >= 3
+      context '共通処理' do
+        before do
+          get :index, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it 'コントローラのマニフェストからリスト操作モデルを導出している' do
+          set_list_model? @my_model_class
+        end
+        it 'リストグループのマニフェストからリストgetter(新着リスト)を導出している' do
+          set_list? 'scroll', 'public'
+        end
+        it '@itemsにリストを取得している' do
+          expect(assigns(:items).size).to be >= 3
+        end
       end
       context 'html形式' do
+        before do
+          get :index, @query
+        end
+        it 'ステータス OKを返して、ファイラーを描画している' do
+          return_ok?
+          render_filer?
+        end
         it '@filerにファイラーを取得している' do
-          get :index
-          expect(assigns(:filer).class).to be Locmare::Filer
+          let_filer?
         end
       end
       context 'json形式' do
+        before do
+          get :index, @query_format_json
+        end
+        it 'ステータス OKを返して、jsonデータを返している' do
+          return_ok?
+          render_json?
+        end
         it '@filerにファイラーをセットしていない' do
-          get :index, format: :json
           expect(assigns(:filer)).to be nil
         end
       end
     end
     context '件数取得' do
-      before do
-        sign_in @user_yas
-      end
-      it 'ステータス OKを返す' do
-        return_ok_at_get :count, format: :json
-      end
       context 'html形式' do
         it '必要ないので実装していない' do
-          get :count
+          sign_in @user_yas
+          get :count, @query
           expect(response.status).to eq(406)
         end
       end
       context 'json形式' do
-        it 'jsonデータを返す' do
-          get :count, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+        it 'ステータス OKを返して、jsonデータを返している' do
+          sign_in @user_yas
+          get :count, @query_format_json
+          return_ok?
+          render_json?
+        end
+      end
+      context 'ゲスト(サインインしていない)' do
+        it '通常通り応答する' do
+          get :count, @query_format_json
+          return_ok?
+          render_json?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        return_ok_at_get :index
-        return_ok_at_get :index, format: :json
+        get :index, @query
+        return_ok?
+        get :index, @query_format_json
+        render_json?
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @user_rom
-        return_ok_at_get :index
-        return_ok_at_get :index, format: :json
+        get :index, @query
+        return_ok?
+        get :index, @query_format_json
+        render_json?
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :index
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :index, @query
+        redirect? sign_in_url
+        get :index, @query_format_json
+        render_unauthorized?
       end
     end
   end
   describe '作家フィルタ一覧及びカウント' do
     before do
       factory_contents :scroll_hello, @author_yas
+      @query = {:id => @author_yas.id}
+      @query_format_json = @query.merge(:format => :json)
     end
     
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it 'ステータス OKを返して、ファイラーまたはjsonデータを返す。' do
-        list_should_return_filer_or_json :by_author, id: @author_yas.id
-      end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        get :by_author, id: @author_yas.id
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
-        get :by_author, id: @author_yas.id
-        expect(assigns(:list).item_name).to eq('scroll')
-        expect(assigns(:list).list_name).to eq('by_author')
-      end
-      it '@itemsにリストを取得している' do
-        get :by_author, id: @author_yas.id
-        expect(assigns(:items).size).to be >= 3
+      context '共通処理' do
+        before do
+          get :by_author, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
+          set_list? 'scroll', 'by_author'
+        end
+        it '@itemsにリストを取得している' do
+          expect(assigns(:items).size).to be >= 3
+        end
       end
       context 'html形式' do
+        before do
+          get :by_author, @query
+        end
+        it 'ステータス OKを返して、ファイラーを描画している' do
+          return_ok?
+          render_filer?
+        end
         it '@filerにファイラーを取得している' do
-          get :by_author, id: @author_yas.id
-          expect(assigns(:filer).class).to be Locmare::Filer
+          let_filer?
         end
       end
       context 'json形式' do
+        before do
+          get :by_author, @query_format_json
+        end
+        it 'ステータス OKを返して、jsonデータを返している' do
+          return_ok?
+          render_json?
+        end
         it '@filerにファイラーをセットしていない' do
-          get :by_author, id: @author_yas.id, format: :json
           expect(assigns(:filer)).to be nil
         end
       end
     end
     context '件数取得' do
+      context 'html形式' do
+        it '必要ないので実装していない' do
+          sign_in @user_yas
+          get :count_by_author, @query
+          expect(response.status).to eq(406)
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          sign_in @user_yas
+          get :count_by_author, @query_format_json
+          return_ok?
+          render_json?
+        end
+      end
+      context 'ゲスト(サインインしていない)' do
+        it '通常通り応答している' do
+          get :count_by_author, @query_format_json
+          return_ok?
+          render_json?
+        end
+      end
+    end
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答している' do
+        sign_in @admin
+        get :by_author, @query
+        return_ok?
+        get :by_author, @query_format_json
+        render_json?
+      end
+      it '創作活動してないROM専の読者にも通常通り応答している' do
+        sign_in @user_rom
+        return_ok?
+        get :by_author, @query_format_json
+        render_json?
+      end
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :by_author, @query
+        redirect? sign_in_url
+        get :by_author, @query_format_json
+        render_unauthorized?
+      end
+    end
+  end
+  
+  describe 'コマフィルタ一覧及びカウント' do
+    before do
+      @panel = FactoryGirl.create :panel_hello_with_scroll_panels, author_id: @author_yas.id
+      @query = {:id => @panel.id}
+      @query_format_json = @query.merge(:format => :json)
+    end
+    
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it 'ステータス OKを返す' do
-        return_ok_at_get :count_by_author, id: @author_yas.id, format: :json
+      context '共通処理' do
+        before do
+          get :by_panel, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
+          set_list? 'scroll', 'by_panel'
+        end
+        it '@itemsにリストを取得している' do
+          expect(assigns(:items).size).to be >= 3
+        end
+      end
+      context 'html形式' do
+        before do
+          get :by_panel, @query
+        end
+        it 'ステータス OKを返して、ファイラーを描画している' do
+          return_ok?
+          render_filer?
+        end
+        it '@filerにファイラーを取得している' do
+          let_filer?
+        end
+      end
+      context 'json形式' do
+        before do
+          get :by_panel, @query_format_json
+        end
+        it 'ステータス OKを返して、jsonデータを返している' do
+          return_ok?
+          render_json?
+        end
+        it '@filerにファイラーをセットしていない' do
+          expect(assigns(:filer)).to be nil
+        end
       end
+    end
+    context '件数取得' do
       context 'html形式' do
         it '必要ないので実装していない' do
-          get :count_by_author, id: @author_yas.id
+          sign_in @user_yas
+          get :count_by_panel, @query
           expect(response.status).to eq(406)
         end
       end
       context 'json形式' do
         it 'jsonデータを返す' do
-          get :count_by_author, id: @author_yas.id, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+          sign_in @user_yas
+          get :count_by_panel, @query_format_json
+          return_ok?
+          render_json?
+        end
+      end
+      context 'ゲスト(サインインしていない)' do
+        it '通常通り応答している' do
+          get :count_by_panel, @query_format_json
+          return_ok?
+          render_json?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        return_ok_at_get :by_author, id: @author_yas.id
-        return_ok_at_get :by_author, id: @author_yas.id, format: :json
+        get :by_panel, @query
+        return_ok?
+        get :by_panel, @query_format_json
+        render_json?
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @user_rom
-        return_ok_at_get :by_author, id: @author_yas.id
-        return_ok_at_get :by_author, id: @author_yas.id, format: :json
+        return_ok?
+        get :by_panel, @query_format_json
+        render_json?
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :by_author, id: @author_yas.id
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :by_panel, @query
+        redirect? sign_in_url
+        get :by_panel, @query_format_json
+        render_unauthorized?
       end
     end
   end
@@ -163,60 +310,82 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     before do
       @item =  FactoryGirl.create :scroll_hello, author: @author_yas
       @item_id = @item.id
+      @query = {:id => @item_id}
+      @query_format_json = @query.merge(:format => :json)
+      @query_format_prof = @query.merge(:format => :prof)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      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)
+      context '正常系の共通処理' do
+        before do
+          get :show, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemにリクエストしたアイテムを取得している' do
+          expect(assigns(:item)).to eq(@item)
+        end
       end
       context 'html形式' do
-        it 'showテンプレートを描画する' do
-          get :show, id: @item_id
+        before do
+          get :show, @query
+        end
+        it 'showテンプレートを描画している' do
+          return_ok?
           expect(response).to render_template("show")
         end
+        it 'プロファイラーは必要ないので@profilerに用意していない' do
+          expect(assigns(:profiler)).to be nil
+        end
       end
       context 'json形式' do
+        before do
+          get :show, @query_format_json
+        end
         it 'jsonデータを返す' do
-          get :show, id: @item_id, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+          return_ok?
+          render_json?
         end
         it 'プロファイラーは必要ないので@profilerに用意していない' do
-          get :show, id: @item_id, format: :json
           expect(assigns(:profiler)).to be nil
         end
       end
       context 'prof形式' do
-        it 'プロファイラーテンプレートを描画する' do
-          get :show, id: @item_id, format: :prof
-          expect(response).to render_template("templates/r/profiler/profiler")
+        before do
+          get :show, @query_format_prof
+        end
+        it 'プロファイラーテンプレートを描画している' do
+          return_ok?
+          render_profiler?
+        end
+        it '@profilerにプロファイラーを取得している' do
+          let_profiler?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        return_ok_at_get :show, id: @item_id
-        return_ok_at_get :show, id: @item_id, format: :json
+        get :show, @query
+        return_ok?
+        get :show, @query_format_json
+        render_json?
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @user_rom
-        return_ok_at_get :show, id: @item_id
-        return_ok_at_get :show, id: @item_id, format: :json
+        get :show, @query
+        return_ok?
+        get :show, @query_format_json
+        render_json?
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :show, id: @item_id
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :show, @query
+        redirect? sign_in_url
+        get :show, @query_format_json
+        render_unauthorized?
       end
     end
   end
@@ -225,129 +394,156 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     before do
       @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
       @item_id = @item.id
+      @query = {:id => @item_id}
+      @query_format_json = @query.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       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
-      it 'コントローラのマニフェストからScrollPanelモデルを@my_model_classに取得している' do
-        # リクエストの対象はスクロールであるが、返されるのはスクコマのリストである。
-        # くれぐれも間違えないように。 
-        get :play, id: @item_id
-        expect(assigns(:my_model_class)).to be ScrollPanel
-      end
-      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)).not_to be nil
+      context '共通処理' do
+        before do
+          get :play, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemにリクエストしたスクロールを取得している' do
+          expect(assigns(:item)).to eq(@item)
+        end
+        it 'コントローラのマニフェストからリスト操作モデルを導出している' do
+          # リクエストの対象はスクロールであるが、返されるのはスクコマのリストである。
+          # くれぐれも間違えないように。 
+          set_list_model? ScrollPanel
+        end
+        it 'リストグループのマニフェストからリストgetter(プレイリスト)を導出している' do
+          set_list? 'scroll_panel', 'play'
+        end
+        it '@itemsにプレイリストを取得している' do
+          set_play_list? ScrollPanel
+        end
       end
       context 'html形式' do
-        it 'playテンプレートを描画する' do
-          get :play, id: @item_id
+        before do
+          get :play, @query
+        end
+        it 'playテンプレートを描画している' do
+          return_ok?
           expect(response).to render_template("play")
         end
       end
       context 'json形式' do
+        before do
+          get :play, @query_format_json
+        end
         it 'jsonデータを返す' do
-          get :play, id: @item_id, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+          return_ok?
+          render_json?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        return_ok_at_get :play, id: @item_id
-        return_ok_at_get :play, id: @item_id, format: :json
+        get :play, @query
+        return_ok?
+        get :play, @query_format_json
+        render_json?
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\82\82é\80\9a常é\80\9aã\82\8aå¿\9cç­\94ã\81\97ã\81¦ã\81\84る' do
         sign_in @user_rom
-        return_ok_at_get :play, id: @item_id
-        return_ok_at_get :play, id: @item_id, format: :json
+        get :play, @query
+        return_ok?
+        get :play, @query_format_json
+        render_json?
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :play, id: @item_id
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :play, @query
+        redirect? sign_in_url
+        get :play, @query_format_json
+        render_unauthorized?
       end
     end
   end
   
   describe '新規作成フォーム表示に於いて' do
     before do
+      @query = { }
+      @query_format_json = @query.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it '[html, json]でステータス OKを返す' do
-        return_ok_at_get :new
-        return_ok_at_get :new, format: :json
-      end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        get :new
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it '@itemに新規データを用意している' do
-        get :new
-        @item = assigns(:item)
-        expect(@item.is_a?(Scroll)).to be true
-        expect(@item.new_record?).to be true
+      context '共通処理' do
+        before do
+          get :new, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemに新規データを用意している' do
+          @item = assigns(:item)
+          expect(@item.is_a?(@my_model_class)).to be true
+          expect(@item.new_record?).to be true
+        end
+        it 'ブーストしている' do
+          boost? []
+        end
       end
-      it '@formに入力フォーム(Bucket)を取得している' do
-        get :new
-        @item = assigns(:item)
-        expect(assigns(:form).item).to eq(@item)
-        expect(assigns(:form).mounted).to eq(true)
-        expect(assigns(:form).submit).to eq(true)
-      end
-      it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
-        allow_any_instance_of(Scroll).to receive(:supply_default)
-        allow_any_instance_of(Scroll).to receive(:boosts)
-        expect_any_instance_of(Scroll).to receive(:supply_default)
-        expect_any_instance_of(Scroll).to receive(:boosts)
-        get :new
+      context '問い合わせ' do
+        it 'スクロールモデルにデフォルト値補充を依頼している' do
+          allow_any_instance_of(@my_model_class).to receive(:supply_default)
+          expect_any_instance_of(@my_model_class).to receive(:supply_default)
+          get :new, @query
+        end
       end
       context 'html形式' do
-        it 'formテンプレートを描画する' do
-          get :new
-          expect(response).to render_template("templates/r/form/form")
+        before do
+          get :new, @query
+        end
+        it 'formテンプレートを描画している' do
+          return_ok?
+          render_form?
+        end
+        it '@formに入力フォーム(Bucket)を取得している' do
+          set_bucket? assigns(:item)
         end
       end
       context 'json形式' do
+        before do
+          get :new, @query_format_json
+        end
         it 'jsonデータを返す' do
-          get :new, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+          return_ok?
+          render_json?
+        end
+        it '入力フォームは必要ないので@formに用意していない' do
+          expect(assigns(:form)).to be nil
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
       before do
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\97ã\81¦ã\81\84ã\82\8b, ä¾\8bå¤\96ã\82\92ç\99ºç\94\9fã\81\95ã\81\9bã\81¦ã\81\84る' do
         sign_in @user_rom
-        get :new
-        announce_regist_author_for_html
-        announce_regist_author_for_json :get
+        get :new, @query
+        redirect? new_author_path
+        announce_regist_author_for_json :get, @query_format_json, :new
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :new
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        get :new, @query
+        redirect? sign_in_url
+        get :new, @query_format_json
+        render_unauthorized?
       end
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        announce_sign_in_at_get :new
+        get :new, @query
+        redirect? sign_in_url
+        get :new, @query_format_json
+        render_unauthorized?
       end
     end
   end
@@ -356,86 +552,98 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     before do
       @attributes = FactoryGirl.attributes_for(:scroll_hello, author_id: @author_yas.id)
       @attr = {:scroll => @attributes}
+      @attr_format_json = @attr.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        allow_save Scroll
-        post_save @attr
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it '@itemに新規アイテムを用意している' do
-        allow_save Scroll
-        post_save @attr
-        @item = assigns(:item)
-        expect(@item.is_a?(Scroll)).to be true
+      context '共通処理' do
+        before do
+          allow_save @my_model_class
+          post :create, @attr
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemに新規アイテムを用意している' do
+          @item = assigns(:item)
+          expect(@item.is_a?(@my_model_class)).to be true
+        end
       end
       context 'html形式' do
-        it 'ステータスコード302 Foundを返して, 作成されたアイテムの表示ページへ遷移する' do
-          post_save @attr
-          expect(response.status).to eq(302)
-          expect(response).to redirect_to Scroll.last
+        before do
+          post :create, @attr
+        end
+        it '作成されたアイテムの表示ページへ遷移している' do
+          redirect? @my_model_class.last
         end
       end
       context 'json形式' do
+        before do
+          post :create, @attr_format_json
+        end
         it 'ステータスコード200 OKを返して, 作成されたアイテムをjsonデータで返す' do
-          post_save @attr.merge(:format => :json)
-          expect(response).to be_success
-          expect {JSON.parse(response.body)}.not_to raise_error
+          return_ok?
+          render_json?
+        end
+      end
+      context 'db' do
+        it '作成されている' do
+          expect {
+            post :create, @attr
+          }.to change {@my_model_class.count}.by(1)
         end
       end
     end
     context '検証、保存に失敗したとき' do
       before do
         sign_in @user_yas
-        reject_save Scroll
+        reject_save @my_model_class
       end
       context 'html形式' do
-        it 'ステータスコード200 OKを返して, formテンプレートを描画する' do
-          post_save @attr
-          expect(response).to be_success
-          expect(response).to render_template("templates/r/form/form")
+        before do
+          post :create, @attr
+        end
+        it 'ステータスコード200 OKを返して, formテンプレートを描画している' do
+          return_ok?
+          render_form?
         end
         it '@formに入力フォーム(Bucket)を取得している' do
-          post_save @attr
-          @item = assigns(:item)
-          expect(assigns(:form).item).to eq(@item)
-          expect(assigns(:form).mounted).to eq(true)
-          expect(assigns(:form).submit).to eq(true)
+          set_bucket? assigns(:item)
         end
       end
       context 'json形式' do
-        it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
-          post_save @attr.merge(:format => :json)
-          expect(response.status).to eq(422)
-          expect(response.message).to match(/Unprocessable/)
+        before do
+          post :create, @attr_format_json
+        end
+        it '処理不能を返している' do
+          render_unprocessable?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
       before do
-        allow_save Scroll
+        allow_save @my_model_class
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\97ã\81¦ã\81\84ã\82\8b, ä¾\8bå¤\96ã\82\92ç\99ºç\94\9fã\81\95ã\81\9bã\81¦ã\81\84る' do
         sign_in @user_rom
-        post_save @attr
-        announce_regist_author_for_html
-        announce_regist_author_for_json :post, @attr
+        post :create, @attr
+        redirect? new_author_path
+        announce_regist_author_for_json :post, @attr_format_json, :create
       end
-      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
-        post_save @attr
-        announce_sign_in_for_html
-        post_save @attr.merge(:format => :json)
-        announce_sign_in_for_json
+      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
+        post :create, @attr
+        redirect? sign_in_url
+        post :create, @attr_format_json
+        render_unauthorized?
       end
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        post_save @attr
-        announce_sign_in_for_html
-        post_save @attr.merge(:format => :json)
-        announce_sign_in_for_json
+        post :create, @attr
+        redirect? sign_in_url
+        post :create, @attr_format_json
+        render_unauthorized?
       end
     end
   end
@@ -444,66 +652,75 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     before do
       @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
       @item_id = @item.id
+      @query = {:id => @item_id}
+      @query_format_json = @query.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it '[html, json]でステータス OKを返す' do
-        return_ok_at_get :edit, id: @item_id
-        return_ok_at_get :edit, id: @item_id, format: :json
-      end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        get :edit, id: @item_id
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it '@itemにリクエストしたスクロールを取得している' do
-        get :edit, id: @item_id
-        expect(assigns(:item).is_a?(Scroll)).to be true
-        expect(assigns(:item).new_record?).not_to be true
-        expect(assigns(:item)).to eq(@item)
-      end
-      it '@formに入力フォーム(Bucket)を取得している' do
-        get :edit, id: @item_id
-        @item = assigns(:item)
-        expect(assigns(:form).item).to eq(@item)
-        expect(assigns(:form).mounted).to eq(true)
-        expect(assigns(:form).submit).to eq(true)
-      end
-      it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
-        allow_any_instance_of(Scroll).to receive(:boosts)
-        expect_any_instance_of(Scroll).to receive(:boosts)
-        get :edit, id: @item_id
+      context '共通処理' do
+        before do
+          get :edit, @query
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemにリクエストしたアイテムを取得している' do
+          expect(assigns(:item).is_a?(@my_model_class)).to be true
+          expect(assigns(:item)).to eq(@item)
+        end
+        it 'ブーストしている' do
+          boost? []
+        end
       end
       context 'html形式' do
-        it 'formテンプレートを描画する' do
-          get :edit, id: @item_id
-          expect(response).to render_template("templates/r/form/form")
+        before do
+          get :edit, @query
+        end
+        it 'formテンプレートを描画している' do
+          return_ok?
+          render_form?
+        end
+        it '@formに入力フォーム(Bucket)を取得している' do
+          set_bucket? assigns(:item)
         end
       end
       context 'json形式' do
+        before do
+          get :edit, @query_format_json
+        end
         it 'jsonデータを返す' do
-          get :edit, id: @item_id, format: :json
-          expect {JSON.parse(response.body)}.not_to raise_error
+          return_ok?
+          render_json?
+        end
+        it '入力フォームは必要ないので@formに用意していない' do
+          expect(assigns(:form)).to be nil
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
       before do
-        allow_save Scroll
+        allow_save @my_model_class
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\97ã\81¦ã\81\84ã\82\8b, ä¾\8bå¤\96ã\82\92ç\99ºç\94\9fã\81\95ã\81\9bã\81¦ã\81\84る' do
         sign_in @user_rom
-        get :edit, id: @item_id
-        expect(response.status).to eq(302)
-        expect(response).to redirect_to new_author_path
+        get :edit, @query
+        redirect? new_author_path
+        announce_regist_author_for_json :get, @query_format_json, :edit
       end
-      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
-        announce_sign_in_at_get :new
+      it 'ゲスト(サインインしていない)はサインインページに遷移している' do
+        post :edit, @query
+        redirect? sign_in_url
+        post :edit, @query_format_json
+        render_unauthorized?
       end
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        announce_sign_in_at_get :new
+        post :edit, @query
+        redirect? sign_in_url
+        post :edit, @query_format_json
+        render_unauthorized?
       end
     end
   end
@@ -514,87 +731,110 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
       @item_id = @item.id
       @attributes = FactoryGirl.attributes_for(:scroll_hidden, author_id: @author_yas.id)
       @attr = {:id => @item_id, :scroll => @attributes}
+      @attr_format_json = @attr.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        allow_save Scroll
-        put_save @attr
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it '@itemにリクエストしたアイテムを取得して, 更新している' do
-        allow_save Scroll
-        put_save @attr
-        expect(assigns(:item).is_a?(Scroll)).to be true
-        expect(assigns(:item).visible).to eq(0)
-        expect(assigns(:item)).to eq(@item)
+      context '共通処理' do
+        before do
+          allow_save @my_model_class
+          put :update, @attr
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemにリクエストしたアイテムを取得している' do
+          expect(assigns(:item).is_a?(@my_model_class)).to be true
+          expect(assigns(:item)).to eq(@item)
+        end
       end
       context 'html形式' do
-        it 'ステータスコード302 Foundを返して, 作成されたアイテムの表示ページへ遷移する' do
-          put_save @attr
-          expect(response.status).to eq(302)
-          expect(response).to redirect_to @item
+        before do
+          allow_save @my_model_class
+          put :update, @attr
+        end
+        it 'リクエストしたアイテムの表示ページへ遷移している' do
+          redirect? @item
         end
       end
       context 'json形式' do
+        before do
+          allow_save @my_model_class
+          put :update, @attr_format_json
+        end
         it 'ステータスコード200 OKを返して, ページ本体は特に返さない' do
-          put_save @attr.merge(:format => :json)
-          expect(response).to be_success
-          expect(response.message).to match /./
+          return_ok?
+          render_complated?
+        end
+      end
+      context 'db' do
+        it '@itemの件数に変わりはない' do
+          expect {
+            put :update, @attr
+          }.to change {@my_model_class.count}.by(0)
+        end
+        it '@itemを更新している' do
+          put :update, @attr
+          # dbから取得しなおす
+          updated_item = @my_model_class.find @item_id
+          # 変化を確認できるカラムはモデルごとに違うので注意
+          expect(updated_item.visible).to eq(0)
         end
       end
     end
     context '検証、保存に失敗したとき' do
       before do
         sign_in @user_yas
-        reject_save Scroll
+        reject_save @my_model_class
       end
       context 'html形式' do
-        it 'ステータスコード200 OKを返して, formテンプレートを描画する' do
-          put_save @attr
-          expect(response).to be_success
-          expect(response).to render_template("templates/r/form/form")
+        before do
+          put :update, @attr
+        end
+        it 'ステータスコード200 OKを返して, formテンプレートを描画している' do
+          return_ok?
+          render_form?
         end
         it '@formに入力フォーム(Bucket)を取得している' do
-          put_save @attr
-          @item = assigns(:item)
-          expect(assigns(:form).item).to eq(@item)
-          expect(assigns(:form).mounted).to eq(true)
-          expect(assigns(:form).submit).to eq(true)
+          set_bucket? assigns(:item)
         end
       end
       context 'json形式' do
-        it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
-          put_save @attr.merge(:format => :json)
-          expect(response.status).to eq(422)
-          expect(response.message).to match(/Unprocessable/)
+        before do
+          put :update, @attr_format_json
+        end
+        it '処理不能を返している' do
+          render_unprocessable?
+        end
+        it '入力フォームは必要ないので@formに用意していない' do
+          expect(assigns(:form)).to be nil
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
       before do
-        allow_save Scroll
+        allow_save @my_model_class
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\97ã\81¦ã\81\84ã\82\8b, ä¾\8bå¤\96ã\82\92ç\99ºç\94\9fã\81\95ã\81\9bã\81¦ã\81\84る' do
         sign_in @user_rom
-        put_save @attr
-        announce_regist_author_for_html
-        announce_regist_author_for_json :put, @attr
+        put :update, @attr
+        redirect? new_author_path
+        announce_regist_author_for_json :put, @attr_format_json, :update
       end
-      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
-        put_save @attr
-        announce_sign_in_for_html
-        put_save @attr.merge(:format => :json)
-        announce_sign_in_for_json
+      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
+        put :update, @attr
+        redirect? sign_in_url
+        put :update, @attr_format_json
+        render_unauthorized?
       end
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        put_save @attr
-        announce_sign_in_for_html
-        put_save @attr.merge(:format => :json)
-        announce_sign_in_for_json
+        put :update, @attr
+        redirect? sign_in_url
+        put :update, @attr_format_json
+        render_unauthorized?
       end
     end
   end
@@ -604,90 +844,101 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
       @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
       @item_id = @item.id
       @attr = {:id => @item_id}
-      @attr_with_json = @attr.merge(:format => :json)
+      @attr_format_json = @attr.merge(:format => :json)
     end
-    context '正常系の共通処理' do
+    context '正常系' do
       before do
         sign_in @user_yas
       end
-      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
-        allow_destroy Scroll
-        destroy_save @attr
-        expect(assigns(:my_model_class)).to be Scroll
-      end
-      it '@itemにリクエストしたアイテムを取得している' do
-        allow_destroy Scroll
-        destroy_save @attr
-        expect(assigns(:item).is_a?(Scroll)).to be true
-        expect(assigns(:item)).to eq(@item)
-      end
-      it '削除されている' do
-        lambda {
-          destroy_save @attr
-        }.should change Scroll, :count
-      end
-      it 'ぶら下がるリーフも削除されている' do
-        lambda {
-          destroy_save @attr
-        }.should change ScrollPanel, :count
+      context '共通処理' do
+        before do
+          allow_destroy @my_model_class
+          delete :destroy, @attr
+        end
+        it 'コントローラのマニフェストから操作モデルを導出している' do
+          set_model? @my_model_class
+        end
+        it '@itemにリクエストしたアイテムを取得している' do
+          expect(assigns(:item).is_a?(@my_model_class)).to be true
+          expect(assigns(:item)).to eq(@item)
+        end
       end
       context 'html形式' do
-        it 'ステータスコード302 Foundを返して, マイスクロールの一覧ページへ遷移する' do
-          destroy_save @attr
-          expect(response.status).to eq(302)
-          expect(response).to redirect_to '/home/scrolls'
+        before do
+          allow_destroy @my_model_class
+          delete :destroy, @attr
+        end
+        it 'マイスクロールの一覧ページへ遷移している' do
+          redirect? '/home/scrolls'
         end
       end
       context 'json形式' do
+        before do
+          allow_destroy @my_model_class
+          delete :destroy, @attr_format_json
+        end
         it 'ステータスコード200 OKを返して, ページ本体は特に返さない' do
-          destroy_save @attr_with_json
           expect(response).to be_success
-          expect(response.message).to match /./
+          render_complated?
+        end
+      end
+      context 'db' do
+        it '削除されている' do
+          expect {
+            delete :destroy, @attr
+          }.to change {@my_model_class.count}.by(-1)
+        end
+        it 'ぶら下がるリーフも削除されている' do
+          expect {
+            delete :destroy, @attr
+          }.to change {ScrollPanel.count}.from(4).to(0)
         end
       end
     end
     context '検証、保存に失敗したとき' do
       before do
         sign_in @user_yas
-        reject_destroy Scroll
+        reject_destroy @my_model_class
       end
       context 'html形式' do
-        it 'ステータスコード302 Foundを返して, そのスクロールの詳細ページへ遷移する' do
-          destroy_save @attr
-          expect(response.status).to eq(302)
-          expect(response).to redirect_to @item
+        before do
+          delete :destroy, @attr
+        end
+        it 'リクエストしたアイテムの詳細ページへ遷移している' do
+          redirect? @item
         end
       end
       context 'json形式' do
-        it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
-          destroy_save @attr_with_json
-          expect(response.status).to eq(422)
-          expect(response.message).to match(/Unprocessable/)
+        before do
+          delete :destroy, @attr_format_json
+        end
+        it '処理不能を返している' do
+          render_unprocessable?
         end
       end
     end
     context 'サインインの状態が例外的なとき' do
       before do
-        allow_destroy Scroll
+        allow_destroy @my_model_class
       end
-      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81«ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99る' do
+      it 'å\89µä½\9cæ´»å\8b\95ã\81\97ã\81¦ã\81ªã\81\84ROMå°\82ã\81®èª­è\80\85ã\81¯ä½\9c家ç\99»é\8c²ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\97ã\81¦ã\81\84ã\82\8b, ä¾\8bå¤\96ã\82\92ç\99ºç\94\9fã\81\95ã\81\9bã\81¦ã\81\84る' do
         sign_in @user_rom
-        destroy_save @attr
-        announce_regist_author_for_html
-        announce_regist_author_for_json :delete, @attr_with_json
+        delete :destroy, @attr
+        redirect? new_author_path
+        announce_regist_author_for_json :delete, @attr_format_json, :destroy
       end
-      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
-        destroy_save @attr
-        announce_sign_in_for_html
-        destroy_save @attr_with_json
-        announce_sign_in_for_json
+      it 'ã\82²ã\82¹ã\83\88\82µã\82¤ã\83³ã\82¤ã\83³ã\81\97ã\81¦ã\81\84ã\81ªã\81\84\81¯ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
+        delete :destroy, @attr
+        redirect? sign_in_url
+        delete :destroy, @attr_format_json
+        render_unauthorized?
       end
-      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\99る' do
+      it 'ã\83¦ã\83¼ã\82¶ã\81§ã\81¯ã\81ªã\81\8f管ç\90\86è\80\85ã\81§ã\82\82ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81«é\81·ç§»ã\81\97ã\81¦ã\81\84る' do
         sign_in @admin
-        destroy_save id: @item_id
-        announce_sign_in_for_html
-        destroy_save @attr_with_json
-        announce_sign_in_for_json
+        delete :destroy, @attr
+        redirect? sign_in_url
+        delete :destroy, @attr_format_json
+        render_unauthorized?
       end
     end
   end