Guard rspec没有运行规范

时间:2014-03-21 01:25:49

标签: ruby-on-rails rspec guard spring-gem

当规范或模型发生变化时,带有选项spring rspec的后卫会显示下一个输出:

04:54:44 - INFO - Running: spec/models/identity_spec.rb
Version: 1.1.2

Usage: spring COMMAND [ARGS]

Commands for spring itself:

  binstub         Generate spring based binstubs. Use --all to generate a binstub for all known commands.
  help            Print available commands.
  status          Show current status.
  stop            Stop all spring processes for this project.

Commands for your application:

  rails           Run a rails command. The following sub commands will use spring: console, runner, generate, destroy.
  rake            Runs the rake command


Frame number: 0/0

我在春天使用ruby '2.1.0''rails', '4.1.0.rc1'。所以,看起来它并没有运行任何东西。我尝试了不同的cmd选项。

guard :rspec do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
end

这会引发错误:

05:04:08 - INFO - Running: spec/models/identity_spec.rb
05:04:08 - ERROR - Guard::RSpec failed to achieve its <run_on_modifications>, exception was:
> [#] NoMethodError: undefined method `parse_options' for #<RSpec::Core::ConfigurationOptions:0x007fad670937a8 @args=[]>
> [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:33:in `_rspec_formatters'
> [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:29:in `_visual_formatter'
> [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:21:in `_parts'
> [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:14:in `initialize'

包含规范帮助的完整内容there

我已尝试过各种不同的选项rspecspring rspec spec和其他可能的选项,包括没有任何选项,但结果相同。

rspec spec没有后卫可以正常工作。

我找到了similar problem,但没有春天就行了。

2 个答案:

答案 0 :(得分:0)

尝试使用

guard 'rspec', :cli => '--drb' do
  #your code
end

一旦我写了quick guild作为我的参考,看看它是否适合你

HIH

答案 1 :(得分:0)

发现问题。在4.2.2版本的guard-rspec/guard-rspec.gemspec中,行:

   s.add_dependency 'rspec', '>= 2.14', '< 4.0'

我猜测与beta版冲突。所以我接下来改变了它:

   s.add_dependency 'rspec', '>= 2.14', '~> 3.0.0.beta2', '< 4.0'

它有效!

顺便说一下,spring中的选项cmd导致测试无效。所以,这样做:

   guard :rspec, cmd: 'rspec -f doc --color --require spec_helper ' do

guard :rspec do,它会考虑来自.rspec文件的选项,其中我不确定。