expect { … }.to become(…)
Published in
1 min readNov 20, 2015
Since wait_time helper has been removed from Capybara we have used to_become_true matcher for some time.
expect { allocation.reload.end_at == end_at }.to become_true
This works very good until it fails and the failure message is meaningless.
# expected #<Proc:0x007fc9a423b9a8@/spec/features/user_spec.rb:10> to become true
So we have come up with a better solution:
This way we can still use become(true), but we now have more options
expect { allocation.reload.end_at }.to become(end_at)
and pretty failure messages
# expected Fri, 04 Jan 2013 to become Sat, 05 Jan 2013