4

我第一次尝试 ActiveAdmin 并让它在浏览器中运行。但是,我无法使用 Capybara 登录进行集成测试。我已经尝试过填写表格方法以及存根登录。

例如

it "allows user via capybara login" do
  user = AdminUser.create(email: 'test@example.com', password: 'opensesame')
  visit '/admin/login'
  fill_in 'admin_user_email', with: user.email
  fill_in 'admin_user_password', with: user.password
  click_button 'Login'
end

给出错误消息(帖子末尾的完整跟踪)

ActionView::Template::Error: wrong number of arguments (0 for 1)
/home/mike/ptbase/spec/support/request_helpers.rb:11:in `login'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/view_helpers/display_helper.rb:14:in `display_name'

我尝试了Joe's Notes给出的存根方法

# spec/support/request_helpers.rb
require 'spec_helper'
include Warden::Test::Helpers

module RequestHelpers
  def create_logged_in_user
    user = FactoryGirl.create(:admin_user, password: 'opensesame')
    login(user)
    user
  end

  def login(user)
    login_as user, scope: :user
  end
end 

# spec/features/patient_features_spec.rb
require 'spec_helper'
include RequestHelpers

feature "Patients" do
  let(:authed_user) { create_logged_in_user }

  it "should allow access" do
    visit admin_dashboard_path(authed_user)
    save_and_open_page
    # should be good!
  end
end

但这会打开一个页面,上面写着“您需要先登录或注册才能继续。”

我正在使用 Rails 3.1.9、ActiveAdmin 0.5.0 和 Capybara 2.0.1。我确信必须有一个简单的方法来解决这个问题......显然登录是集成测试的基础......但我似乎找不到它!

上述错误的完整回溯:

ActionView::Template::Error: wrong number of arguments (0 for 1)
/home/mike/ptbase/spec/support/request_helpers.rb:11:in `login'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/view_helpers/display_helper.rb:14:in `display_name'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element.rb:175:in `method_missing'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/utility_nav.rb:21:in `build_current_user'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/utility_nav.rb:13:in `build'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/header.rb:26:in `build_utility_navigation'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/header.rb:13:in `build'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/pages/base.rb:49:in `build_header'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/pages/base.rb:40:in `block (2 levels) in build_page'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:18:in `div'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/pages/base.rb:39:in `block in build_page'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/pages/base.rb:38:in `build_page'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/views/pages/base.rb:10:in `build'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/app/views/active_admin/page/index.html.arb:1:in `block in __home_mike__rvm_gems_ruby_______p____perf_gems_activeadmin_______app_views_active_admin_page_index_html_arb___526514329_111865000'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:45:in `instance_eval'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/arbre-1.0.1/lib/arbre/context.rb:45:in `initialize'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/app/views/active_admin/page/index.html.arb:1:in `new'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/app/views/active_admin/page/index.html.arb:1:in `__home_mike__rvm_gems_ruby_______p____perf_gems_activeadmin_______app_views_active_admin_page_index_html_arb___526514329_111865000'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/template.rb:145:in `block in render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications.rb:125:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/template.rb:143:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:in `block in instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/template_renderer.rb:18:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_view/renderer/renderer.rb:17:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/rendering.rb:110:in `_render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/rendering.rb:88:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/rendering.rb:16:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/mike/.rvm/rubies/ruby-1.9.3-p194-perf/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-3.2.9/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:39:in `render'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activeadmin-0.5.0/lib/active_admin/page_controller.rb:12:in `index'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/base.rb:167:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:447:in `_run__1002248294__process_action__401562286__callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:in `block in instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:in `instrument'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-3.2.9/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/base.rb:121:in `process'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/abstract_controller/rendering.rb:45:in `process'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal.rb:203:in `dispatch'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_controller/metal.rb:246:in `block in action'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/head.rb:14:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/flash.rb:242:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-3.2.9/lib/active_record/query_cache.rb:64:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `_run__955233195__call__489842762__callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `block in call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/actionpack-3.2.9/lib/action_dispatch/middleware/static.rb:62:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.9/lib/rails/engine.rb:479:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.9/lib/rails/application.rb:223:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-test-0.6.2/lib/rack/mock_session.rb:30:in `request'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-test-0.6.2/lib/rack/test.rb:230:in `process_request'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rack-test-0.6.2/lib/rack/test.rb:57:in `get'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/browser.rb:59:in `process'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/browser.rb:38:in `block in process_and_follow_redirects'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/browser.rb:37:in `times'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/browser.rb:37:in `process_and_follow_redirects'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/browser.rb:26:in `submit'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/form.rb:64:in `submit'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/rack_test/node.rb:72:in `click'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/node/element.rb:103:in `block in click'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/node/base.rb:77:in `synchronize'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/node/element.rb:103:in `click'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/node/actions.rb:35:in `click_button'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/session.rb:338:in `block (2 levels) in <class:Session>'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/capybara-2.0.1/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
/home/mike/ptbase/spec/features/patients_features_spec.rb:19:in `block (2 levels) in <top (required)>'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:114:in `instance_eval'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:114:in `block in run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:254:in `with_around_each_hooks'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:111:in `run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:388:in `block in run_examples'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:384:in `map'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:384:in `run_examples'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:369:in `run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `map'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `block in run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/reporter.rb:34:in `report'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:25:in `run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:66:in `rescue in run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:62:in `run'
/home/mike/.rvm/gems/ruby-1.9.3-p194-perf/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:8:in `block in autorun'
4

1 回答 1

-1

几天前我遇到了这个问题,通过更改我的 spec_helper 文件中的设置来解决它,另外你可能还需要更新 selinium 和 capybara 版本

Capybara.default_driver = :rack_test
Capybara.javascript_driver = :selenium
# You can also change the driver temporarily (typically in the Before/setup and After/teardown blocks):
# Use: Capybara.current_driver = :webkit # temporarily select different driver
# or use :js => true for specific test and it should use selenium by default.
# Or:
# Also see https://github.com/jnicklas/capybara#drivers
Capybara.default_wait_time = 5
Capybara.run_server = true #Whether start server when testing
Capybara.default_selector = :css #default selector , you can change to :css
OmniAuth.config.test_mode = true
于 2012-12-03T18:39:20.397 回答