2015-10-26 86 views
0

我试图让水豚设置,但只要我访问任何页面时,它抛出这个错误故障使用RSpec 3.3配置水豚和Rails 3.2

Failure/Error: visit root_url 
NoMethodError: 
    Could not render layout: undefined method `[]' for nil:NilClass 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/layouts.rb:408:in `rescue in _default_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/layouts.rb:405:in `_default_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/layouts.rb:383:in `block in _layout_for_option' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:86:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:86:in `resolve_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:69:in `block in find_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/lookup_context.rb:228:in `with_layout_format' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:3:in `with_layout_format' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:69:in `find_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:53:in `render_with_layout' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:45:in `render_template' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:18:in `render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:36:in `render_template' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:17:in `render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:110:in `_render_template' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/streaming.rb:225:in `_render_template' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:103:in `render_to_body' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/renderers.rb:28:in `render_to_body' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/compatibility.rb:50:in `render_to_body' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:88:in `render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:16:in `render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/core_ext/benchmark.rb:5:in `block in ms' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/core_ext/benchmark.rb:5:in `ms' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:40:in `block in render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/searchkick-0.8.7/lib/searchkick/logging.rb:112:in `cleanup_view_runtime' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:39:in `render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:10:in `default_render' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:5:in `send_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:458:in `_run__2579600683761487977__process_action__3403611544666025924__callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/searchkick-0.8.7/lib/searchkick/logging.rb:107:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/journey-1.0.4/lib/journey/router.rb:56:in `each' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/journey-1.0.4/lib/journey/router.rb:56:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/etag.rb:23:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/conditionalget.rb:25:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:210:in `context' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:205:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__1697078018072327880__call__1713325954849929917__callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/request_store-1.1.0/lib/request_store/middleware.rb:8:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/methodoverride.rb:21:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/runtime.rb:17:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/lock.rb:15:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/railties-3.2.13/lib/rails/application.rb:223:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/builder.rb:134:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/urlmap.rb:64:in `block in call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/urlmap.rb:49:in `each' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.4.7/lib/rack/urlmap.rb:49:in `call' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/rack-test-0.6.3/lib/rack/test.rb:58:in `get' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/browser.rb:60:in `process' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/browser.rb:38:in `block in process_and_follow_redirects' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/browser.rb:37:in `times' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/browser.rb:37:in `process_and_follow_redirects' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/browser.rb:21:in `visit' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/rack_test/driver.rb:42:in `visit' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/session.rb:227:in `visit' 
# /home/nick/.rvm/gems/ruby-2.0.0-p598/gems/capybara-2.4.4/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>' 
# ./spec/requests/customers_spec.rb:5:in `block (2 levels) in <top (required)>' 

我试图改变一些基本配置的东西,并试图剥离几乎所有的东西都看不到,但它不会改变错误,并且我已经没有了解如何排除故障的想法。

+0

看起来像你没有该行动的布局文件 –

+0

谢谢@TomWalpole,指出我在正确的方向! –

回答

0

所以发生的是我检查我的应用程序控制器中的用户代理,告诉应用程序使用桌面或移动布局。但是,默认情况下,水豚不会通过任何用户代理,所以我只需在visit调用之前添加page.driver.browser.header('User-Agent', 'Some user agent')即可。