Sha256: 9f3fbcb7ed3038915971ef8da34d6effd473ac9850f0810c705ca9328baf65db

Contents?: true

Size: 1.45 KB

Versions: 37

Compression:

Stored size: 1.45 KB

Contents

describe Hamlit::Engine do
  describe '.new' do
    subject { described_class.new(options) }

    let(:buffer)  { '_a' }
    let(:options) do
      {
        buffer:    buffer,
        generator: Temple::Generators::ArrayBuffer,
      }
    end

    it 'accepts generator valid options' do
      expect(subject.call('')).to eq(
        "#{buffer} = []; ; #{buffer} = #{buffer}.join",
      )
    end
  end

  describe '#call' do
    let(:haml) do
      <<-HAML.unindent
        !!! html

        %html
          %head
            %title Simple Haml
          %body
            %h1= 'header'
            - unless false
              %ul
                - for i in [1, 2, 3]
                  - if i
                    %li
                      %strong= 'hello'
                  - else
                    %li
                      %a{:href => i}= i
            - else
              %p last line
      HAML
    end
    let(:engine) { described_class.new }

    it 'generates code with the same lineno as a template' do
      lines = engine.call(haml).split("\n")
      expect(lines[0]).to include('DOCTYPE')
      expect(lines[6]).to include('header')
      expect(lines[7]).to include('unless')
      expect(lines[9]).to include('for i in')
      expect(lines[10]).to include('if i')
      expect(lines[12]).to include('hello')
      expect(lines[13]).to include('else')
      expect(lines[16]).to include('else')
      expect(lines[17]).to include('last line')
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
hamlit-1.7.2 spec/hamlit/engine_spec.rb
hamlit-1.7.1 spec/hamlit/engine_spec.rb
hamlit-1.7.0 spec/hamlit/engine_spec.rb
hamlit-1.6.7 spec/hamlit/engine_spec.rb
hamlit-1.6.6 spec/hamlit/engine_spec.rb
hamlit-1.6.5 spec/hamlit/engine_spec.rb
hamlit-1.6.4 spec/hamlit/engine_spec.rb
hamlit-1.6.3 spec/hamlit/engine_spec.rb
hamlit-1.6.2 spec/hamlit/engine_spec.rb
hamlit-1.6.1 spec/hamlit/engine_spec.rb
hamlit-1.6.0 spec/hamlit/engine_spec.rb
hamlit-1.5.9 spec/hamlit/engine_spec.rb
hamlit-1.5.8 spec/hamlit/engine_spec.rb
hamlit-1.5.7 spec/hamlit/engine_spec.rb
hamlit-1.5.6 spec/hamlit/engine_spec.rb
hamlit-1.5.5 spec/hamlit/engine_spec.rb
hamlit-1.5.4 spec/hamlit/engine_spec.rb
hamlit-1.5.3 spec/hamlit/engine_spec.rb
hamlit-1.5.2 spec/hamlit/engine_spec.rb
hamlit-1.5.1 spec/hamlit/engine_spec.rb