Sha256: cb42ba46d3b76a24f3758d87a08cb05eafbed70308bdee385a0aa647db244b09

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

describe Hamlit::Engine do
  describe 'script' do
    it 'renders one-line script' do
      assert_render(<<-HAML, <<-HTML)
        = 1 + 2
        %span= 3 * 4
      HAML
        3
        <span>12</span>
      HTML
    end

    it 'renders multi-lines script' do
      assert_render(<<-HAML, <<-HTML)
        %span
          = 1 + 2
          4 / 2
          %a= 3 - 4
      HAML
        <span>
        3
        4 / 2
        <a>-1</a>
        </span>
      HTML
    end

    it 'renders block script' do
      assert_render(<<-HAML, <<-HTML)
        = 3.times do |i|
          = i
        4
      HAML
        0
        1
        2
        3
        4
      HTML
    end

    it 'renders tag internal block script' do
      assert_render(<<-HAML, <<-HTML)
        %span
          = 1.times do |i|
            = i
      HAML
        <span>
        0
        1
        </span>
      HTML
    end

    it 'accepts a continuing script' do
      assert_render(<<-HAML, <<-HTML)
        - def foo(a, b); a + b; end
        = foo(1,
        2)
      HAML
        3
      HTML
    end

    it 'renders !=' do
      assert_render(<<-HAML, <<-HTML, escape_html: true)
        != '<"&>'
        != '<"&>'.tap do |str|
          -# no operation
      HAML
        <"&>
        <"&>
      HTML
    end

    it 'renders &=' do
      assert_render(<<-HAML, <<-HTML, escape_html: false)
        &= '<"&>'
        &= '<"&>'.tap do |str|
          -# no operation
      HAML
        &lt;&quot;&amp;&gt;
        &lt;&quot;&amp;&gt;
      HTML
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamlit-0.1.3 spec/hamlit/engine/script_spec.rb
hamlit-0.1.2 spec/hamlit/engine/script_spec.rb
hamlit-0.1.1 spec/hamlit/engine/script_spec.rb
hamlit-0.1.0 spec/hamlit/engine/script_spec.rb