OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / support / controller_macros.rb
index ef7dd7c..7b8981a 100644 (file)
@@ -65,6 +65,10 @@ module ControllerMacros
     put action, params\r
   end\r
   \r
+  def destroy_save params, action = :destroy\r
+    delete action, params\r
+  end\r
+  \r
   # 保存処理を成功したことにしてスキップする\r
   def allow_save my_model_class\r
     allow_any_instance_of(my_model_class).to receive(:save).and_return(true)\r
@@ -75,6 +79,16 @@ module ControllerMacros
     allow_any_instance_of(my_model_class).to receive(:save).and_return(false)\r
   end\r
   \r
+  # 削除処理を成功したことにしてスキップする\r
+  def allow_destroy my_model_class\r
+    allow_any_instance_of(my_model_class).to receive(:destroy).and_return(true)\r
+  end\r
+  \r
+  # 削除処理を失敗したことにしてスキップする\r
+  def reject_destroy my_model_class\r
+    allow_any_instance_of(my_model_class).to receive(:destroy).and_return(false)\r
+  end\r
+  \r
   def show_action_return_profiler item_id\r
     # prof形式: ステータスコード200 OKを返す\r
     get :show, :id => item_id, :format => :prof\r