describe Hamlit::Engine do describe 'tag' do it 'renders one-line tag' do assert_render(<<-HAML, <<-HTML) %span hello HAML hello HTML end it 'renders multi-line tag' do assert_render(<<-HAML, <<-HTML) %span hello HAML hello HTML end it 'renders a nested tag' do assert_render(<<-HAML, <<-HTML) %span %b hello %i %small world HAML hello world HTML end it 'renders multi-line texts' do assert_render(<<-HAML, <<-HTML) %span %b hello world HAML hello world HTML end it 'skips empty lines' do assert_render(<<-HAML, <<-HTML) %span %b hello HAML hello HTML end it 'renders classes' do assert_render(<<-HAML, <<-HTML) %span.foo-1.bar_A hello HAML hello HTML end it 'renders ids only last one' do assert_render(<<-HAML, <<-HTML) %span#Bar_0#bar- hello HAML hello HTML end it 'renders ids and classes' do assert_render(<<-HAML, <<-HTML) %span#a.b#c.d hello HAML hello HTML end it 'renders implicit div tag starting with id' do assert_render(<<-HAML, <<-HTML) #hello.world HAML
HTML end it 'renders implicit div tag starting with class' do assert_render(<<-HAML, <<-HTML) .world#hello foo HAML
foo
HTML end it 'renders large-case tag' do assert_render(<<-HAML, <<-HTML) %SPAN foo HAML foo HTML end it 'renders h1 tag' do assert_render(<<-HAML, <<-HTML) %h1 foo HAML

foo

HTML end it 'renders tag including hyphen or underscore' do assert_render(<<-HAML, <<-HTML) %-_ foo HAML <-_>foo HTML end it 'does not render silent script just after a tag' do assert_render(<<-HAML, <<-HTML) %span- raise 'a' HAML raise 'a' HTML end it 'renders a text just after attributes' do assert_render(<<-HAML, <<-HTML) %span{a: 2}a HAML a HTML end it 'strips a text' do assert_render(<<-HAML, <<-HTML) %span foo HAML foo HTML end it 'ignores spaces after tag' do assert_render("%span \n a", <<-HTML) a HTML end it 'parses self-closing tag' do assert_render(<<-HAML, <<-HTML, format: :xhtml) %div/ %div HAML
HTML end it 'removes outer whitespace by >' do assert_render(<<-HAML, <<-HTML) %span> a %span b %span c %span> d %span e %span f HAML ab c d e f HTML end end end