我正在尝试运行基本的控制器测试。
我的controller_spec.rb看起来像:
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
当我运行此规范时,我会遇到错误
ActionController::UrlGenerationError: No route matches {:action=>"test_meth", :controller=>"test"}
我不确定我是否会错过一些非常基本的内容,因为这看起来非常简单。非常感谢您的帮助。
错误很明显,在routes.rb
文件中,您没有正确编写操作。
您必须拥有。
get "test", to: "test#test_meth"