Reputation: 24406
When I run this unit test:
require 'test_helper'
class MyControllerTest < ActionController::TestCase
test "my action works" do
get(:my_action, {'url' => "http://localhost:8090/"})
end
end
I get this error:
NoMethodError: undefined method 'request=' for #<MyController:0x5150896>
Any idea?
EDIT this action only has POST and not GET but I see the same results when I change to post in the unit test
Upvotes: 1
Views: 3730
Reputation: 697
There are basically two reasons:
It means you haven't required the controllers file. or
You have a typo in the name that is instantiating the a non controller for the @controller variable in the test.
Cross check at your test file, this will surly solve your problem.
Upvotes: 0
Reputation: 452
This will happen if you've forgotten to inherit from ApplicationController or some derivative thereof...
Upvotes: 10
Reputation: 663
I've seen this happen when the name of the controller in the test is misspelled. Are you sure that for this example the controller is named MyController?
Upvotes: 11