I have created a new project using rails 6 and I can't test many controllers with rspec 3.8 or 3.9.0.pre, for example this test:
it 'OK' do
get :index
expect(response).to be_ok
end
raises
Failure/Error: render template: 'rig_masters/index'
ActionView::Template::Error:
wrong number of arguments (given 2, expected 1)
if I have a controller that renders json it passes, for example if the controller is
def index
@components = Component.recent
render json: @components
end
test passes
but if I try to render a view like
def index
@components = Component.recent
end
or even
def index
@components = Component.recent
render template: 'components/index'
end
raises the ActionView::Template::Error: wrong number of arguments (given 2, expected 1)
error
Any help to make these tests pass would be greatly appreciated.
RSpec isn't compatible with Rails 6 yet. However, you can use rspec-rails 4.0.0.beta2, which will fix this particular issue!
Link: https://github.com/rspec/rspec-rails/issues/2155
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With