You're including Devise::TestHelpers
.
You should create specific test_helper
for tests, that really need Devise.
Same question on stackoverflow.
Question
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 ["to@example.org"], mail.to
assert_equal ["from@example.com"], 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
You're including Devise::TestHelpers
.
You should create specific test_helper
for tests, that really need Devise.
Same question on stackoverflow.