在Rspec

时间:2015-09-08 08:09:48

标签: ruby-on-rails ruby rspec routes rails-routing

我有一个rails应用程序,我正在尝试测试路由文件。

如何在rspec中的routes.rb中测试此路由(minitest也会很棒):

'*unmatched_route', :to => 'application#raise_not_found!', :via => :all

1 个答案:

答案 0 :(得分:0)

根据Routing specs in RSpec,您应该可以写下这样的内容:

# in spec/routing/not_found.rb
describe 'not found' do
  it 'routes to application#raise_not_found' do
    expect(:get => "/an-unknown-route").to route_to(
      :controller => "application",
      :action     => "raise_not_found!"
    )
  end
end