I'm reasonably new to Rails and have just started working on a large project that needs updating from Rails 4.2 to Rails 5. I've never used RSpec much before, and I'm running into some failing tests while attempting the upgrade.
The code for the tests is:
describe "#index " do
it 'should return all plots associated to a purchaser' do
sign_in @user
get purchaser_plots_path(format: :json), params: {}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 2
_(json.first['id']).must_equal @plot_2.id
_(json.second['id']).must_equal @plot_1.id
end
it 'should paginate' do
sign_in @user
get purchaser_plots_path(format: :json), params: {page: 1, per_page: 1}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 1
_(json.first['id']).must_equal @plot_2.id
get purchaser_plots_path(format: :json), params: {page: 2, per_page: 1}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 1
_(json.first['id']).must_equal @plot_1.id
end
end
This is giving me the following error:
Error:
PurchaserPlotControllerTest::#index #test_0001_should return all plots associated to a purchaser:
ArgumentError: unknown keyword: flash
test/controllers/purchaser/plots_controller_test.rb:21:in `block (2 levels) in <class:PurchaserPlotControllerTest>'
All of the help I've found online seems to state that 'flash' is an allowed keyword argument, so I'm not sure what I'm doing wrong!
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire