【发布时间】:2017-10-27 04:23:28
【问题描述】:
我的 routes.rb 中有一条这样定义的路线
scope ':prefix', as: :foo, controller: 'foo_paths', action: :placeholder do
get 'foo/:id', as: 'result'
end
问题是运行我的测试时它总是返回
Failure/Error: subject { get :placeholder }
ActionController::UrlGenerationError:
No route matches {:action=>"placeholder", :controller=>"foo_paths"}
这是我的所有代码,我找不到任何错误,在浏览器中一切正常,并且 rake 路由返回预期的路由。
foo_paths_controller.rb
class FooPathsController < ApplicationController
def placeholder
render nothing: true, status: :service_unavailable
end
end
foo_paths_controller_spec.rb
describe FooPathsController, type: :controller do
describe "GET 'placeholder'" do
subject { get :placeholder }
it 'renders an empty page with service unavailable http error' do
subject
it { expect(subject).to have_http_status(503) }
it { expect(subject.body).to be_blank }
end
end
end
耙路
foo_result GET /:prefix/foo/:id(.:format) foo_paths#placeholder
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 rspec