测试在我的Ubuntu电脑上运行,但不是在我的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

查看:362
本文介绍了测试在我的Ubuntu电脑上运行,但不是在我的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或cucumber时,它们运行良好,但是当我尝试在Mac上运行测试时,在
中有相同的错误 config / application.rb:13: / em> Bundler.require(* Rails.groups(:assets =>%w(开发测试)))



对于黄瓜:

 使用默认配置文件... 
未定义方法`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 :inrescue in block in require
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:62 :inblock 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'
/用户/ sergey / Dropbox / rails_projects / payforapps / config / application.rb:13:在`< top(必需)>'
/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 / ruby​​gems / 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 / ruby​​gems / 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必需)>'
/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:在`run!'
/ Users / sergey /。 rvm/gems/ruby-1.9.3-p125@payforapps321/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:在`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(必填)>'
/Users/sergey/.rvm/gems/ ruby-1.9.3-p125@payforapps321/bin/cucumber:19:在`load'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/bin/cucumber:19:在`< main>'中

对于rspec:


$ b b

 没有DRb服务器正在运行。在本地进程中运行... 
/Users/sergey/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.1/lib/bundler/runtime.rb:77:在`rescue'中的救援在require中的块:undefined方法`gsub'为nil:NilClass(NoMethodError)
从/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:在`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:在`require'
从/Users/sergey/Dropbox/rails_projects/payforapps/config/application.rb:13:in`< top(必需)>'
从/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 / ruby​​gems / custom_require.rb:36:在`require'
从/ Users / sergey / Dropbox / rails_projects /payforapps/config/environment.rb:2:in`< top(必需)>'
从/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/spec/spec_helper.rb:10:in`块在< top(必填)>'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/spork-0.9.0/lib/spork.rb:24:in`prefork'
从/用户/ sergey / Dropbox / rails_projects / payforapps / spec / spec_helper.rb:4:在`< top(必填)>'
从/Users/sergey/.rvm/rubies/ruby-1.9.3- p125 / lib / ruby​​ / site_ruby / 1.9.1 / ruby​​gems / custom_require.rb:36:在`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/spec/controllers/static_pages_controller_spec.rb:1:in`< top (必需)>'
来自/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb :746:在`load'
从/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'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/core /configuration.rb:746:in`map'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/rspec/ core / configuration.rb:746:在`load_spec_files'
从/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'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0/lib/ rspec / core / runner.rb:66:在`rescue in run'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9.0 /lib/rspec/core/runner.rb:62:in`run'
从/Users/sergey/.rvm/gems/ruby-1.9.3-p125@payforapps321/gems/rspec-core-2.9。 0 / lib / rspec / core / runner.rb:10:inblock in autorun

我可以解决它吗?任何帮助赞赏。谢谢。

解决方案

问题出在我的 Gemfile b
$ b

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



这些gem只能与Ubuntu兼容,因为我明白。



UPD:



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

 #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)

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


I have project in Dropbox and two running laptops: one with Ubuntu and one with Mac OS X Lion 10.7.3. When I try to run either rspec or cucumber on ubuntu they are running well, but when I try to run tests on Mac I have the same errors in config/application.rb:13: Bundler.require(*Rails.groups(:assets => %w(development test)))

For cucumber:

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>'

For 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'

How can I fix it? Any help appreciated. Thank you.

解决方案

The problem was in two gems in my Gemfile:

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

These gems are compatible only with Ubuntu as I understand.

UPD:

You should OS-specific gems to groups. Add all OS X specific gems to a darwin group in the Gemfile, and all Linux specific gems to a linux group:

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

group :linux do
  gem 'rb-inotify'
end

To require the appropriate gems in the right environment, add the following to config/application.rb:

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

See https://github.com/bbatsov/rails-style-guide#bundler for more info about bundler here.

这篇关于测试在我的Ubuntu电脑上运行,但不是在我的Mac OS X Lion 10.7.3,Ruby 1.9.3,Rails 3.2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆