rspec-expectations
rspec-expectations copied to clipboard
Compound comparison matcher
Subject of the issue
There is no way to do compound comparisons in an expectation.
Steps to reproduce
expect(rand(5) + 1).to be(> 0).and be <= 6
Expected behavior
Test Pass
Actual behavior
unexpected '>'
expect(rand(5) + 1).to be.>(0).and be <= 6
worked quite fine:
is expected to be > 0 and be <= 6
Operators in Ruby are methods, so as @pirj points out there is a way to make this work, but you have the brackets in the wrong place to delegate operators, this also works (note the after to):
expect(rand(5) + 1).to (be > 0).and be <= 6