6

在我开始尝试使用 Capybara-Webkit 与依赖于 Javascript 的界面元素进行交互之前,我的 Rspec + Capybara 集成测试运行良好。

当我尝试使用 Capybara-Webkit 时,我在save_and_open_line下面得到空白页。为什么?

/spec/features/area_spec.rb

require 'spec_helper'
describe "Area" do
  ...
  describe "Admin" do
    ...  
    before(:each) do
      Capybara.current_driver = :webkit
      @virginia = User.create(
        :username => "Virginia", 
        :password => "password", 
        :password_confirmation => "password", 
        :email => "example@example.com")
      @admin = Role.create(:name => "admin")    
      @assignment = Assignment.create(user_id: @virginia.id, role_id: @admin.id)
      visit login_path
      fill_in 'user_session_username', :with => @virginia.username
      fill_in 'user_session_password', :with => @virginia.password
      click_on 'submit_user_session'
      visit report_path(@report)
      save_and_open_page
      page.find('#nav_reports').trigger(:mouseover)
      ...
    end
    ...
  end
  ...
end

/spec/spec_helper.rb

require 'rubygems'
require 'spork'
require 'database_cleaner'
Spork.prefork do
end
Spork.each_run do
end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'capybara/rails' 
require 'capybara/dsl' 
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
  config.mock_with :rspec
  config.fail_fast = true
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.before(:each) { ActionMailer::Base.deliveries.clear }
  config.use_instantiated_fixtures = false 
  config.include(Capybara, :type => :integration)
  Capybara.javascript_driver = :webkit
  config.use_transactional_fixtures = false
  config.before(:suite) do
    DatabaseCleaner.clean_with :truncation
  end
  config.before(:each) do
    if example.metadata[:js]
      DatabaseCleaner.strategy = :truncation
    else
      DatabaseCleaner.strategy = :transaction
    end
    DatabaseCleaner.start
  end
  config.after(:each) do
    DatabaseCleaner.clean
  end
end

当我从中删除Capybara.current_driver = :webkitarea_spec.rb但将 Webkit 相关代码保留在 中spec_helper.rb)时,生成的页面save_and_open_page不为空,但在 Rspec 命令行中出现以下错误:

Failure/Error: page.find('#nav_reports').trigger(:mouseover)
     Capybara::NotSupportedByDriverError:
       Capybara::NotSupportedByDriverError

最初我尝试添加:js => :true到 before block ... do,但 Rspec 一直拒绝我的语法。当我添加:js => trueit ... do block要被before ... do块覆盖的第一个时,我仍然在 处得到一个空白页save_and_open_page,但是 Rspec 命令行中的错误更改为:

Failure/Error: page.find('#nav_reports').trigger(:mouseover)
     Capybara::Webkit::NodeNotAttachedError:
       Capybara::Webkit::NodeNotAttachedError

当我在文件Capybara.javascript_driver = :webkit中向上移动一个级别时,我得到了同样的错误。spec_helper.rbRspec.configure do

当我从before ... do块中剪切每一行并将其粘贴到it ... do block要覆盖的第一行时,我得到了同样的错误。

当我设置config.use_transactional_fixtures = true和删除所有与 Webkit 相关的代码时,规范工作,当然 for 除外page.find('#nav_reports').trigger(:mouseover),它需要一个 Javascript 驱动程序。

更新:我page.current_path.should == report_path(@report)在之前插入save_and_open_page并发现有关 Capybara-Webkit 的某些东西正在阻止我visit report_path(@report)的工作。(当我不尝试使用 Capybara-Webkit 测试依赖于 Javascript 的界面元素时,它工作正常。)错误代码是:

 Failure/Error: page.current_path.should == report_path(@report)
       expected: "/reports/3"
            got: nil (using ==) 

进一步更新:我发现当我使用 Capybara-Webkit 时,Rspec 很难找到@report对象,即使我将我的@report = Report.create(...)语句直接移动到访问之前的行report_path(@report)。完整的测试日志如下:

 Marker - 19/12/2012 11:55:45 AM
Connecting to database specified by database.yml
  [1m[36m (2.1ms)[0m  [1mALTER TABLE "references" DISABLE TRIGGER ALL;ALTER TABLE "values" DISABLE TRIGGER ALL;ALTER TABLE "variants" DISABLE TRIGGER ALL;ALTER TABLE "veracities" DISABLE TRIGGER ALL;ALTER TABLE "goods" DISABLE TRIGGER ALL;ALTER TABLE "orders" DISABLE TRIGGER ALL;ALTER TABLE "reports" DISABLE TRIGGER ALL;ALTER TABLE "roles" DISABLE TRIGGER ALL;ALTER TABLE "users" DISABLE TRIGGER ALL;ALTER TABLE "areas" DISABLE TRIGGER ALL;ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "ijoins" DISABLE TRIGGER ALL;ALTER TABLE "fields" DISABLE TRIGGER ALL;ALTER TABLE "footnotes" DISABLE TRIGGER ALL;ALTER TABLE "gjoins" DISABLE TRIGGER ALL;ALTER TABLE "heuristics" DISABLE TRIGGER ALL;ALTER TABLE "assignments" DISABLE TRIGGER ALL;ALTER TABLE "categories" DISABLE TRIGGER ALL;ALTER TABLE "industries" DISABLE TRIGGER ALL;ALTER TABLE "markets" DISABLE TRIGGER ALL;ALTER TABLE "mjoins" DISABLE TRIGGER ALL[0m
  [1m[35m (2.0ms)[0m  select table_name from information_schema.views where table_schema = 'db/testivate_test'
  [1m[36m (82.3ms)[0m  [1mTRUNCATE TABLE "references", "values", "variants", "veracities", "goods", "orders", "reports", "roles", "users", "areas", "ijoins", "fields", "footnotes", "gjoins", "heuristics", "assignments", "categories", "industries", "markets", "mjoins" RESTART IDENTITY CASCADE;[0m
  [1m[35m (1.7ms)[0m  ALTER TABLE "references" ENABLE TRIGGER ALL;ALTER TABLE "variants" ENABLE TRIGGER ALL;ALTER TABLE "veracities" ENABLE TRIGGER ALL;ALTER TABLE "goods" ENABLE TRIGGER ALL;ALTER TABLE "values" ENABLE TRIGGER ALL;ALTER TABLE "orders" ENABLE TRIGGER ALL;ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "reports" ENABLE TRIGGER ALL;ALTER TABLE "roles" ENABLE TRIGGER ALL;ALTER TABLE "users" ENABLE TRIGGER ALL;ALTER TABLE "areas" ENABLE TRIGGER ALL;ALTER TABLE "ijoins" ENABLE TRIGGER ALL;ALTER TABLE "fields" ENABLE TRIGGER ALL;ALTER TABLE "footnotes" ENABLE TRIGGER ALL;ALTER TABLE "gjoins" ENABLE TRIGGER ALL;ALTER TABLE "heuristics" ENABLE TRIGGER ALL;ALTER TABLE "categories" ENABLE TRIGGER ALL;ALTER TABLE "industries" ENABLE TRIGGER ALL;ALTER TABLE "markets" ENABLE TRIGGER ALL;ALTER TABLE "mjoins" ENABLE TRIGGER ALL;ALTER TABLE "assignments" ENABLE TRIGGER ALL
  [1m[36m (0.2ms)[0m  [1mBEGIN[0m
  [1m[35mUser Exists (0.7ms)[0m  SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('example@example.com') LIMIT 1
  [1m[36mUser Exists (0.3ms)[0m  [1mSELECT 1 AS one FROM "users" WHERE LOWER("users"."username") = LOWER('Virginia') LIMIT 1[0m
  [1m[35mUser Exists (0.3ms)[0m  SELECT 1 AS one FROM "users" WHERE "users"."persistence_token" = 'f0a9f99733b2d60d466811c27c5b0375019959e894845e6baced63af874c93cada0b6f8dd1e94e3cb99447c8bfddbbc22ed991ac6b7924f80a84649689fb25c7' LIMIT 1
  [1m[36mSQL (47.5ms)[0m  [1mINSERT INTO "users" ("created_at", "crypted_password", "email", "password_salt", "persistence_token", "updated_at", "username") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"[0m  [["created_at", Wed, 19 Dec 2012 00:56:22 UTC +00:00], ["crypted_password", "28f6bd928c62aab1dac4eb58c3ab3d8c09bb0ff762218bedfbf4457b234a0140cc4c7e01594fe6d9c0c5fc6acb283befc1eae12c21930187ba09547a413205fb"], ["email", "example@example.com"], ["password_salt", "BWr1wBmASo58D6d2j0aD"], ["persistence_token", "f0a9f99733b2d60d466811c27c5b0375019959e894845e6baced63af874c93cada0b6f8dd1e94e3cb99447c8bfddbbc22ed991ac6b7924f80a84649689fb25c7"], ["updated_at", Wed, 19 Dec 2012 00:56:22 UTC +00:00], ["username", "Virginia"]]
  [1m[35m (0.5ms)[0m  COMMIT
  [1m[36m (0.1ms)[0m  [1mBEGIN[0m
  [1m[35mSQL (1.3ms)[0m  INSERT INTO "roles" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id"  [["created_at", Wed, 19 Dec 2012 00:56:23 UTC +00:00], ["name", "admin"], ["updated_at", Wed, 19 Dec 2012 00:56:23 UTC +00:00]]
  [1m[36m (0.5ms)[0m  [1mCOMMIT[0m
  [1m[35m (0.1ms)[0m  BEGIN
  [1m[36mSQL (1.3ms)[0m  [1mINSERT INTO "assignments" ("created_at", "role_id", "updated_at", "user_id") VALUES ($1, $2, $3, $4) RETURNING "id"[0m  [["created_at", Wed, 19 Dec 2012 00:56:23 UTC +00:00], ["role_id", 1], ["updated_at", Wed, 19 Dec 2012 00:56:23 UTC +00:00], ["user_id", 1]]
  [1m[35m (0.5ms)[0m  COMMIT
Started GET "/login" for 127.0.0.1 at 2012-12-19 11:56:29 +1100
Processing by UserSessionsController#new as HTML
  Rendered user_sessions/new.html.haml within layouts/application (30.1ms)
  Rendered shared/_subscribe.html.haml (15.6ms)
  Rendered shared/_share.html.haml (6.1ms)
  Rendered shared/_contact.html.haml (10.2ms)
Completed 200 OK in 420ms (Views: 319.1ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css" for 127.0.0.1 at 2012-12-19 11:56:30 +1100
Served asset /application.css - 200 OK (269ms)
Started GET "/assets/application.js" for 127.0.0.1 at 2012-12-19 11:56:31 +1100
Served asset /application.js - 200 OK (1611ms)
Started GET "/assets/subtle_dots3.png" for 127.0.0.1 at 2012-12-19 11:56:33 +1100
Served asset /subtle_dots3.png - 200 OK (75ms)
Started GET "/assets/background.png" for 127.0.0.1 at 2012-12-19 11:56:33 +1100
Served asset /background.png - 200 OK (56ms)
Started GET "/assets/logo3.png" for 127.0.0.1 at 2012-12-19 11:56:33 +1100
Served asset /logo3.png - 200 OK (24ms)
  [1m[36m (0.1ms)[0m  [1mBEGIN[0m
Started POST "/user_sessions" for 127.0.0.1 at 2012-12-19 11:56:35 +1100
Processing by UserSessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "user_session"=>{"username"=>"Virginia", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Login"}
  [1m[35mSQL (118.9ms)[0m  INSERT INTO "reports" ("created_at", "name", "short_name", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["created_at", Wed, 19 Dec 2012 00:56:35 UTC +00:00], ["name", "The Testivate Retail Site Search Benchmark"], ["short_name", "Search"], ["updated_at", Wed, 19 Dec 2012 00:56:35 UTC +00:00]]
  [1m[36m (32.8ms)[0m  [1mCOMMIT[0m
  [1m[35mUser Load (1.3ms)[0m  SELECT "users".* FROM "users" WHERE (LOWER("users".username) = 'virginia') LIMIT 1
Redirected to http://127.0.0.1:61073/
Completed 302 Found in 348ms (ActiveRecord: 7.3ms)
Started GET "/" for 127.0.0.1 at 2012-12-19 11:56:36 +1100
Processing by HighVoltage::PagesController#show as HTML
  Parameters: {"id"=>"home"}
  [1m[36mUser Load (0.6ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1[0m
  Rendered pages/home.html.haml within layouts/application (152.8ms)
  Rendered shared/_subscribe.html.haml (0.2ms)
  Rendered shared/_share.html.haml (0.2ms)
  Rendered shared/_contact.html.haml (0.3ms)
Completed 200 OK in 256ms (Views: 213.1ms | ActiveRecord: 0.6ms)
Started GET "/assets/steven_portrait.jpg" for 127.0.0.1 at 2012-12-19 11:56:36 +1100
Served asset /steven_portrait.jpg - 200 OK (18ms)
Started GET "/assets/stack-of-papers3.png" for 127.0.0.1 at 2012-12-19 11:56:36 +1100
Served asset /stack-of-papers3.png - 200 OK (10ms)
Started GET "/assets/guarantee.png" for 127.0.0.1 at 2012-12-19 11:56:36 +1100
Served asset /guarantee.png - 200 OK (3ms)
Started GET "/assets/sample-chart.png" for 127.0.0.1 at 2012-12-19 11:56:36 +1100
Served asset /sample-chart.png - 200 OK (3ms)
Started GET "/reports/1" for 127.0.0.1 at 2012-12-19 11:56:39 +1100
Processing by ReportsController#show as HTML
  Parameters: {"id"=>"1"}
  [1m[35mUser Load (0.5ms)[0m  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  [1m[36mReport Load (0.9ms)[0m  [1mSELECT "reports".* FROM "reports" WHERE "reports"."id" = $1 LIMIT 1[0m  [["id", "1"]]
  [1m[35mRole Load (0.7ms)[0m  SELECT "roles".* FROM "roles" INNER JOIN "assignments" ON "roles"."id" = "assignments"."role_id" WHERE "assignments"."user_id" = 1
  [1m[36mCACHE (0.0ms)[0m  [1mSELECT "reports".* FROM "reports" WHERE "reports"."id" = $1 LIMIT 1[0m  [["id", "1"]]
  [1m[35mArea Load (0.3ms)[0m  SELECT "areas".* FROM "areas" 
  [1m[36mCategory Load (0.4ms)[0m  [1mSELECT "categories".* FROM "categories" [0m
  [1m[35mHeuristic Load (0.4ms)[0m  SELECT "heuristics".* FROM "heuristics" WHERE "heuristics"."report_id" = 1
  Rendered reports/show.html.haml within layouts/wide (34.9ms)
Completed 200 OK in 499ms (Views: 161.8ms | ActiveRecord: 16.1ms)
Started GET "/images/shadow.png" for 127.0.0.1 at 2012-12-19 11:56:39 +1100
Started GET "/reports/1" for 127.0.0.1 at 2012-12-19 11:56:39 +1100
Processing by ReportsController#show as HTML
  Parameters: {"id"=>"1"}
  [1m[36m (2.7ms)[0m  [1mALTER TABLE "references" DISABLE TRIGGER ALL;ALTER TABLE "variants" DISABLE TRIGGER ALL;ALTER TABLE "veracities" DISABLE TRIGGER ALL;ALTER TABLE "goods" DISABLE TRIGGER ALL;ALTER TABLE "values" DISABLE TRIGGER ALL;ALTER TABLE "orders" DISABLE TRIGGER ALL;ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "reports" DISABLE TRIGGER ALL;ALTER TABLE "roles" DISABLE TRIGGER ALL;ALTER TABLE "users" DISABLE TRIGGER ALL;ALTER TABLE "areas" DISABLE TRIGGER ALL;ALTER TABLE "ijoins" DISABLE TRIGGER ALL;ALTER TABLE "fields" DISABLE TRIGGER ALL;ALTER TABLE "footnotes" DISABLE TRIGGER ALL;ALTER TABLE "gjoins" DISABLE TRIGGER ALL;ALTER TABLE "heuristics" DISABLE TRIGGER ALL;ALTER TABLE "categories" DISABLE TRIGGER ALL;ALTER TABLE "industries" DISABLE TRIGGER ALL;ALTER TABLE "markets" DISABLE TRIGGER ALL;ALTER TABLE "mjoins" DISABLE TRIGGER ALL;ALTER TABLE "assignments" DISABLE TRIGGER ALL[0m
  [1m[35mUser Load (0.8ms)[0m  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  [1m[36m (39.7ms)[0m  [1mTRUNCATE TABLE "references", "values", "variants", "veracities", "goods", "orders", "reports", "roles", "users", "areas", "ijoins", "fields", "footnotes", "gjoins", "heuristics", "assignments", "categories", "industries", "markets", "mjoins" RESTART IDENTITY CASCADE;[0m
  [1m[35mReport Load (37.2ms)[0m  SELECT "reports".* FROM "reports" WHERE "reports"."id" = $1 LIMIT 1  [["id", "1"]]
Completed 404 Not Found in 46ms

ActiveRecord::RecordNotFound - Couldn't find Report with id=1:
  (gem) activerecord-3.2.9/lib/active_record/relation/finder_methods.rb:341:in `find_one'
  (gem) activerecord-3.2.9/lib/active_record/relation/finder_methods.rb:312:in `find_with_ids'
  (gem) activerecord-3.2.9/lib/active_record/relation/finder_methods.rb:107:in `find'
  (gem) activerecord-3.2.9/lib/active_record/querying.rb:5:in `find'
  (gem) declarative_authorization-0.5.6/lib/declarative_authorization/in_controller.rb:143:in `load_controller_object'
  (gem) declarative_authorization-0.5.6/lib/declarative_authorization/in_controller.rb:527:in `block in filter_resource_access'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:440:in `_run__1180530030885761146__process_action__691010259609085274__callbacks'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
  (gem) actionpack-3.2.9/lib/abstract_controller/callbacks.rb:17:in `process_action'
  (gem) actionpack-3.2.9/lib/action_controller/metal/rescue.rb:29:in `process_action'
  (gem) actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  (gem) activesupport-3.2.9/lib/active_support/notifications.rb:123:in `block in instrument'
  (gem) activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  (gem) activesupport-3.2.9/lib/active_support/notifications.rb:123:in `instrument'
  (gem) actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  (gem) actionpack-3.2.9/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  (gem) activerecord-3.2.9/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  (gem) actionpack-3.2.9/lib/abstract_controller/base.rb:121:in `process'
  (gem) actionpack-3.2.9/lib/abstract_controller/rendering.rb:45:in `process'
  (gem) actionpack-3.2.9/lib/action_controller/metal.rb:203:in `dispatch'
  (gem) actionpack-3.2.9/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  (gem) actionpack-3.2.9/lib/action_controller/metal.rb:246:in `block in action'
  (gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  (gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:36:in `call'
  (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  (gem) journey-1.0.4/lib/journey/router.rb:56:in `each'
  (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in `call'
  (gem) better_errors-0.2.0/lib/better_errors/middleware.rb:23:in `app_call'
  (gem) better_errors-0.2.0/lib/better_errors/middleware.rb:17:in `call'
  (gem) sass-3.2.3/lib/sass/plugin/rack.rb:54:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  (gem) rack-1.4.1/lib/rack/etag.rb:23:in `call'
  (gem) rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/head.rb:14:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/flash.rb:242:in `call'
  (gem) rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
  (gem) rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/cookies.rb:341:in `call'
  (gem) activerecord-3.2.9/lib/active_record/query_cache.rb:64:in `call'
  (gem) activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `_run__3970772839722169598__call__3997376486539605674__callbacks'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  (gem) activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  (gem) railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app'
  (gem) railties-3.2.9/lib/rails/rack/logger.rb:16:in `block in call'
  (gem) activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged'
  (gem) railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  (gem) rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
  (gem) rack-1.4.1/lib/rack/runtime.rb:17:in `call'
  (gem) activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  (gem) rack-1.4.1/lib/rack/lock.rb:15:in `call'
  (gem) actionpack-3.2.9/lib/action_dispatch/middleware/static.rb:62:in `call'
  (gem) railties-3.2.9/lib/rails/engine.rb:479:in `call'
  (gem) railties-3.2.9/lib/rails/application.rb:223:in `call'
  (gem) rack-1.4.1/lib/rack/builder.rb:134:in `call'
  (gem) rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
  (gem) rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
  (gem) rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
  (gem) capybara-2.0.1/lib/capybara/server.rb:19:in `call'
  (gem) rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
  /Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

  [1m[36m (1.7ms)[0m  [1mALTER TABLE "references" ENABLE TRIGGER ALL;ALTER TABLE "variants" ENABLE TRIGGER ALL;ALTER TABLE "veracities" ENABLE TRIGGER ALL;ALTER TABLE "goods" ENABLE TRIGGER ALL;ALTER TABLE "values" ENABLE TRIGGER ALL;ALTER TABLE "orders" ENABLE TRIGGER ALL;ALTER TABLE "reports" ENABLE TRIGGER ALL;ALTER TABLE "roles" ENABLE TRIGGER ALL;ALTER TABLE "users" ENABLE TRIGGER ALL;ALTER TABLE "areas" ENABLE TRIGGER ALL;ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "ijoins" ENABLE TRIGGER ALL;ALTER TABLE "fields" ENABLE TRIGGER ALL;ALTER TABLE "footnotes" ENABLE TRIGGER ALL;ALTER TABLE "gjoins" ENABLE TRIGGER ALL;ALTER TABLE "heuristics" ENABLE TRIGGER ALL;ALTER TABLE "assignments" ENABLE TRIGGER ALL;ALTER TABLE "categories" ENABLE TRIGGER ALL;ALTER TABLE "industries" ENABLE TRIGGER ALL;ALTER TABLE "markets" ENABLE TRIGGER ALL;ALTER TABLE "mjoins" ENABLE TRIGGER ALL[0m
4

4 回答 4

6

可能不是正确的答案,但以防万一其他人像我一样用谷歌搜索这个答案,寻找想法:

我忘记了visit网址前面的正斜杠。出于某种原因,默认机架驱动程序对此很好,但我的 JS 驱动程序不是(capybara-webkit 和 poltergeist)。

于 2014-04-08T14:20:32.823 回答
0

我有一个类似的问题,仍然试图找出确切的问题,但使用page.visit而不是只是visit似乎有帮助。

于 2013-03-29T13:28:07.653 回答
0

升级到capybara-webkit1.5.1 为我解决了这个问题。参见thoughtbot/capybara-webkit#724

于 2015-05-18T19:05:56.127 回答
0

我们正在使用 capybara-webkit 1.3.1,capybara 2.1.0

由于返回了 304 状态代码,我看到了这一点。我认为 Capybara Webkit 出于某种原因没有呈现页面(可能是由于非 2xx 代码)并且会返回一个空白页面。

一旦我将标头设置为不可缓存,那么这个问题在我们的情况下就消失了。

于 2015-07-15T17:45:16.080 回答