Prev | Current Page 296 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


?– Note It??™s also important to note that, like Ruby itself, case does matter when comparing strings. "Kevin"
is not equal to "kevin". When you want to ignore case in your tests, you should upcase or downcase both
strings first.
We already showed an example of this method at the start of this section, but since it??™s so
commonly used, we??™ll provide another quick one:
# test_artest.rb Unit Test example
require 'artest'
require 'test/unit'
class TestArtest < Test::Unit::TestCase
def test_simple
temp = Artest.new
CHAPTER 6 ?–  ACTIVE RECORD TESTING AND DEBUGGING 131
assert_equal(temp.appreciate(1).to_s, nil)
end
end
assert_in_delta
Computers have always had a little bit of trouble accurately dealing with floating point values.
This method allows you to test that a given floating point value is within a given range of another
floating point value. It??™s up to you, as the application developer, to determine an acceptable
range for floating point accuracy.
This method accepts four parameters: The first is the expected floating point value you
want to test against.


Pages:
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308