I am trying to run basic controller test.
My controller_spec.rb looks like:
class Test < ActionController::Base
def test_meth
puts 'hello for test meth'
head 200
end
end
describe Test do
it 'responds with 200' do
get :test_meth
expect(response.status).to eq(200)
end
end
When I run this spec I end up with an error
ActionController::UrlGenerationError: No route matches {:action=>"test_meth", :controller=>"test"}
I am not sure if I am missing something very basic here becasue this looks very straight forward. Any help is much appreciated.
The error is clear, in your
routes.rb
file you have not written the action correctly.You must have.
get "test", to: "test#test_meth"