SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 299 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


assert_nothing_raised
This is simply the inverse to the assert_raised method; it checks that no exceptions are raised
within the block.
The interesting thing here is that this assertion acts much like a transaction wrapper, where
any exception within the block will cause the entire method to fail.
In our example, we take multiple steps, most of which will evaluate correctly, but because we
include a call to a method with an ID that is not in our database, an ActiveRecord::RecordNotFound
exception is thrown and, therefore, causes our entire assertion block to fail.
# test_artest.rb Unit Test example
require 'artest'
require 'test/unit'
class TestArtest < Test::Unit::TestCase
def test_simple
assert_nothing_raised do
t = 100.0
a = t * 50.0
temp = Artest.new
assert_in_delta(6.50, temp.earnedmoney(1000), 0.05)
end
end
end
assert_instance_of
This method just checks if a given object is an instance of a given class. Calling the assert_
instance_of method is really the equivalent of calling the instance_of? Ruby method.


Pages:
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6