Valency
Valency

Reputation: 107

rspec rails 3.2.3, and ruby 1.9.3 getting cannot load such file errors

When I run:

bundle exec rspec spec/requests/static_pages_spec.rb:

I get:

c:\Sites\sample_app>bundle exec rspec spec/requests/static_pages_spec.rb
C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/conf
iguration.rb:746:in `load': cannot load such file -- c:/Sites/spec/requests/stat
ic_pages_spec.rb (LoadError)
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

I'm getting a similar error to the one contained in this post, however the solution proposed doesn't work for me.

spec with guard, rails 3.1.1, and ruby 1.9.3 getting cannot load such file errors

I've run bundle install and rails generate rspec:install but the error remains. All the files are in their correct spots, and nothing has changed since last night, so I'm not sure what has happened.

Any light shed on the situation would be greatly appreciated!

Upvotes: 2

Views: 4020

Answers (2)

Fernando
Fernando

Reputation: 41

Make sure that you are executing the bundle exec rspec spec/.... command from the app root directory. If you run the command from a sub-directory, you will get this error.

Upvotes: 2

Andreas Heim
Andreas Heim

Reputation: 581

It seems like rspec does not care that you stand in c:\sites\sample_app, as it tries to load

c:/Sites/spec/requests/static_pages_spec.rb 

Try to run rspec with an absolute path:

 bundle exec rspec c:/Sites/sample_app/spec/requests/static_pages_spec.rb 

Upvotes: 4

Related Questions