1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/test/parser_test.rb

41 lines
1.2 KiB
Ruby
Raw Normal View History

require 'test_helper'
module Haml
class ParserTest < MiniTest::Unit::TestCase
test "should raise error for 'else' at wrong indent level" do
begin
parse("- if true\n #first\n text\n - else\n #second")
flunk("Should have raised a Haml::Error")
rescue Error => e
assert_equal Error.message(:bad_script_indent, 'else', 0, 1), e.message
end
end
test "should raise error for 'elsif' at wrong indent level" do
begin
parse("- if true\n #first\n text\n - elsif false\n #second")
flunk("Should have raised a Haml::Error")
rescue Error => e
assert_equal Error.message(:bad_script_indent, 'elsif', 0, 1), e.message
end
end
test "should raise error for 'else' at wrong indent level after unless" do
begin
parse("- unless true\n #first\n text\n - else\n #second")
flunk("Should have raised a Haml::Error")
rescue Error => e
assert_equal Error.message(:bad_script_indent, 'else', 0, 1), e.message
end
end
private
def parse(haml, options = nil)
options ||= Options.new
parser = Parser.new(haml, options)
parser.parse
end
end
end