在Rails項目我工作我插入RSpec的,黃瓜和自動測試與此Gemfile中(部分)自動測試平臺特定的寶石,捆綁
gem 'rspec-rails'
gem 'cucumber-rails'
gem 'autotest-standalone'
gem 'autotest-rails-pure'
gem 'zentest-without-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上,我想啓用自動測試,咆哮和自動測試,fsevents寶石,但如果我插入我的~/.autotest
那些行
require 'autotest/growl'
require 'autotest/fsevent'
然後我需要插入在Gemfile中相應的寶石和一切工作,但它打破建立我的CI服務器(這是在Linux上)上
如何解決這個不維護本地不同的Gemfile和CI環境?
編輯:
對於我的Gemfile
if RUBY_PLATFORM.downcase.include?("darwin") # I'm on Mac
gem 'autotest-fsevent'
gem 'autotest-growl'
end
它可以在本地和CI服務器上用這些行解決的那一刻,我不知道這是否擺烏龍,時刻它似乎工作完美無瑕。
任何干淨的方法,仍然是受歡迎的。
編輯2:
我切換到組解決方案。雖然以前的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
所以我對這個問題的最終解決方案是包括在一個給定組平臺特定的寶石,說OSX,然後在生產和CI服務器上使用排除捆綁它。
如果使用Capistrano的部署來把這個在您的config.rb
set :bundle_without, [:development, :test, :osx]
# capistrano bundler task
require "bundler/capistrano"
我在我的ci上使用了[這個配置](https://github.com/fabn/rails-jenkins-template),我想保持簡單,所以我想繼續在ci上運行簡單的作爲'捆綁安裝;耙規格;犁耙黃瓜'。 – Fabio 2011-04-12 13:00:49
我對這個問題進行了大量搜索,目前沒有解決方案。所以我會接受你的回答是正確的。 – Fabio 2011-05-28 00:42:59