Any special assertion to test if the resulting integer lies within a range
Posted
by
barerd
on Stack Overflow
See other posts from Stack Overflow
or by barerd
Published on 2012-04-04T17:26:29Z
Indexed on
2012/04/04
17:29 UTC
Read the original article
Hit count: 228
ruby
|unit-testing
I would like to test if an instance variable lies in a range of numbers. I solved the problem by using assert_in_delta but would like to know if there is a formal assertion for this.
#part of the tested class
def initialize(value = 70 + rand(30))
@value = value
end
#test_value.rb
class ValueTestCase < Test::Unit::TestCase
def test_if_value_in_range
assert_in_delta(85, p.value, 15)
end
end
© Stack Overflow or respective owner