スポーンブロックを呼び出すコントローラーアクションがあります
class MyController < ApplicationController
....
def send_product_mails
if @user.has_rights?
spawn_block(:nice => 19 ) do
@current_product.send_mail
end
end
end
...
end
@current_product で send_mail が呼び出されていることを確認したいのですが、受信していないことがわかります..どうすればよいですか?
私の仕様は次のようになります。
it "works with spawn" do
# Setup: create Product, Usersession (via UserSession.create(user))
get :send_product_mails, :id => product.id
MyController.any_instance.should_receive(:spawn_block).and_yield("sd")
end
spawn_block
ユーザーが権利を持っている場合は何かが渡され、そうでない場合は何も渡されないことを仕様にしたいと思います。現在、さまざまな.should_receive
試行を行っています (MyController、MyController.any_instance、@controller のテストを呼び出すと、and_yield の有無にかかわらず、メッセージspawn_block
が受信されなかったというエラーが常に発生します。 if-statement 内に puts-debug-output を入れます。)
編集:質問にさらにコンテキストとコードを与え、私が試したこと