Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rspec "cannot load such file"

Running rspec for the first time with the Rails tutorial, p. 95. Getting this output:

    david@david-desktop:~/rails_projects/sample_app1$ bundle exec rspec /spec/requests/static_pages_spec.rb
/home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load': cannot load such file -- /spec/requests/static_pages_spec.rb (LoadError)
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
    from /home/david/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2nded/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Here is Gemfile:

    source 'https://rubygems.org'

gem 'rails', '3.2.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.9.0'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platform => :ruby
end

gem 'jquery-rails'

group :test do
  gem 'capybara', '1.1.2'
end

Have already done the rails generate rspec:install and rails generate integration_test static_pages commands. Ideas?

like image 372
dave104 Avatar asked Jan 02 '13 23:01

dave104


2 Answers

Drop the leading slash in the filename:

bundle exec rspec spec/requests/static_pages_spec.rb
like image 80
Chris Salzberg Avatar answered Nov 25 '22 15:11

Chris Salzberg


Just FYI - I have also experienced this when my spec file wasn't formatted properly. I was missing a "DO"

like image 39
jffgrdnr Avatar answered Nov 25 '22 15:11

jffgrdnr