ferdy
ferdy

Reputation: 41

around_filter stubbing in Rspec?

Hi I am trying to stub an around_filter method in controller which return true always,using the below source code in rspec

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

but it fails. When i change that particular method as before_filter then it works fine? can anyone help me plz?

Upvotes: 0

Views: 276

Answers (1)

Uri Agassi
Uri Agassi

Reputation: 37419

To correctly stub an around_filter, you should yield for the rest of the operation to work, otherwise, you are simply stubbing the whole action...

controller.stub(:catch_exceptions).and_yield

Upvotes: 2

Related Questions