ruby on rails - How to stub using any_instance in Rspec feature spec with Capybara? -
i have following in feature spec:
it "shows page" 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, fails because price_all method on project not being stubbed. failure trace contains following:
# ./app/models/project.rb:430:in `price_all'
how stub price_all method on project class?
i've tried stub(:price_all).with(anything())
, stub(:price_all).with(any_args())
, doesn't change failure message.
here's full failure:
1) gs options page shows page failure/error: visit edit_gs_option_path(gso) nomethoderror: undefined method `id' 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)>'
this stubbing feature started working when upgraded rspec-rails 3.0.0.beta.
Comments
Post a Comment