Capybara tests with :js=>true… Routing Error: No route matches [GET] “/assets”

前端 未结 4 2254
忘掉有多难
忘掉有多难 2020-12-08 02:14

I\'m getting a similar error in a number of tests when I add \":js => true\" to them. eg:

    An error occurred in an after hook
      ActionController::Rout         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 02:58

    In my case, I am getting

     Failure/Error: Unable to find matching line from backtrace
     ActionController::RoutingError:
       No route matches [GET] "/favicon.ico"
    

    I have already put an empty file favicon.ico under app/assets/images, so the development server is fine. But the test environment doesn't know how to handle the assets in this case. The workaround I found was to turn on static serving (instead of using a different server to serve static assets). The penalty of course is the performance.

      in environments/test.rb, set
      config.serve_static_assets = true # default is false
    

提交回复
热议问题