-
Notifications
You must be signed in to change notification settings - Fork 386
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
Test helpers do not work in Rails 5 #775
Comments
Hi @5t111111 If your rest is an integration test, you should not include |
@arnvald I'm sorry for asking you with a wrong snippet. However, even after removing I think the cause of the problem is that
I'm going to give it further investigation, but it'll take a while because actually I don't write any controller tests ATM... Anyway, thank you for the answer out of your busy schedule. |
Im having a similar issue. include Sorcery::TestHelpers::Rails::Integration produces "NameError: undefined local variable or method `sessions_url' for" include Sorcery::TestHelpers::Rails::Controller produces "NoMethodError: undefined method `auto_login' for nil:NilClass" I'm still digging into this and will report back if I find solution |
It seems the integration test helpers only work with Rack::Tests. Neither it works for Rails integration tests nor Capybara feature tests. |
Today I got the same problem.
|
Workaround: Change your controller tests to inherit from That being said, you will also need to convert your tests back to the previous syntax. To move forward, not sure what it takes to update the code though. |
Alternative: in def authenticate_user(user = users(:admin))
post sessions_url, params: {
session: { email: user.email, password: "123123" } }
assert_redirected_to workflows_path
assert_equal session[:user_id].to_i, user.id
end Then, leverage the helper In your controller. Rails 5 discourages from setting the session in controller tests |
I ran into this on updating an app from Rails 4 to Rails 5. Here's how I got through it:
Then update your
|
In Rails 5, generated controller tests now inherit from
ActionDispatch::IntegrationTest
, so the helpers likelogin_user
don't seem to work.e.g.) the following does not work (think if
index
requires login):Are there any idea or plan for using the test helpers in Rails 5 controller testing?
FYI: Devise seems to be going to implement a test helper for integration tests. heartcombo/devise#3913
The text was updated successfully, but these errors were encountered: