You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it'correctly fails the spec'doexpect{record.save}.tochange{record.created_at}.from(nil).to(be_within(1.second).of(Time.now))end
Workarounds
There are several workaround for this currently:
Move the predicate check into the change block
it'fails as expected'dohash={a: 1}expect{hash.clear}.tochange{hash.empty?}.tofalseend
The above tests was modified slightly so that the result of the change block is accurate. Also, instead of .to false it could also have been written .to be_false and the test would still have failed as expected, stating it was now true.
@samphippen the error message for most of the other matchers when chained on change are pretty awful; this holds true for be_false, be_true, and be_within.
A very similar issue was brought up in #161. I tested both on 2.14.0.rc1 and 2.13.1.
When chaining the
be_xxxx
matcher on the expect change the test always passes.Example Issue
Here's a very simple and contrived example which clearly shows the false positive result:
A more typical example may be something like:
Inconsistent behavior
However, the
be
matchers (be_true
andbe_false
) work as expected, though the error message could be improved a tad.The
be_within
matcher also works as expect:Workarounds
There are several workaround for this currently:
Move the predicate check into the change block
The above tests was modified slightly so that the result of the
change
block is accurate. Also, instead of.to false
it could also have been written.to be_false
and the test would still have failed as expected, stating it was nowtrue
.Do not use expect change
The text was updated successfully, but these errors were encountered: