2010-03-02 72 views
1

我使用gem bundler(v.0.9.6)和Rails 2.3.5,rubygems 1.3.6和ruby 1.8.7(在Snow上豹)。我的Gemfile看起來像這樣:Selenium模式下的黃瓜和WebRat:使用gem包時無法啓動mongrel_rails

source :rubyforge 
source "http://gems.github.com" 

gem "rails", "2.3.5" 
gem "ruby-debug" 
gem "activemerchant", :require => 'active_merchant' 
gem "hpricot" 
gem "nokogiri" 
gem "state_machine" 
gem "fastercsv" 
gem "yubikey" 
gem "httparty" 
gem "ruby-openid" 
gem "mongrel" 

group :development do 
    gem 'mongrel' 
end 

#teste 
group :test do 
    gem 'rspec' 
    gem 'rspec-rails' 
    gem 'cucumber' 
    gem 'cucumber-rails' 
    gem "mechanize" 
    gem 'notahat-machinist', :require => 'machinist' 
    gem 'faker' 
    gem 'webrat' 
    gem 'selenium-client' 
    gem 'database_cleaner' 
    gem 'fakeweb' 
    gem 'mongrel' #Selenium needs this 
end 

到目前爲止好。我已經成功使用捆綁器幾個星期了。然而,我開始在Selenium模式下使用Cucumber和WebRat來測試站點的一些ajaxy特性,並且每當我運行該功能時,WebRat都告訴我Rails服務器已啓動,但我總是得到一個XHR_ERROR,Selenium不能找不到網址。 嗯,它發生了服務器沒有啓動。

於是,我打開webrat/lib中/ webrat /硒/ application_servers/rails.rb文件,並把一個調試器語句啓動方法。再次運行功能,當調試器觸發,我打印的START_COMMAND返回閃避,這是:

mongrel_rails start -d --chdir='/Users/fullofcaffeine/Projetos/myproject' --port=3001 --environment=test --pid /Users/fullofcaffeine/Projetos/myproject/tmp/pids/mongrel_selenium.pid 

我複製並在控制檯貼吧,刪除從最終-d和&,這裏的我得到的輸出:

** Rails loaded. 
** Loading any Rails specific GemPlugins 
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require': no such file to load -- /Users/fullofcaffeine/.bundle/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/init.rb (MissingSourceFile) 
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' 
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' 
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' 
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:134:in `load' 
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:241:in `each' 
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:241:in `each' 
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:231:in `load_plugins' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:117:in `cloaker_' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run' 
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 
from /usr/bin/mongrel_rails:19:in `load' 
from /usr/bin/mongrel_rails:19 

檢查它試圖加載從雜種的路徑:「〜/ .bundle/...」,但雜種安裝爲系統的寶石。 Bundle處理系統寶石的加載在其他情況下罰款,但在這種特殊情況下,我不知道爲什麼它是失敗:(。

我試着再次運行「捆綁安裝」,它總是說:

從系統安裝雜種(1.1.5) 寶石

我試圖從系統中卸載雜種來儘量讓捆在〜/ .bundle安裝(因爲這似乎是錯誤的來源,因爲雜種是在這條路上搜索ing我開始像上面的mongrel_rails),但我無法做到這一點。

gem uninstall mongrel 
ERROR: While executing gem ... (Gem::InstallError) 
    cannot uninstall, check `gem list -d mongrel` 

當我運行 「寶石名單| grep的雜種」,我得到:

mongrel (1.1.5) 

奇怪。

我只是希望能夠在使用gem bundler的同時成功運行Cucumber和WebRat + Selenium,但是這使我瘋狂。

任何人都可以啓發我嗎?

回答

0

好吧,我發現了一個解決辦法,就是那種腥,但工程:

cp /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/ mongrel-1.1.5 

現在,如果你嘗試:

mongrel_rails start --chdir='/Users/fullofcaffeine/Projetos/myproject' --port=3001 --environment=test --pid /Users/fullofcaffeine/Projetos/myproject/tmp/pids/mongrel_selenium.pid 

它會找到雜種並啓動服務器,然後你可以運行使用Selenium的Cucumber功能,它將工作:)

如果有人發現或知道有關此問題的其他信息,請沙這可能最終會成爲某個地方的錯誤。

+0

你能否確認這個變通方法是否加載所有從包鋼軌的寶石?或者做雜種和所有積極的*寶石結束從系統gemenv加載? – tribalvibes 2010-10-07 00:10:51

0

我有一個類似的問題,但事實證明,在我的/Users/{account}/.gems/和安裝在/ Library/Ruby/Gems /(default安裝)或在/ opt/local/lib/ruby​​/gems /(Mac端口安裝)中。一旦我刪除了/Users/{account}/.gems/,它就全部奏效了。

0

我遇到了同樣的問題,花了一段時間試圖調試它。看起來Mongrel,GemPlugin和Bundler之間有某種相互作用。可能的解決方案包括:

  1. 修復GemPlugin與Bundler 0.9配合良好。
  2. 將Mongrel修改爲不再使用GemPlugin。
  3. 修改Webrat以支持Mongrel以外的Web服務器。

由於GemPlugin和Mongrel都看起來已經過時並且被放棄了,所以我決定根據this patch向Webrat添加Thin支持。

您可以find the new patch on github,或添加以下到您的Gemfile:

gem 'webrat', :git => 'git://github.com/emk/webrat.git' 

...和更新相應的功能/支持/ env.rb文件:

Webrat.configure do |config| 
    # Add this line. 
    config.application_framework = :rails_thin 

    # Your previous configuration here... 
end 
0

嘗試找到當前gem可執行文件正在使用的gems目錄,並從緩存或規範目錄中刪除任何殘留,這應該起作用。

相關問題