5

Exception encountered: #<SystemExit: exit>尝试通过 spork 运行黄瓜时出现错误。

功能/支持/env.rb:

require 'rubygems'
require 'spork'
require 'cucumber/rails'
require 'pickle/world'
require "capybara/poltergeist"

Spork.prefork do

  Capybara.javascript_driver = :poltergeist

end

Spork.each_run do
  ActionController::Base.allow_rescue = false

  begin
    DatabaseCleaner[:mongoid].strategy = :truncation
  rescue NameError
    raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
  end

  DatabaseCleaner[:mongoid].clean

  Cucumber::Rails::Database.javascript_strategy = :truncation

end

不带叉子跑:

vagrant@lucid32:/vagrant$ bundle exec cucumber
WARNING: No DRb server is running. Running features locally:
Rack::File headers parameter replaces cache_control after Rack 1.5.
Using the default profile...
Feature: Password recovery
  In order to retrieve lost password
  As a user of this site
  I want to reset it

  Scenario: Reset password   # features/users/password_recovery.feature:6
    Given I am not logged in # features/step_definitions/login_steps.rb:1
    And a user exists        # features/step_definitions/pickle_steps.rb:4

1 scenario (1 passed)
2 steps (2 passed)
0m0.504s

用 spork 运行:

vagrant@lucid32:/vagrant$ bundle exec cucumber
Disabling profiles...
Feature: Password recovery
  In order to retrieve lost password
  As a user of this site
  I want to reset it

  Scenario: Reset password   # features/users/password_recovery.feature:6
    Given I am not logged in # features/step_definitions/login_steps.rb:1
    And a user exists        # features/step_definitions/pickle_steps.rb:4

1 scenario (1 passed)
2 steps (2 passed)
0m0.495s
Exception encountered: #<SystemExit: exit>
backtrace:
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/cli/main.rb:54:in `exit'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/cli/main.rb:54:in `rescue in execute!'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/cli/main.rb:37:in `execute!'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/test_framework/cucumber.rb:24:in `run_tests'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/usr/local/rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'

如何解决?

4

2 回答 2

6

我也遇到过这种情况。不知道为什么,但我想这是因为我将 cucumber-rails 更新到了最新版本。切换回旧版本后,问题消失了

尝试将这些行放入您的 Gemfile

gem 'cucumber',  '1.2.5'
gem 'cucumber-rails', '1.3.0', :require => false 

然后bundle install

我希望这有帮助

于 2013-04-28T08:09:35.557 回答
2

我向 spork 提交了一个拉取请求来解决这个问题。

https://github.com/sporkrb/spork/pull/228

于 2013-05-29T19:07:54.933 回答