繁体   English   中英

测试在我的Ubuntu pc上运行,但不在我的Mac OS X Lion 10.7.3,Ruby 1.9.3,Rails 3.2.1上运行

[英]Tests are running on my Ubuntu pc, but not on my Mac OS X Lion 10.7.3, Ruby 1.9.3, Rails 3.2.1

我在Dropbox和两台运行的笔记本电脑上有一个项目:一个是Ubuntu,另一个是Mac OS X Lion 10.7.3。 当我尝试在ubuntu上运行rspec或者黄瓜时它们运行良好,但是当我尝试在Mac上运行测试时,我在config / application.rb中 Bundler.require(*Rails.groups(:assets => %w(development test)))了相同的错误:13: Bundler.require(*Rails.groups(:assets => %w(development test)))

黄瓜:

Using the default profile...
undefined method `gsub' for nil:NilClass (NoMethodError)
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:72:in `rescue in block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:62:in `block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `each'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler.rb:119:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/config/application.rb:13:in `<top (required)>'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/config/environment.rb:2:in `<top (required)>'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/features/support/env.rb:11:in `block in <top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/spork-0.9.0/lib/spork.rb:24:in `prefork'
/Users/sergey/Dropbox/rails_projects/payforapps/features/support/env.rb:6:in `<top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/bin/cucumber:19:in `load'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/bin/cucumber:19:in `<main>'

对于rspec:

No DRb server is running. Running in local process instead ...
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require': undefined method `gsub' for nil:NilClass (NoMethodError)
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:72:in `rescue in block in require'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:62:in `block in require'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `each'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `require'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler.rb:119:in `require'
        from /Users/sergey/Dropbox/rails_projects/payforapps/config/application.rb:13:in `<top (required)>'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/Dropbox/rails_projects/payforapps/config/environment.rb:2:in `<top (required)>'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/Dropbox/rails_projects/payforapps/spec/spec_helper.rb:10:in `block in <top (required)>'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/spork-0.9.0/lib/spork.rb:24:in `prefork'
        from /Users/sergey/Dropbox/rails_projects/payforapps/spec/spec_helper.rb:4:in `<top (required)>'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /Users/sergey/Dropbox/rails_projects/payforapps/spec/controllers/static_pages_controller_spec.rb:1:in `<top (required)>'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:66:in `rescue in run'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:62:in `run'
        from /Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

我该如何解决? 任何帮助赞赏。 谢谢。

问题出在我的Gemfile中的两个宝石中:

gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'

据我所知,这些宝石只与Ubuntu兼容。

UPD:

您应该将特定于操作系统的宝石添加到组中。 将所有OS X特定的gems添加到Gemfile中的darwin组,并将所有特定于Linux的gem添加到linux组:

# Gemfile
group :darwin do
  gem 'rb-fsevent'
  gem 'growl'
end

group :linux do
  gem 'rb-inotify'
end

要在正确的环境中需要适当的gem,请将以下内容添加到config / application.rb

platform = RUBY_PLATFORM.match(/(linux|darwin)/)[0].to_sym
Bundler.require(platform)

有关bundler的更多信息,请参阅https://github.com/bbatsov/rails-style-guide#bundler

我的宝石有问题。

更新捆绑包

正确阅读错误,它会告诉你哪个宝石是罪魁祸首。

事实是,并非所有宝石都与操作系统兼容。

暂无
暂无

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

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