Reactormonk
Reactormonk

Reputation: 21700

Integer comparison matcher in rspec

Let's say x should be bigger than y. How do I encode this in rspec?

Upvotes: 14

Views: 7977

Answers (4)

nocache
nocache

Reputation: 1805

Using rspec 2.14 and the expectation syntax, this can be expressed like this:

expect(x).to be > y

Upvotes: 41

user1170055
user1170055

Reputation: 212

There are another ways to match inequalities:

x.should be_greater_than_or_equal_to(y)
x.should be_less_than_or_equal_to(y)
x.should be_greater_than(y)
x.should be_less_than(y)

Upvotes: 4

Jeremy Roman
Jeremy Roman

Reputation: 16355

Don't have RSpec on hand right now to verify, but I think this ought to work:

x.should > y

Upvotes: 7

user904990
user904990

Reputation:

wont this work for you?

x.should be > y

you could also try a more intuitive testing framework - Specular

then you can:

is?(x) > y
expect(x) > y
check(x) > y
etc.

Upvotes: 1

Related Questions