从cli:切换到cmd时,Capybara功能测试失败:

时间:2014-02-21 00:42:12

标签: ruby-on-rails rspec capybara guard

相关信息

  • rails 4.0.3
  • capybara 2.2.1
  • guard-livereload 2.2.1
  • guard-rspec 4.2.6
  • guard-spork 1..5.1
  • guard-teaspoon 0.0.4
  • phantomjs 1.9.21
  • rspec-rails 2.14.4
  • spork-rails 4.0.0
  • 茶匙0.7.9

运行Guard时,我看到cli选项已被弃用。阅读后继者cmd,并按原样实施:

# Before
guard :rspec, after_all_pass: false, cli: '--drb' do
    ...
end

# After
guard :rspec, after_all_pass: false, cmd: 'bundle exec rspec --drb' do
     ...
end

在使用更改启动Guard后,除了Capybara支持的(功能)之外的所有测试都会失败。在终端中运行直接捆绑exec控制台会导致所有测试通过。恢复使用cli会导致所有测试通过。

任何想法可能是什么问题?

修改

以下是我在使用cmd: 'rspec --drb'时的一项测试中看到的输出。

00:21:38 - INFO - Running: spec/features/devise/confirmations_spec.rb
Running tests with args ["--color", "--failure-exit-code", "2", "--format", "documentation", "--format", "html", "--out", "reports/rspec_results.html", "--format", "Guard::RSpec::Formatter", "--require", "spec_helper", "--require", "/Users/viet/.rvm/gems/ruby-2.1.0/gems/guard-rspec-4.2.6/lib/guard/rspec/formatter.rb", "spec/features/devise/confirmations_spec.rb"]...

Confirmations
  #new
    should accept incorrect email and not send reset email (FAILED - 1)
    should accept correct email and send instructions email (FAILED - 2)
    should accept incorrect username and not send reset email (FAILED - 3)
    should accept correct username and send instructions email (FAILED - 4)

Failures:

  1) Confirmations #new should accept incorrect email and not send reset email
     Failure/Error: within('#new_user') { fill_in 'user_login', with: 'wrong@foobar.com' }
     Capybara::ElementNotFound:
       Unable to find css "#new_user"
     # ./spec/features/devise/confirmations_spec.rb:40:in `block (3 levels) in <top (required)>'

  2) Confirmations #new should accept correct email and send instructions email
     Failure/Error: within('#new_user') { fill_in 'user_login', with: user.email }
     Capybara::ElementNotFound:
       Unable to find css "#new_user"
     # ./spec/features/devise/confirmations_spec.rb:23:in `block (3 levels) in <top (required)>'

  3) Confirmations #new should accept incorrect username and not send reset email
     Failure/Error: within('#new_user') { fill_in 'user_login', with: 'foobar' }
     Capybara::ElementNotFound:
       Unable to find css "#new_user"
     # ./spec/features/devise/confirmations_spec.rb:32:in `block (3 levels) in <top (required)>'

  4) Confirmations #new should accept correct username and send instructions email
     Failure/Error: within('#new_user') { fill_in 'user_login', with: user.name }
     Capybara::ElementNotFound:
       Unable to find css "#new_user"
     # ./spec/features/devise/confirmations_spec.rb:14:in `block (3 levels) in <top (required)>'

Finished in 2.34 seconds
4 examples, 4 failures

Failed examples:

rspec ./spec/features/devise/confirmations_spec.rb:39 # Confirmations #new should accept incorrect email and not send reset email
rspec ./spec/features/devise/confirmations_spec.rb:22 # Confirmations #new should accept correct email and send instructions email
rspec ./spec/features/devise/confirmations_spec.rb:31 # Confirmations #new should accept incorrect username and not send reset email
rspec ./spec/features/devise/confirmations_spec.rb:13 # Confirmations #new should accept correct username and send instructions email

Randomized with seed 29280

Done.

恢复为cli: '--drb',测试按预期传递。

1 个答案:

答案 0 :(得分:1)

好像是DRb support has been removed since guard-rspec 4.0。您可以使用guard-rspec 3.1.0或(更好)切换到Zeus或Spring!