Sha256: a4dba1adcc955c4c78f83e587f9b2e9c774bd30a5389cc59cdca7102a0a3cce1

Contents?: true

Size: 910 Bytes

Versions: 21

Compression:

Stored size: 910 Bytes

Contents

require 'hamlit'
require 'unindent'

module HamlitSpecHelper
  def parse_string(str)
    Hamlit::Parser.new.call(str)
  end

  def render_string(str, options = {})
    eval Hamlit::Engine.new(options).call(str)
  end

  def assert_render(haml, html, options = {})
    haml = haml.unindent
    html = html.unindent

    expect(render_string(haml, options)).to eq(html)
  end

  def assert_parse(haml, &block)
    haml = haml.unindent
    ast  = block.call

    expect(parse_string(haml)).to eq(ast)
  end

  def assert_compile(before, after)
    result = described_class.new.call(before)
    expect(result).to eq(after)
  end
end

RSpec.configure do |config|
  config.include HamlitSpecHelper

  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hamlit-1.5.3 spec/spec_helper.rb
hamlit-1.5.2 spec/spec_helper.rb
hamlit-1.5.1 spec/spec_helper.rb
hamlit-1.5.0 spec/spec_helper.rb
hamlit-1.4.7 spec/spec_helper.rb
hamlit-1.4.6 spec/spec_helper.rb
hamlit-1.4.5 spec/spec_helper.rb
hamlit-1.4.3 spec/spec_helper.rb
hamlit-1.4.2 spec/spec_helper.rb
hamlit-1.4.1 spec/spec_helper.rb
hamlit-1.3.2 spec/spec_helper.rb
hamlit-1.3.1 spec/spec_helper.rb
hamlit-1.3.0 spec/spec_helper.rb
hamlit-1.2.1 spec/spec_helper.rb
hamlit-1.2.0 spec/spec_helper.rb
hamlit-1.1.1 spec/spec_helper.rb
hamlit-1.1.0 spec/spec_helper.rb
hamlit-1.0.0 spec/spec_helper.rb
hamlit-0.6.2 spec/spec_helper.rb
hamlit-0.6.1 spec/spec_helper.rb