Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does rspec have anything more specific than target.should be < 6?

Tags:

ruby

rspec

http://cheat.errtheblog.com/s/rspec/ has for inequalities (such as less than or greater than)

target.should be < 6 

Has anything better been created since the cheat sheet was created?

like image 235
Andrew Grimm Avatar asked Jul 26 '11 11:07

Andrew Grimm


2 Answers

In RSpec's new expectation syntax, you would express it as:

expect(target).to be < 6 
like image 51
Charles Worthington Avatar answered Sep 17 '22 20:09

Charles Worthington


This is still the accepted way to handle this test. It's best to use >, <, and == in my opinion for numerical comparisons -- it's clearer.

like image 24
mrb_bk Avatar answered Sep 21 '22 20:09

mrb_bk