Ji Mun
Ji Mun

Reputation: 1830

RSpec No example found

For some reason, RSpec is not recognizing assertions in one of my spec files - but runs the print statement around it.

To start the spec test, on the terminal:

rspec spec/lib/slots_scheduler_spec.rb

Part of the spec file that asserts... (is part of a loop)

print "#{slots_result[0].date} #{slot.date}\n"
slots_result[0].date.should == slot.date

And what I see on the console...

....
2012-11-18 2012-11-11
2012-11-25 2012-11-11
No examples found.


Finished in 0.00005 seconds
0 examples, 0 failures

If something is wrong, I expect some other message than '0 examples, 0 failures'. Why are my tests ignored like this?

Upvotes: 2

Views: 3708

Answers (1)

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84343

You Haven't Defined an Example Group

Your code, as posted above, has no example groups. Example groups require a describe or context block, and a specify or it block for each test in order to work.

Your print statements work because they are valid Ruby. However, the RSpec DSL requires more from you before it will result in an actual test being performed.

Upvotes: 3

Related Questions