spec/hamlit/engine/error_spec.rb in hamlit-1.6.3 vs spec/hamlit/engine/error_spec.rb in hamlit-1.6.4
- old
+ new
@@ -82,7 +82,54 @@
%div/
foo
HAML
to raise_error(Hamlit::SyntaxError, "Illegal nesting: nesting within a self-closing tag is illegal.")
end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(<<-HAML.unindent) }.
+ hello
+ world
+ HAML
+ to raise_error(Hamlit::SyntaxError, 'Illegal nesting: nesting within plain text is illegal.')
+ end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(<<-HAML.unindent) }.
+ %span hello
+ world
+ HAML
+ to raise_error(Hamlit::SyntaxError, "Illegal nesting: content can't be both given on the same line as %span and nested within it.")
+ end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(<<-HAML.unindent) }.
+ / hello
+ world
+ HAML
+ to raise_error(Hamlit::SyntaxError, 'Illegal nesting: nesting within a tag that already has content is illegal.')
+ end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(<<-HAML.unindent) }.
+ %span
+ %span
+ %span
+ HAML
+ to raise_error(Hamlit::SyntaxError, 'The line was indented 2 levels deeper than the previous line.')
+ end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(<<-HAML.unindent) }.
+ %span
+ %span
+ %span
+ HAML
+ to raise_error(Hamlit::SyntaxError, "Inconsistent indentation: 6 spaces used for indentation, but the rest of the document was indented using 4 spaces.")
+ end
+
+ it 'rejects illegal indentation' do
+ expect { render_string(' hello') }.
+ to raise_error(Hamlit::SyntaxError, 'Indenting at the beginning of the document is illegal.')
+ end
end
end