Ruby on rails:测试成功的http状态时出现Rspec路由错误

时间:2018-04-01 18:36:03

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

所以我在rails应用程序的ruby中传递这些规范时遇到了麻烦:

Failures:

  1) WikisController GET show returns http success
     Failure/Error: get :show

     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"wikis"}
     # ./spec/controllers/wikis_controller_spec.rb:16:in `block (3 levels) in <top (required)>'

  2) WikisController GET edit returns http success
     Failure/Error: get :edit

     ActionController::UrlGenerationError:
       No route matches {:action=>"edit", :controller=>"wikis"}
     # ./spec/controllers/wikis_controller_spec.rb:23:in `block (3 levels) in <top (required)>'

当我运行这些规范时,我得到了这些错误:

                    root GET    /                              wikis#index
                   wikis GET    /wikis(.:format)               wikis#index
                         POST   /wikis(.:format)               wikis#create
                new_wiki GET    /wikis/new(.:format)           wikis#new
               edit_wiki GET    /wikis/:id/edit(.:format)      wikis#edit
                    wiki GET    /wikis/:id(.:format)           wikis#show
                         PATCH  /wikis/:id(.:format)           wikis#update
                         PUT    /wikis/:id(.:format)           wikis#update
                         DELETE /wikis/:id(.:format)           wikis#destroy
我感到困惑的原因是因为它们在浏览器中运行良好。此外,当我运行rake路线时,我得到了这个:

<dependencies>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>2.0.4</version>
        </dependency>

    </dependencies>

所以,这些错误对我来说没有意义,因为显然我确实拥有那些控制器的路径。有人能给我一些关于这里发生了什么的见解吗?

1 个答案:

答案 0 :(得分:0)

您的rspec包含idrake routes次行动,需要get :show, id: 1作为import json的结果。

尝试add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = '[su_spoiler title="Download The File" style="fancy" icon="chevron-circle"]Here[/su_spoiler]'; return $content; }