Prev | Current Page 307 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

new
CHAPTER 6 ?–  ACTIVE RECORD TESTING AND DEBUGGING 137
assert_throws :awesome do
throw :awesome if temp.appreciate(1) == "Kevin is great!"
end
end
end
assert_send
The assert_send method checks that a send command executed with the given values returns
a value of true. The method accepts two parameters: an array that contains the details of the
send method and an optional message to display in the event that the assertion fails.
The important thing to remember is that the details of the send method are sent as an array.
The array should contain the object that will receive the send call, the method you intend to
execute for the object, and the arguments you are going to pass to the method.
In our example, we test that our temp object has a method called appreciate, which responds
properly when passed a valid ID from our database (because we are returning nil when an ID is
not found and nil equates to false in a Boolean comparison, if we pass an invalid ID via our
send command our assertion will fail).
# test_artest.


Pages:
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319