Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"assigns" in integration test not working #28

Open
mahemoff opened this issue Oct 7, 2016 · 6 comments
Open

"assigns" in integration test not working #28

mahemoff opened this issue Oct 7, 2016 · 6 comments

Comments

@mahemoff
Copy link

mahemoff commented Oct 7, 2016

This gem has restored assigns as expected for controller tests, but not for integration tests. e.g.:

UsersIntegrationTest <  ActionDispatch::IntegrationTest
  test "get user"  do
    assert_equal joe, assigns(:user)
    …
  end
end

yields

NoMethodError: assigns has been extracted to a gem. To continue using it,
    add `gem 'rails-controller-testing'` to your Gemfile.

I notice the integration test here doesn't include assigns, is it supported?

@rafaelfranca
Copy link
Member

It should not. Integrations tests are not supposed to have the assigns method since they are integration tests and integrations tests should not be asserting the state of the controller object. I'll remove that message from integration test.

@rafaelfranca
Copy link
Member

Closed by rails/rails@5dde413

@mahemoff
Copy link
Author

mahemoff commented Oct 8, 2016

I'm a little surprised tbh. I realise assigns was never the main point of integration tests, but it was still supported right up until Rails 5, so this represents a (minor, though undocumented) break in back-compatibility for the upgrade. If the purpose of rails-controller-testing is to help make a smooth transition to Rails 5, and ultimately assigns is deprecated in controller tests anyway, I'd think it was in scope for integration tests too.

(I had some tests using it because they were migrated from controller tests at some point. Maybe I'm an outlier.)

@rafaelfranca rafaelfranca reopened this Oct 21, 2016
@rafaelfranca
Copy link
Member

I just found that the integration tests add it. Could you create an example application that reproduce this issue?

It is being defined here https://github.com/rails/rails-controller-testing/blob/master/lib/rails/controller/testing.rb#L18

@mahemoff
Copy link
Author

Please see https://github.com/mahemoff/integration-assert.

assigns here fails for me with the above error.

@Xosmond
Copy link

Xosmond commented Dec 16, 2016

Same here, assign its not working, im getting nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants