Cucumber 硒模式下的黄瓜和大鼠:Can';使用gem bundle时不要启动mongrel_rails

Cucumber 硒模式下的黄瓜和大鼠:Can';使用gem bundle时不要启动mongrel_rails,cucumber,bundle,gem,webrat,bundler,Cucumber,Bundle,Gem,Webrat,Bundler,我正在使用gem bundler(v.0.9.6)和Rails 2.3.5、rubygems 1.3.6和ruby 1.8.7(在雪豹上)。我的文件如下所示: source :rubyforge source "http://gems.github.com" gem "rails", "2.3.5" gem "ruby-debug" gem "activemerchant", :require => 'active_merchant' gem "hpricot" gem "nokogir

我正在使用gem bundler(v.0.9.6)和Rails 2.3.5、rubygems 1.3.6和ruby 1.8.7(在雪豹上)。我的文件如下所示:

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
到目前为止还不错。我已经成功地使用bundler几个星期了。然而,我开始在Selenium模式下使用Cucumber和WebRat来测试站点的一些ajaxy功能,每当我运行该功能时,WebRat都会告诉我Rails服务器已经启动,但我总是遇到XHR_错误,Selenium无法找到URL嗯,碰巧服务器没有启动。

然后,我打开webrat/lib/webrat/selenium/application\u servers/rails.rb文件,并在start方法中放入一条调试器语句。再次运行该功能,当调试器触发时,我打印了start_命令def的返回,它是:

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/…”加载mongrel的路径,但mongrel是作为系统gem安装的。Bundle在其他上下文中处理系统gems的加载,但在这个特定的情况下,我不知道它为什么会失败:(

我尝试再次运行“捆绑安装”,它总是说:

从系统安装mongrel(1.1.5) 宝石

我已经尝试从系统中卸载mongrel到尝试制作bundle将其安装到~/.bundle(因为这似乎是错误的根源,因为mongrel正在这个路径中搜索,所以我启动了mongrel\u rails,如上所述),但我就是做不到

gem uninstall mongrel
ERROR:  While executing gem ... (Gem::InstallError)
    cannot uninstall, check `gem list -d mongrel`
当我运行“gem list | grep mongrel”时,我得到:

奇怪

我只想在使用gem bundler时能够成功运行Cucumber和WebRat+Selenium,但这让我发疯


有谁能给我点启发吗?

嗯,我找到了一个解决办法,有点可疑,但很有效:

 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
它将找到mongrel并启动服务器,然后您可以运行使用Selenium的Cucumber功能,它将工作:)


如果其他人发现或知道有关此问题的任何其他信息,请分享,这可能最终成为某个地方的bug

我也遇到了类似的问题,但结果是/Users/{account}/.gems/和/Library/Ruby/gems/(默认安装)或/opt/local/lib/Ruby/gems/(Mac端口安装)中安装的gems版本不匹配。当我删除/Users/{account}/.gems/时,一切都正常了。

我遇到了同样的问题,并花了一段时间试图调试它。看起来Mongrel、GemPlugin和Bundler之间存在某种交互。可能的解决办法包括:

  • 修复GemPlugin,使其与Bundler 0.9配合使用
  • 修改Mongrel以不再使用GemPlugin
  • 修改Webrat以支持除Mongrel之外的web服务器
  • 由于GemPlugin和Mongrel这几天看起来都有些过时和废弃,我决定基于添加对Webrat的瘦支持

    您可以,也可以将以下内容添加到您的文件中:

    gem 'webrat', :git => 'git://github.com/emk/webrat.git'
    
    …并相应地更新您的features/support/env.rb文件:

    Webrat.configure do |config|
      # Add this line.
      config.application_framework = :rails_thin
    
      # Your previous configuration here...
    end
    

    尝试定位当前gem可执行文件正在使用的gems目录,并从缓存或规范目录中删除任何剩余内容,这应该会起作用。

    bundle exec mongrel\u rails start…

    这里的要点是从bundle加载rails gem,而不是从系统gemenv加载

    我们这里有一个类似的场景:

    您能否验证此解决方案是否从捆绑包中加载所有rails gem?还是mongrel和所有活动的*gems最终都从系统gemenv加载?
    Webrat.configure do |config|
      # Add this line.
      config.application_framework = :rails_thin
    
      # Your previous configuration here...
    end