Understanding Failure

To try your specs, run the rspec command from your project directory. RSpec will look inside the spec subdirectory for files named «something»_spec.rb and run them:

 $ ​​rspec
 F
 
 Failures:
 
  1) An ideal sandwich is delicious
  Failure/Error: sandwich = Sandwich.new(’delicious’, [])
 
  NameError:
  uninitialized constant Sandwich
  # ./spec/sandwich_spec.rb:4:in ‘block (2 levels) in <top (required)>’
 
 Finished in 0.00076 seconds (files took 0.08517 seconds to load)
 1 example, 1 failure
 
 Failed examples:
 
 rspec ./spec/sandwich_spec.rb:3 # An ideal sandwich is delicious

RSpec gives us a detailed report showing which spec failed, the line of code where the error occurred, and a description of the problem. ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.