Reputation: 4595
I have the following in a feature spec:
it "shows the page" do
Project.any_instance.stub(:price_all)
login_user
gso = create(:gs_option)
gso.gs_collector.collector.project.update(user_id: @user.id)
visit edit_gs_option_path(gso)
end
Yet, it always fails because the price_all method on Project is not being stubbed. The failure trace contains the following:
# ./app/models/project.rb:430:in `price_all'
How do I stub the price_all method on the Project class?
I've tried stub(:price_all).with(anything())
and stub(:price_all).with(any_args())
, but it doesn't change the failure message.
Here's the full failure:
1) GS Options page shows the page
Failure/Error: visit edit_gs_option_path(gso)
NoMethodError:
undefined method `id' for nil:NilClass
# ./app/models/collector.rb:435:in `price_item'
# ./app/models/gs_collector.rb:279:in `price_out'
# ./app/models/collector.rb:260:in `price_out_all'
# ./app/models/project.rb:430:in `price_all'
# ./app/controllers/application_controller.rb:187:in `get_totals'
# ./app/controllers/gs_options_controller.rb:6:in `edit'
# ./spec/features/gs_options_spec.rb:10:in `block (2 levels) in <top (required)>'
Upvotes: 0
Views: 1049
Reputation: 4595
This stubbing feature started working when I upgraded to rspec-rails 3.0.0.beta.
Upvotes: 1