在Windows上使用JRuby的guard失败了

时间:2012-02-26 20:26:41

标签: rspec jruby guard

我正在尝试使用JRuby在Windows上设置Guard,我得到了这个输出:

$ guard
You must 'gem install win32console' to use color on Windows
WARNING: You are using Guard outside of Bundler, this is dangerous and could not
 work. Using `bundle exec guard` is safer.
Guard uses Notifu to send notifications.
Guard is now watching at 'C:/Workspace/OE_11/CyberTrack_Rails3'
Guard::RSpec is running, with RSpec 2!

Running all specs
bundler: command not found: rspec
Install missing gem executables with `bundle install`
>

如果我只输入命令'rspec',事情就会起作用。那我在这里错过了什么?

$ rspec
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m


Finished in 1.39 seconds
←[32m8 examples, 0 failures←[0m

我将rspec.bat的路径添加到我的PATH环境变量中。

顺便说一句,我正在使用Windows。在Ubuntu上,我很快就完成了所有工作......

UPDATE 的Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.2.rc1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'activerecord-jdbcsqlite3-adapter'

gem 'jruby-openssl'
gem 'json'

group :development do
    gem 'rspec-rails'
    gem 'guard-rspec'
end

group :test do
    gem 'rspec-rails'
    gem 'guard-rspec'
  gem 'capybara', '1.1.2'
  gem 'rb-fchange', '0.0.5'
  gem 'rb-notifu', '0.0.4'
  #gem 'win32console', '1.3.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyrhino'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

1 个答案:

答案 0 :(得分:1)

我认为这是一个bundler错误,因为如果我运行,我会收到相同的错误:

bundle exec rspec spec

我设法让它能够评论并向guard-rspec源文件添加一些代码。

打开文件:

C:\jruby-1.6.7\lib\ruby\gems\1.8\gems\guard-rspec-0.6.0\lib\guard\rspec\runner.rb

Obs:请注意,此路径可能与您的计算机不同。无论如何,只需转到guard-rspec gem的来源并打开runner.rb文件。

并将rspec_command更改为:

  def rspec_command(paths, options={})
    warn_deprectation(options)

    cmd_parts = []
    cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
    cmd_parts << "bundle exec" if (bundler? && options[:binstubs] == true && options[:bundler] != false) || (bundler? && options[:bundler] != false)
    cmd_parts << "'"
    cmd_parts << rspec_exec(options)
    cmd_parts << options[:cli] if options[:cli]
    cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(/[\s=]/).any? { |w| %w[-f --format].include?(w) }
    #cmd_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_class.downcase}.rb -f Guard::RSpec::Formatter::Notification#{rspec_class}#{rspec_version == 1 ? ":" : " --out "}/dev/null" if options[:notification] != false
    cmd_parts << "--failure-exit-code #{failure_exit_code}" if failure_exit_code_supported?(options)

    cmd_parts << paths.join(' ')
    cmd_parts << "'"

    cmd_parts.join(' ')
  end

我所做的改变:

 1. commented on of the lines
 2. Added 2 code line to add "quotes" to the string builder.

它适用于此,因此它也可以在您的机器上运行。 我在捆绑商https://github.com/carlhuda/bundler/issues/1689上针对此问题打开了一个问题。