mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Expand the exception test into multiple tests.
This commit is contained in:
parent
2f9baa6a31
commit
eca9a4059b
1 changed files with 4 additions and 5 deletions
|
@ -733,15 +733,14 @@ HAML
|
|||
assert_equal("<a b='2' />\nc\n", render("%a{'b' => 1 + 1}/\n= 'c'\n"))
|
||||
end
|
||||
|
||||
def test_exceptions
|
||||
EXCEPTION_MAP.each do |key, value|
|
||||
define_method("test_exception (#{key.inspect})") do
|
||||
begin
|
||||
render(key, :filename => "(exception test for #{key.inspect})")
|
||||
render(key, :filename => __FILE__)
|
||||
rescue Exception => err
|
||||
value = [value] unless value.is_a?(Array)
|
||||
expected_message, line_no = value
|
||||
line_no ||= key.split("\n").length
|
||||
line_reported = err.backtrace[0].gsub(/\(.+\):/, '').to_i
|
||||
|
||||
if expected_message == :compile
|
||||
assert_match(/^compile error\n/, err.message, "Line: #{key}")
|
||||
|
@ -749,7 +748,7 @@ HAML
|
|||
assert_equal(expected_message, err.message, "Line: #{key}")
|
||||
end
|
||||
|
||||
assert_equal(line_no, line_reported, "Line: #{key}")
|
||||
assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, err.backtrace[0], "Line: #{key}")
|
||||
else
|
||||
assert(false, "Exception not raised for\n#{key}")
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue