Self-answer. So far, I have found one sensible application. I can hack this to work in 1.9.2 with just a few lines:
describe "Mathematics" do
it "2 + 2 != 5" do
(2+2).should != 5
end
end
Prior to 1.9.2 Ruby, this means:
describe "Mathematics" do
it "2 + 2 != 5" do
((2+2).should == 5) ? false : true
end
end
But as we remove the return value, we have no way to distinguish it == 5from != 5the Ruby query for the parsing tree. PositiveOperatorMatcher#==(5)just raise an exception ExpectationNotMetError, and it will be so. It seems that should !~ /pattern/, should !be_somethingetc. Also may work.
This is a slight improvement over (2+2).should_not == 5, but not very large. And there is no way to crack it further to get things like (2+2).should be_even or be_odd.
, Ruby . Ruby. , ?
, ! !=/!~ . !((2+2).should == 5) #== !. #== , ! , . , . ( , , !self - )