require 'spec_helper' class LineVerifier < StandardError def initialize super("raised at #{caller_locations(1, 1)[0].lineno}") end end module LineVerifierHelper extend RSpec::Matchers::DSL matcher :raised_at do |expected| match do |actual| actual == "raised at #{expected}" end end end RSpec.describe 'Faml::Compiler newline generation', type: :render do include LineVerifierHelper it do expect { render_string(<= raise LineVerifier HAML end it do expect { render_string(< %img HAML end it do expect { render_string(<<'HAML') }.to raise_error(LineVerifier, raised_at(3)) %div %span hello %span #{raise LineVerifier} %span world HAML end it do expect { render_string(<4\n") = [__LINE__, __LINE__, __LINE__].join(' ') %span= __LINE__ HAML end end end end