I tried to google but I find nowhere about this error for ActionView I am using Minitest (no Rspec)
custom_user_groups_helper_test.rb
class CustomUserGroupsHelperTest < ActionView::TestCase
test "should work custom user" do
response_params = gotta_get
end
end
custom_user_groups_helper.rb
module CustomUserGroupsHelper
def self.gotta_get
return true
end
This test_helper.rb
works fine with the controller test, but when I use it for helper test
it throws me this error
Error:
CustomUserGroupsHelperTest#test_should_work_custom_user:
NoMethodError: undefined method `env' for nil:NilClass
I tried another solution too
But this seems to be for the controller, none of the solutions is for the helper testing.
What to include
for ActionView::TestCase
from Devise
I tried to include these
include Devise::TestHelpers
include Devise::Test::IntegrationHelpers
include Devise::Test::ControllerHelpers
As one of the solutions on StackOverflow says
The Devise::TestHelpers should only be included for controller tests, so you need to move it to the ActionController::TestCase by adding this to your test helpers:
Then what to include for Helper test which inherits ActionView::TestCase
How to test helpers in the Minitest framework.
But i suppose include Devise::Test::IntegrationHelpers
and include Devise::Test::ControllerHelpers
are for controllers for different rails versions.
error
Updated error stack trace
stack trace for test run
CustomUserGroupsHelperTest: test_should_work_custom_user
--------------------------------------------------------
(0.1ms) ROLLBACK
E (0.1ms) BEGIN