环境/ cucumber.rb:
...
# gem dependencies
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.0' unless File.directory?(File.join(Rails.root, 'vend
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vend
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vend
config.gem 'spork', :lib => false, :version => '>=0.7.5' unless File.directory?(File.join(Rails.root, 'vend
config.gem 'factory_girl', :source => 'http://gemcutter.org'
config.gem 'selenium-client', :lib => false
config.gem 'Selenium', :lib => false
config.gem 'rspec', :lib => 'spec'
config.gem 'rspec-rails', :lib => 'spec/rails'
config.gem 'test-unit', :lib => false
运行黄瓜会丢失宝石错误:
artem:~/projects/food4feed (master)$ cucumber
...
no such file to load -- Selenium
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rspec-rails-1.3.2/lib/spec/rails.rb:13:in `<top (required)>'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in `load'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `block in load_gems'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `each'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:169:in `process'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
/home/artem/projects/food4feed/config/environment.rb:9:in `<top (required)>'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/projects/food4feed/features/support/env.rb:12:in `block in <top (required)>'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/spork-0.8.1/lib/spork.rb:23:in `prefork'
/home/artem/projects/food4feed/features/support/env.rb:10:in `<top (required)>'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/rb_support/rb_language.rb:124:in `load_code_file'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:85:in `load_code_file'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:77:in `block in load_code_files'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:76:in `each'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:76:in `load_code_files'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/cli/main.rb:48:in `execute!'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/cli/main.rb:20:in `execute'
/home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/bin/cucumber:8:in `<top (required)>'
/home/artem/.rvm/gems/ruby-1.9.1-p378/bin/cucumber:19:in `load'
/home/artem/.rvm/gems/ruby-1.9.1-p378/bin/cucumber:19:in `<main>'
Missing these required gems:
selenium-client
Selenium
rspec-rails
You're running:
ruby 1.9.1.378 at /home/artem/.rvm/rubies/ruby-1.9.1-p378/bin/ruby
rubygems 1.3.5 at /home/artem/.rvm/gems/ruby-1.9.1-p378, /home/artem/.rvm/gems/ruby-1.9.1-p378%global
所有宝石显然都在那里:
artem:~/projects/food4feed (master)$ gem list | egrep "elenium|rspec|test-unit"
rspec (1.3.0)
rspec-rails (1.3.2)
Selenium (1.1.14)
selenium-client (1.2.18)
test-unit (2.0.7)
更令人困惑的是,它只会抱怨某些宝石。 factory_girl
和rspec
不会导致问题。
知道发生了什么事吗?
我的环境:
答案 0 :(得分:2)
好的,我想到了(在aslakhellesoy的帮助下,谢谢!)。当黄瓜说Missing these required gems
时,它也可能意味着Can't load these required gems
。这增加了所有可能的错误。
在这种情况下,gems名称(除了rspec-rails)与要求的相应库文件不匹配。例如,应该:lib => 'selenium'
添加了config.gem 'selenium-client'
。
对于rspec-rails,由于测试单元的版本错误而导致无法加载:Gem::LoadError: RubyGem version error: test-unit(2.0.7 not = 1.2.3)
。如果黄瓜首先报告这个错误(我从控制台要求rspec-rails得到它),它会帮助很多。
答案 1 :(得分:1)
您是否在config / environment.rb或features / support / env.rb文件中的某处需要'test-unit'?
如果你这样做,那就错了。测试单元gem没有test-unit.rb文件,因此要求'test-unit'将始终失败。尝试删除require行,或者至少尝试要求正确的文件:
要求'test / unit'
我不知道你为什么要尝试显式加载测试单元。