Running the specs in a single spec file

This never seems to work for me. I can run the specs using “bundle exec rspec”, but it doesnt work when I try to run the specs on a specific problem.

Here is one example of what happened whhen I try to run a specific file:

~/03b91885-npsandler-rspec-2 (master)$ bundle exec rspec 00_silly_blocks.rb
bundler: failed to load command: rspec (/Users/nathaniel/.rbenv/versions/2.3.1/bin/rspec)
LoadError: cannot load such file – /Users/nathaniel/03b91885-npsandler-rspec-2/00_silly_blocks.rb
/Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in load' /Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:inblock in load_spec_files’
/Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in each' /Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:inload_spec_files’
/Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in setup' /Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:inrun’
/Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in run' /Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:ininvoke’
/Users/nathaniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.2.3/exe/rspec:4:in <top (required)>' /Users/nathaniel/.rbenv/versions/2.3.1/bin/rspec:23:inload’
/Users/nathaniel/.rbenv/versions/2.3.1/bin/rspec:23:in `<top (required)>’

Hey Nathaniel,

Make sure you are specifying the correct file path to the spec file that you would like to run, not the file where you are writing your code:

bundle exec rspec spec/00_silly_blocks_spec.rb

HINT: You can run a single spec from a spec file by specifying the line number of where the code says describe:

bundle exec rspec spec/00_silly_blocks_spec.rb:29

1 Like

Hi there,

I’m getting the same error, expect I was running the spec on the spec file and still received the following error:

Hey Loralee,

Read my answer to Nathaniel’s question again carefully. The path you have given to the spec file is still incorrect causing the LoadError.

Keep up the great work!

Hey kevin,

I still get an error message when I use the / as you’ve done in your example above. See below

I get the error message even after I run bundle install.

Close! The slash is not the only missing piece. You need to specify the exact location of the spec file to be run, which includes the parent spec folder. So the final command should read:

bundle exec rspec spec/01_temperature_spec.rb