1

当规格或型号发生变化时,带有选项的守卫会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'

带有规范助手的完整内容

我已经尝试了 options 的所有不同变体rspecspring rspec spec以及其他可能的变体,包括没有任何变体,但结果相同。

rspec spec没有警卫工作正常。

我发现了类似的问题,但它没有弹簧。

4

2 回答 2

0

发现了问题。在guard-rspec/guard-rspec.gemspec4.2.2 版本中,行:

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

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

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

它有效!

顺便说一句,选项springincmd导致测试什么也不做。所以,这样工作:

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

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

于 2014-03-24T00:59:19.897 回答
0

尝试使用

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

一旦我写了这个快速公会供我参考,看看它是否适合你

HIH

于 2014-03-24T00:18:21.907 回答