我正在使用 gem bundler (v.0.9.6) 和 Rails 2.3.5、rubygems 1.3.6 和 ruby 1.8.7(在雪豹上)。我的 Gemfile 看起来像这样:
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_ERROR,Selenium 无法'找不到网址。好吧,碰巧服务器没有启动。
然后,我打开了 webrat/lib/webrat/selenium/application_servers/rails.rb 文件并在 start 方法中放置了一个调试器语句。再次运行该功能,当调试器触发时,我打印了 start_command 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
检查它尝试从以下位置加载 mongrel 的路径:“~/.bundle/...”,但 mongrel 是作为系统 gem 安装的。Bundle 在其他情况下可以很好地处理系统 gem 的加载,但在这种特殊情况下,我不知道它为什么会失败 :(。
我试图再次运行“捆绑安装”,它总是说:
从系统 gem 安装 mongrel (1.1.5)
我已经尝试从系统中卸载 mongrel 以尝试制作 bundle 以将其安装在 ~/.bundle 上 (因为这似乎是错误的来源,因为正在此路径中搜索 mongrel 我像上面一样启动 mongrel_rails),但我只是做不到。
gem uninstall mongrel
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d mongrel`
当我运行“gem list | grep mongrel”时,我得到:
mongrel (1.1.5)
奇怪的。
我只是希望能够在使用 gem bundler 时成功运行 Cucumber 和 WebRat + Selenium,但这让我抓狂。
谁能启发我?