Colin ShieldColin Shield
Standup 6/9/2009 Spring Cleaning. rspec should == useless
edit Posted by Colin Shield on Tuesday June 09, 2009 at 04:20PM

Ask for help

Using Rspec 1.2.6 and an expression of some desired behavior such as this:

it "should score 0" do
  score = 0
  score.should == 0
end

Will sometimes result in a ruby warning:

warning: useless use of == in void context

There was a little confusion as to why this warning was sometimes appearing. It turns out that the warning appears when the command ruby -w is used to run the spec rather than spec. This seems to be the case when rake is run for a non rails project, say a plugin.