[rspec-users] should !=

Pat Maddox pergesu at gmail.com
Thu Oct 9 20:07:51 EDT 2008


"Mark Wilden" <mark at mwilden.com> writes:

> I expected 'should !=' to act the same as 'should_not =='. That turned out to be incorrect (by design?):
>
> require 'spec'
> require 'spec/rails'
>
> describe "using 'should !='" do
>   it "seems to treat != as the same as ==" do
>     1.should != 1 # passes
>     1.should != 2 # fails
>   end
> end

Sorry for the short message, but yeah this is known.  You can search the
mailing list archives and the tracker for other emails.  Basically, Ruby
doesn't let us do this, because it translates
should != 1
into
!(should == 1)
and since (should == 1) is a passing expectation, the thing passes.

You can get around it by using paresetree or a similar technique but
it's sloooooooow thus has not become a part of rspec.

Pat


More information about the rspec-users mailing list