来自 Hartl 教程的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用 [英] bundle exec rspec spec/requests/static_pages_spec.rb from Hartl's tutorial isn't working

查看:28
本文介绍了来自 Hartl 教程的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 Michael Hartl 的 ruby​​ on rails 教程来测试示例应用程序(3.2.1 测试驱动开发),但在键入 bundle exec rspec spec/requests/static_pages_spec.rb 后出现以下错误

I'm following Michael Hartl's ruby on rails tutorial to test the sample app(3.2.1 Test-driven development), but I'm getting following error after typing bundle exec rspec spec/requests/static_pages_spec.rb

/home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in `require': cannot load such file -- zip/zip (LoadError)
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in `<top (required)>'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `<top (required)>'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `<top (required)>'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `<top (required)>'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /home/rahul/Downloads/rails_projects/sample_app/config/application.rb:12:in `<top (required)>'
    from /home/rahul/Downloads/rails_projects/sample_app/config/environment.rb:2:in `require'
    from /home/rahul/Downloads/rails_projects/sample_app/config/environment.rb:2:in `<top (required)>'
    from /home/rahul/Downloads/rails_projects/sample_app/spec/spec_helper.rb:3:in `require'
    from /home/rahul/Downloads/rails_projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
    from /home/rahul/Downloads/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
    from /home/rahul/Downloads/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

这是来自 spec/requests/static_pages_spec 文件的代码:

Here is the code from spec/requests/static_pages_spec file:

require 'spec_helper'

describe "Static pages" do

  describe "Home page" do

    it "should have the content 'Sample App' " do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')
    end

  end

end

Gemfile:

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.0'

group :development, :test do
  gem 'sqlite3', '1.3.7'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.0.0'
  gem 'capybara', '2.1.0'
end

gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

routes.rb:

SampleApp::Application.routes.draw do
  get "static_pages/home"
  get "static_pages/help"
end

操作系统:Ubuntu 13.04

OS: Ubuntu 13.04

我一直在寻找解决方案,但没有找到.请记住,我是 Ruby on Rails 和网络开发的新手.

I've been searching for solution, but have not found one. Please keep in mind that I'm new to Ruby on Rails and web development.

推荐答案

错误信息:

in `require': cannot load such file -- zip/zip (LoadError)

指的是一个名为rubyzip"的缺失宝石.它应该是由 bundler 和 selenium-web 驱动程序一起安装的,但有时这些东西并不完美.在这种情况下,最新版本的rubyzip"gem 已更改库结构,因此zip/zip"不存在.Bundler默认会安装最新版本,这就是为什么安装时不会报错,但是尝试运行项目时会报错,因为selenium-webdriver依赖列表不知道区别.

is referring to a missing gem called "rubyzip". It should have been installed by bundler along with selenium-web driver, but sometimes these things are not perfect. In this case, the latest version of the "rubyzip" gem has changed library structure, so 'zip/zip' does not exist. Bundler will by default install the latest version, which is why there is no error on install, but there will be an error when you try to run the project, because selenium-webdriver dependency lists are not aware of the difference.

尝试添加 gem 'rubyzip', '<1.0.0' 到您的测试组,然后重新运行 bundle install.

Try adding gem 'rubyzip', '< 1.0.0' to your test group, and re-run bundle install.

该问题似乎是由 rubyzip gem 的更新引起的,请参阅 https://github.com/rubyzip/rubyzip

The problem appears to be caused by an update to the rubyzip gem, see https://github.com/rubyzip/rubyzip

selenium-webdriver gem 可能需要更新以反映这些更改 - 我记录了一个问题:https://github.com/vertis/selenium-webdriver/issues/3

The selenium-webdriver gem probably needs updating to reflect those changes - I have logged an issue: https://github.com/vertis/selenium-webdriver/issues/3

这篇关于来自 Hartl 教程的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆