2010-03-02 71 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目录,并从缓存或规范目录中删除任何残留,这应该起作用。