Rails 求解~看 RoR Tutorial 书中关于 spec 的问题

ying39 · 2014年04月11日 · 最后由 ying39 回复于 2014年04月12日 · 3601 次阅读

按书的第三章来做练习,具体在第 75 页,输入 bundle exec rspec spec/requests/static_pages_spec.rb 结果提示一大堆问题,看不明白,求解。

/Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in require': cannot load such file -- zip/zip (LoadError) from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:inblock (2 levels) in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in each' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:inblock in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in each' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:inrequire' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in require' from /Users/air-mx/rails_projects/sample_app/config/application.rb:12:in' from /Users/air-mx/rails_projects/sample_app/config/environment.rb:2:in require' from /Users/air-mx/rails_projects/sample_app/config/environment.rb:2:in' from /Users/air-mx/rails_projects/sample_app/spec/spec_helper.rb:3:in require' from /Users/air-mx/rails_projects/sample_app/spec/spec_helper.rb:3:in' from /Users/air-mx/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in require' from /Users/air-mx/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in load' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inblock in load_spec_files' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in each' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inload_spec_files' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in run' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:inrun' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in block in autorun' air-mxtekiMacBook-Air:sample_app air-mx$ bundle exec rspec spec/requests/static_pages_spec.rb /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:inrequire': cannot load such file -- zip/zip (LoadError) from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in <top (required)>' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:inrequire' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in <top (required)>' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:inrequire' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in <top (required)>' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:inrequire' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in <top (required)>' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:inrequire' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in block (2 levels) in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:ineach' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in block in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:ineach' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in require' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:inrequire' from /Users/air-mx/rails_projects/sample_app/config/application.rb:12:in <top (required)>' from /Users/air-mx/rails_projects/sample_app/config/environment.rb:2:inrequire' from /Users/air-mx/rails_projects/sample_app/config/environment.rb:2:in <top (required)>' from /Users/air-mx/rails_projects/sample_app/spec/spec_helper.rb:3:inrequire' from /Users/air-mx/rails_projects/sample_app/spec/spec_helper.rb:3:in <top (required)>' from /Users/air-mx/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:inrequire' from /Users/air-mx/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in <top (required)>' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inload' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in block in load_spec_files' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:ineach' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in load_spec_files' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:inrun' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in run' from /Users/air-mx/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:inblock in autorun'

把你的 gemfile 里对 selenium-webdriver 的声明写成: gem 'selenium-webdriver', '2.35.1' 然后重新 bundle install 试一试

后来自己搞定了,需要在 gemfile 的测试组总添加 gem 'zip',并 install。不过有个疑问,这个方法在我苦想乱试的时候做过,不过没有把它放在测试组里,而是直接单独放一行,这样好像没发解决,只能在测试组里才能生效,有什么区别吗?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号