1

我无法让 Guard 在 jruby 上工作。我已经通过 rvm 在 1.9.3 旁边安装了 jruby。尝试在 1.9.3 上运行 Guard - 工作正常。如何使其在specor的每次更改时自动运行规范lib

这是我运行后得到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'
4

2 回答 2

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,直到修复。

于 2013-03-04T12:25:24.307 回答
0

将其添加到您的 Guardfile

# disable Pry for continious integration
interactor :off
于 2013-12-20T09:12:58.863 回答