Fixed rendering of URIs with port number; moved match.rb to test_helper (where it belongs)

This commit is contained in:
Alexey Verkhovsky 2005-01-16 16:04:45 +00:00
parent 832cfdf605
commit 178f3f53ee
4 changed files with 35 additions and 19 deletions

View file

@ -32,6 +32,7 @@ class WikiServiceWithNoPersistence
end
end
# With the new cookies infrastructure, @response.cookies['foo'] is no good anymore.
# Pending implementation in Rails, here is a convenience method for accessing cookies from a test
@ -46,3 +47,24 @@ module ActionController
end
end
end
# This module is to be included in unit tests that involve matching chunks.
# It provides a easy way to test whether a chunk matches a particular string
# and any the values of any fields that should be set after a match.
module ChunkMatch
# Asserts a number of tests for the given type and text.
def match(type, test_text, expected)
pattern = type.pattern
assert_match(pattern, test_text)
pattern =~ test_text # Previous assertion guarantees match
chunk = type.new($~)
# Test if requested parts are correct.
for method_sym, value in expected do
assert_respond_to(chunk, method_sym)
assert_equal(value, chunk.method(method_sym).call, "Checking value of '#{method_sym}'")
end
end
end