为什么Guard(rspec)停止在jruby上工作

时间:2013-03-03 21:22:50

标签: ruby rspec jruby guard specifications

我无法让卫兵在jruby上工作。我在1.9.3旁边的rvm中有jruby inistalled。试图在1.9.3上运行Guard - 工作正常。如何在speclib

中的每次更改时自动运行规范

这是我在运行bundle exec guard并且在此期间未更改文件

后获得的内容
vagrant@precise64:/vagrant/sample$ bundle exec guard
21:16:46 - INFO - Guard uses TerminalTitle to send notifications.
21:16:47 - INFO - Guard::RSpec is running
21:16:47 - INFO - Running all specs
...

Finished in 0.025 seconds
3 examples, 0 failures

21:17:20 - INFO - Guard is now watching at '/vagrant/sample'
before_session hook failed: Errno::ENOENT: No such file or directory - /vagrant/sample
org/jruby/RubyFile.java:333:in `initialize'
(see _pry_.hooks.errors to debug)
[1] guard(main)> 

再次运行规范的唯一方法是在这里按ENTER键。此外,我无法确定此No such file or directory事物的来源(它不会在1.9.3 MRI上弹出)。我不熟悉守卫内部,不能真正找到为什么会这样。

我的Guardfile是标准的:

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

Gemfile仅包含:

gem 'rspec', '~>2.13.0'
gem 'guard-rspec'
gem 'rb-inotify', '~>0.9'

2 个答案:

答案 0 :(得分:2)

before_session挂钩来自Pry,但是Guard不使用这种类型的挂钩(我们只使用:when_started和:after_eval):

[1] guard(main)> Pry.hooks
=> #<Pry::Hooks:0x007ff0359a36c0
 @errors=[],
 @hooks=
  {:before_session=>
    [[:default,
      #<Proc:0x007ff0359a3648@/Users/michi/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/pry-0.9.12/lib/pry.rb:11>]],
   :when_started=>
    [[:load_guard_rc,
      #<Proc:0x007ff037a12910@/Users/michi/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/guard-1.6.2/lib/guard/interactor.rb:109>]],
   :after_eval=>
    [[:restore_visibility,
      #<Proc:0x007ff037a126e0@/Users/michi/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/guard-1.6.2/lib/guard/interactor.rb:116>]],
   :after_session=>[],
   :after_read=>[],
   :before_eval=>[]}>

我会提交一个Pry错误并在没有交互器(guard -i)的情况下运行Guard,直到修复为止。

答案 1 :(得分:0)

将其添加到Guardfile

# disable Pry for continious integration
interactor :off