除了我用js =>添加的测试之外,我的测试都没有错误。真正。奇怪的是,如果没有路由错误,测试将通过。
我的测试:
context 'Javascript', :js => true do
visit careers_path
page.should have_content("Your Recommendations")
end
我可以实际puts page.body
并看到内容已存在,但它仍然会出现此路由错误。我注意到在运行实际服务器时,它为资产文件夹提出了GET
请求。我不明白为什么或这是做什么的,但它似乎是失败的原因。
错误:
运行rails s
Started GET "/assets/" for 127.0.0.1 at 2013-08-12 19:11:02 -0400
Served asset / - 404 Not Found (5ms)
运行rspec
Failure/Error: Unable to find matching line from backtrace
ActionController::RoutingError:
No route matches [GET] "/assets"
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:32:in `call_app'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:16:in `block in call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.14/lib/active_support/tagged_logging.rb:22:in `tagged'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:16:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/request_id.rb:22:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.14/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/static.rb:63:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/engine.rb:484:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/application.rb:231:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/capybara-2.1.0/lib/capybara/server.rb:19:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
在旁注中,将config.action_dispatch.show_exceptions = true
添加到config / environments / test.rb允许测试通过,它不能解释为什么会发生,它只是抑制警告