简体   繁体   English

Guard rspec没有运行规范

[英]Guard rspec doesn't run specs

When spec or model changed, guard with options spring rspec shows next output: 当规格或型号更改时,带有选项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

I'm using ruby '2.1.0' and 'rails', '4.1.0.rc1' with spring. 我使用的ruby '2.1.0''rails', '4.1.0.rc1'春暖花开。 So, it looks like it doesn't run anything. 因此,看起来它什么都没有运行。 I tried different cmd options. 我尝试了不同的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

This throws en error: 这将引发错误:

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'

Full content there with spec helper 全部内容存在与规范帮手

I've tried all different variations of options rspec , spring rspec spec and other possible including without any, but had the same result. 我尝试了选项rspecspring rspec spec所有不同变体,以及其他可能的变体,包括没有任何变体,但结果相同。

rspec spec without guard works fine. 没有保护的rspec spec可以正常工作。

I found similar problem , but it works without spring. 我发现了类似的问题 ,但是它没有弹簧就可以工作。

try using 尝试使用

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

once I wrote this quick guild for my reference, see if that works for you 一旦我写了这个快速公会供我参考,看看是否对您有用

HIH HIH

Found the problem. 找到了问题。 In guard-rspec/guard-rspec.gemspec from 4.2.2 version, line: 在4.2.2版本的guard-rspec/guard-rspec.gemspec ,行:

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

Conflicted with beta version i guess. 我想与Beta版本冲突。 So i changed it on next: 所以我接下来更改了它:

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

And it works! 而且有效!

And by the way, option spring in cmd caused test to do nothing. 顺便说一句, cmd option spring导致测试无效。 So, works this: 因此,这工作:

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

And just guard :rspec do , and it consider options from .rspec file, in which i wasn't sure. 只是guard :rspec do ,它会考虑.rspec文件中的选项,我不确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM