Ruby on rails rspec表示没有匹配的路由,但路由在浏览器中工作

Ruby on rails rspec表示没有匹配的路由,但路由在浏览器中工作,ruby-on-rails,Ruby On Rails,问题很简单,我不知道哪里可能出了问题 我有这个规格: it "/fr/admin/articles/new" do expect(:get => "/fr/admin/articles/new").to route_to(:controller => 'articles', :action => 'new') end 当我浏览localhost:3000/fr/admin/articles/new时,它可以工作 但我的测试表明: Failure/Error: expect

问题很简单,我不知道哪里可能出了问题

我有这个规格:

it "/fr/admin/articles/new" do
  expect(:get => "/fr/admin/articles/new").to route_to(:controller => 'articles', :action => 'new')
end
当我浏览localhost:3000/fr/admin/articles/new时,它可以工作

但我的测试表明:

Failure/Error: expect(:get => "/fr/admin/articles/new").to route_to(:controller => 'articles', :action => 'new')
   No route matches "/fr/admin/articles/new"
   # ./spec/routing/articles_routing_spec.rb:6:in `block (2 levels) in <top (required)>'
还有我的语言环境_constraint.rb

class LocaleConstraint
  def self.matches?(request)
    /(fr|zh)/.match(request.path_parameters[:locale])
  end
end
rake路由的输出:

    ckeditor        /ckeditor                                  Ckeditor::Engine
       admin        /admin(.:format)                           :controller#:action
       login GET    /login(.:format)                           sessions#new
      logout GET    /logout(.:format)                          sessions#destroy
    sessions POST   /sessions(.:format)                        sessions#create
        root        /:locale(.:format)                         static#home
        root        /:locale/admin(.:format)                   articles#index
    articles GET    /:locale/admin/articles(.:format)          articles#index
             POST   /:locale/admin/articles(.:format)          articles#create
 new_article GET    /:locale/admin/articles/new(.:format)      articles#new
edit_article GET    /:locale/admin/articles/:id/edit(.:format) articles#edit
     article GET    /:locale/admin/articles/:id(.:format)      articles#show
             PUT    /:locale/admin/articles/:id(.:format)      articles#update
             DELETE /:locale/admin/articles/:id(.:format)      articles#destroy
        root        /                                          :controller#:action

Routes for Ckeditor::Engine:
        pictures GET    /pictures(.:format)             ckeditor/pictures#index
                 POST   /pictures(.:format)             ckeditor/pictures#create
         picture DELETE /pictures/:id(.:format)         ckeditor/pictures#destroy
attachment_files GET    /attachment_files(.:format)     ckeditor/attachment_files#index
                 POST   /attachment_files(.:format)     ckeditor/attachment_files#create
 attachment_file DELETE /attachment_files/:id(.:format) ckeditor/attachment_files#destroy

显然,这是Rails中的一个bug,请参见:


请运行
rake routes
并将输出添加到问题中。
    ckeditor        /ckeditor                                  Ckeditor::Engine
       admin        /admin(.:format)                           :controller#:action
       login GET    /login(.:format)                           sessions#new
      logout GET    /logout(.:format)                          sessions#destroy
    sessions POST   /sessions(.:format)                        sessions#create
        root        /:locale(.:format)                         static#home
        root        /:locale/admin(.:format)                   articles#index
    articles GET    /:locale/admin/articles(.:format)          articles#index
             POST   /:locale/admin/articles(.:format)          articles#create
 new_article GET    /:locale/admin/articles/new(.:format)      articles#new
edit_article GET    /:locale/admin/articles/:id/edit(.:format) articles#edit
     article GET    /:locale/admin/articles/:id(.:format)      articles#show
             PUT    /:locale/admin/articles/:id(.:format)      articles#update
             DELETE /:locale/admin/articles/:id(.:format)      articles#destroy
        root        /                                          :controller#:action

Routes for Ckeditor::Engine:
        pictures GET    /pictures(.:format)             ckeditor/pictures#index
                 POST   /pictures(.:format)             ckeditor/pictures#create
         picture DELETE /pictures/:id(.:format)         ckeditor/pictures#destroy
attachment_files GET    /attachment_files(.:format)     ckeditor/attachment_files#index
                 POST   /attachment_files(.:format)     ckeditor/attachment_files#create
 attachment_file DELETE /attachment_files/:id(.:format) ckeditor/attachment_files#destroy