Sha256: bb6821968b361f57f8bd97195e7f5d7df2189acadf22e1cbf205f2894f9a66e9

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

RSpec.describe 'Indent', type: :render do
  it 'raises error if indent is wrong' do
    expect { render_string(<<HAML) }.to raise_error(Faml::IndentTracker::IndentMismatch) { |e|
%div
    %div
        %div
  %div
HAML
      expect(e.current_level).to eq(2)
      expect(e.indent_levels).to eq([0])
      expect(e.lineno).to eq(4)
    }
  end

  it 'raises error if the current indent is deeper than the previous one' do
    expect { render_string(<<HAML) }.to raise_error(Faml::IndentTracker::InconsistentIndent) { |e|
%div
  %div
      %div
HAML
      expect(e.previous_size).to eq(2)
      expect(e.current_size).to eq(4)
      expect(e.lineno).to eq(3)
    }
  end

  it 'raises error if the current indent is shallower than the previous one' do
    expect { render_string(<<HAML) }.to raise_error(Faml::IndentTracker::InconsistentIndent) { |e|
%div
    %div
      %div
HAML
      expect(e.previous_size).to eq(4)
      expect(e.current_size).to eq(2)
      expect(e.lineno).to eq(3)
    }
  end

  it 'raises error if indented with hard tabs' do
    expect { render_string(<<HAML) }.to raise_error(Faml::IndentTracker::HardTabNotAllowed)
%p
	%a
HAML
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faml-0.2.16 spec/render/indent_spec.rb
faml-0.2.15 spec/render/indent_spec.rb
faml-0.2.14 spec/render/indent_spec.rb