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 302 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


The key thing to keep in mind is that this test simply checks that the regular expression
has at least one match in the given string. In our example, we check that the username we
expect is a part of the return value of our method call.
# test_artest.rb Unit Test example
require 'artest'
require 'test/unit'
class TestArtest < Test::Unit::TestCase
def test_simple
temp = Artest.new
assert_match /Kevin/, temp.appreciate(1)
end
end
assert_no_match
This method is simply the inverse of the assert_match method, the big difference being that
the test will pass so long as the given regular expression cannot be found within the given
string. Therefore, even though the regular expression match technically fails, the assertion
passes.
In our example, we use a regular expression looking for digits; if any are found in our
response, our test will fail.
# test_artest.rb Unit Test example
require 'artest'
require 'test/unit'
class TestArtest < Test::Unit::TestCase
def test_simple
temp = Artest.new
assert_no_match /\d+/, temp.


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