2015-01-27 18 views
6

sto creando`require ': non può caricare tale file - spec_helper (LoadError)

bundler gem --test=rspec MyGem. 

in cui mi sto ricevendo struttura reository.

mentre eseguo il codice rspec sto ricevendo errore.

`require': cannot load such file -- spec_helper (LoadError) 

cerco di applicare richiedono relativa ancora I m ottenendo errore come

[email protected]:~/sheetal/spec$ rspec sheetal_spec.rb 
\/home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spec_helper (LoadError) 
    from /home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
    from /home/sheetal/sheetal/spec/sheetal_spec.rb:1:in `<top (required)>' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `load' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `<main>' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval' 
    from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>' 

risposta

21

Si sta eseguendo le specifiche dalla cartella spec. Questo rovina il percorso di caricamento. Esegui le specifiche dalla radice del tuo progetto: ~/sheetal.

rspec spec/sheetal_spec.rb 

Rspec aggiunge le cartelle spec e lib al percorso di carico automaticamente. Se sei già nella cartella spec, rspec aggiungerà invece spec/spec al percorso di caricamento.

Supponendo di avere il codice nella cartella lib, si dovrà aggiungere sia . e ../lib al percorso di carico, se si desidera eseguire i test nella cartella spec.

+0

Grazie a @Jesper .. Sono in grado di eseguirlo ora dalla mia cartella – user4443990

Problemi correlati