2013-09-01 8 views
10

Sto seguendo il tutorial di Michael Hartl su rubinetti su rotaie per testare l'app di esempio (3.2.1 Sviluppo basato su test), ma sto ottenendo seguente errore dopo aver digitato bundle exec rspec spec/requests/static_pages_spec.rbbundle exec rspec spec/richieste/static_pages_spec.rb dal tutorial di Hartl non funziona

/home/rahul/.rvm/gems/[email protected]_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/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in `<top (required)>' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `require' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `<top (required)>' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `require' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `<top (required)>' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `require' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `<top (required)>' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each' 
    from /home/rahul/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require' 
    from /home/rahul/.rvm/gems/[email protected]/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/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load' 
    from /home/rahul/.rvm/gems/[email protected]_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/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' 
    from /home/rahul/.rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' 

Qui è il codice dal file di spec/requests/static_pages_spec:

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 

OS: Ubuntu 13.04

Sono stato alla ricerca di una soluzione, ma non ho trovato uno. Tieni presente che sono nuovo di Ruby on Rails e dello sviluppo web.

+2

Immagino che manchi una gemma chiamata "zip", che dovrebbe essere stata installata insieme al driver del selenio-web, ma a volte queste cose non sono perfette.Prova ad aggiungere "gem 'zip" "al tuo gruppo di test, esegui di nuovo l'installazione di bundle –

+1

@NeilSlater Che ha funzionato! Molte grazie. –

+1

Dato che non ci sono risposte, dovrei rispondere alla mia stessa domanda per chiudere la discussione? –

risposta

13

Il messaggio di errore:

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

si riferisce a una gemma mancante chiamato "rubyzip". Dovrebbe essere stato installato da bundler insieme al driver del selenio-web, ma a volte queste cose non sono perfette. In questo caso, l'ultima versione della gemma "rubyzip" ha cambiato la struttura della libreria, quindi "zip/zip" non esiste. Bundler installerà per impostazione predefinita la versione più recente, motivo per cui non vi sono errori durante l'installazione, ma si verificherà un errore quando si tenta di eseguire il progetto, poiché gli elenchi di dipendenza di selenium-webdriver non sono a conoscenza della differenza.

Provare ad aggiungere gem 'rubyzip', '< 1.0.0' al proprio gruppo di prova ed eseguire nuovamente bundle install.


Il problema sembra essere causato da un aggiornamento al rubyzip gemma, vedere https://github.com/rubyzip/rubyzip

Il selenium-webdriver gemma probabilmente deve essere aggiornata per riflettere tali cambiamenti - ho registrato un problema: https://github.com/vertis/selenium-webdriver/issues/3

+1

L'ho trovato durante l'aggiornamento di un progetto Rails 3 per utilizzare 'rspec-rails 2.14.0' e' capybara 2.1.0' e questa risposta ha risolto il problema. Grazie molto! –

1

Change

gem 'selenium-webdriver', '2.0.0' 

a

gem 'selenium-webdriver' 

nel vostro Gemfile

4

Ho avuto lo stesso problema di recente e, semplicemente cambiando la versione della gemma

gem 'selenium-webdriver', '2.0.0' 

per l'ultimo:

gem 'selenium-webdriver', '2.35.1' 

esso ha riparato ! Non è stato necessario installare la gemma rubyzip.

+1

stesso qui. ha funzionato come un fascino. – nfriend21

Problemi correlati