'NoMethodError: undefined method 'env' for nil:NilClass in ActionMailer::TestCase
I'm starting in ruby on rails and created a sample application. In this application I have a mail class and a test generated Mail class. I managed to get all tests working except the tests from ActionMailer::TestCase. Every time I run the tests I get an error message:
NoMethodError: undefined method 'env' for nil:NilClass.
My generated mailer test method looks like this:
test "new_project" do
mail = ProjectMailer.new_project
assert_equal "New project", mail.subject
assert_equal ["[email protected]"], mail.to
assert_equal ["[email protected]"], mail.from
assert_match "Hi", mail.body.encoded
end
I have in my test_helper
class ActionController::TestCase
include Devise::TestHelpers
end
class ActionMailer::TestCase
include Devise::TestHelpers
end
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
include Devise::TestHelpers
fixtures :all
end
Anyone does know how to solve that?
Solution 1:[1]
You're including Devise::TestHelpers.
You should create specific test_helper for tests, that really need Devise.
Same question on stackoverflow.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
