ruby-on-rails – 带捆绑器的自动测试的平台特定宝石
在我正在研究的rails项目中,我使用此Gemfile插入了对rspec,黄瓜和自动测试的支持(部分)
gem 'rspec-rails' gem 'cucumber-rails' gem 'autotest-standalone' gem 'autotest-rails-pure' gem 'zentest-without-autotest' 但是为了使用autotest运行测试,我需要执行bundle exec autotest,否则它将失败并显示此消息 $autotest loading autotest/cucumber_rails_rspec_rspec2 Error loading Autotest style autotest/cucumber_rails_rspec_rspec2 (no such file to load -- autotest/cucumber_rails_rspec_rspec2). Aborting. 现在我正在使用Mac进行开发,我想启用autotest-growl和autotest-fsevents gem,但是如果我在?/ .autotest中插入这些行 require 'autotest/growl' require 'autotest/fsevent' 然后我需要在Gemfile中插入相应的gems,一切正常,但它会破坏我的CI服务器上的构建(在Linux上) 如何在不为本地和CI环境维护不同的Gemfile的情况下解决这个问题? 编辑: 目前我在Gemfile中用这些行解决了 if RUBY_PLATFORM.downcase.include?("darwin") # I'm on Mac gem 'autotest-fsevent' gem 'autotest-growl' end 它既可以在本地也可以在CI服务器上运行,我不知道它是否会弄乱一些东西,目前它似乎完美无缺. 任何更干净的方式仍然是受欢迎的. EDIT2: 我切换到群组解决方案.虽然之前的monkeypatch在开发和持续集成方面都运行良好,但如果您使用capistrano bundler任务进行部署,或者如果您使用bundle install –deployment选项(在生产中建议),它将在生产中出现错误 使用if RUBY_PLATFORM.downcase.include?(“darwin”)行时,您将在部署时遇到此错误. # bundle install --deployment --without development test You are trying to install in deployment mode after changing your Gemfile. Run `bundle install` elsewhere and add the updated Gemfile.lock to version control. You have deleted from the Gemfile: * autotest-fsevent * autotest-growl 所以我对这个问题的最终解决方案是在给定的组中包含特定于平台的gems,比如osx,然后在生产中和CI服务器上使用bundle排除它. 如果你使用capistrano部署把它放在你的config.rb中 set :bundle_without,[:development,:test,:osx] # capistrano bundler task require "bundler/capistrano" 解决方法
您可能希望在gemfile中使用组,例如:
group :development do gem "autotest-growl" gem "autotest-fsevents" end 并在您使用的服务器上:$bundle install – without development (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |