2014-04-04 35 views
0

你好我試圖存根在控制器中的around_filter方法,該方法返回true始終,在rspec的around_filter stubbing在Rspec中?

before(:each) do 
    controller.stub(:catch_exceptions).and_return(true) 
end 
after(:each) do 
    controller.stub(:catch_exceptions).and_return(true) 
end 

使用下面的源代碼,但它失敗。當我改變那個特定的方法,因爲before_filter然後它工作正常?任何人都可以幫助我嗎?

回答

2

要正確存根的around_filter,你應該yield爲經營工作的休息,否則,你只是磕碰整個動作......

controller.stub(:catch_exceptions).and_yield 
+0

謝謝你這麼多@Uri阿加西 – ferdy