Fab*_*bio 7 ruby-on-rails autotest bundler gemfile
在我正在研究的rails项目中,我使用此Gemfile插入了对rspec,黄瓜和自动测试的支持(部分)
gem 'rspec-rails'
gem 'cucumber-rails'
gem 'autotest-standalone'
gem 'autotest-rails-pure'
gem 'zentest-without-autotest'
Run Code Online (Sandbox Code Playgroud)
但是为了使用自动测试运行测试,我需要执行,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.
Run Code Online (Sandbox Code Playgroud)
现在我正在使用Mac进行开发,我想启用autotest-growl和autotest-fsevents gem,但是如果我将这些行插入我的 ~/.autotest
require 'autotest/growl'
require 'autotest/fsevent'
Run Code Online (Sandbox Code Playgroud)
然后我需要在Gemfile中插入相应的gems,一切正常,但它会破坏我的CI服务器上的构建(在Linux上)
如何在不为本地和CI环境维护不同的Gemfile的情况下解决这个问题?
编辑:
目前我在Gemfile中用这些行解决了
if RUBY_PLATFORM.downcase.include?("darwin") # I'm on Mac
gem 'autotest-fsevent'
gem 'autotest-growl'
end
Run Code Online (Sandbox Code Playgroud)
它既可以在本地也可以在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
Run Code Online (Sandbox Code Playgroud)
所以我对这个问题的最终解决方案是在给定的组中包含特定于平台的gems,比如osx,然后在生产中和CI服务器上使用bundle排除它.
如果你使用capistrano部署把它放在你的 config.rb
set :bundle_without, [:development, :test, :osx]
# capistrano bundler task
require "bundler/capistrano"
Run Code Online (Sandbox Code Playgroud)
您可能想在 gemfile 中使用组,例如:
group :development do
gem "autotest-growl"
gem "autotest-fsevents"
endRun Code Online (Sandbox Code Playgroud)
并在您使用的服务器上:$ bundle install --without development
| 归档时间: |
|
| 查看次数: |
2250 次 |
| 最近记录: |