Sha256: d7eaeeed2a23cd5258de9ac313665335177ec6bb3e4543da40bea3d0978ec449

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

describe Hamlit::Engine do
  describe 'syntax error' do
    it 'raises syntax error for empty =' do
      expect { render_string('=  ') }.to raise_error(
        Hamlit::SyntaxError,
        "There's no Ruby code for = to evaluate.",
      )
    end

    it 'raises syntax error for illegal indentation' do
      expect { render_string(<<-HAML.unindent) }.
        %a
            %b
      HAML
        to raise_error(Hamlit::SyntaxError, 'inconsistent indentation: 2 spaces used for indentation, but the rest of the document was indented using 4 spaces')
    end

    it 'raises syntax error for illegal indentation' do
      expect { render_string(<<-HAML.unindent) }.
        %a
         %b
      HAML
        to raise_error(Hamlit::SyntaxError, 'inconsistent indentation: 2 spaces used for indentation, but the rest of the document was indented using 1 spaces')
    end

    it 'raises syntax error which has correct line number in backtrace' do
      begin
        render_string(<<-HAML.unindent)
          %1
            %2
            %3
            %4
          %5
            %6
            %7
             %8 this is invalid indent
          %9
        HAML
      rescue Hamlit::SyntaxError => e
        if e.respond_to?(:backtrace_locations)
          line_number = e.backtrace_locations.first.to_s.match(/:(\d+):/)[1]
          expect(line_number).to eq('8')
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hamlit-0.3.3 spec/hamlit/engine/error_spec.rb
hamlit-0.3.2 spec/hamlit/engine/error_spec.rb
hamlit-0.3.1 spec/hamlit/engine/error_spec.rb
hamlit-0.3.0 spec/hamlit/engine/error_spec.rb
hamlit-0.2.0 spec/hamlit/engine/error_spec.rb
hamlit-0.1.3 spec/hamlit/engine/error_spec.rb
hamlit-0.1.2 spec/hamlit/engine/error_spec.rb
hamlit-0.1.1 spec/hamlit/engine/error_spec.rb
hamlit-0.1.0 spec/hamlit/engine/error_spec.rb