Sha256: fe416213f410612889971e554723d32860948cd56df0a81ae78627cd23936a36

Contents?: true

Size: 805 Bytes

Versions: 10

Compression:

Stored size: 805 Bytes

Contents

require 'minitest/autorun'
require 'json'
require 'faml'

class HamlTest < Minitest::Test
  contexts = JSON.parse(File.read(File.join(__dir__, 'haml-spec', 'tests.json')))
  contexts.each do |context|
    context[1].each do |name, test|
      define_method("test_spec: #{name} (#{context[0]})") do
        html             = test['html']
        haml             = test['haml']
        locals           = Hash[(test['locals'] || {}).map { |x, y| [x.to_sym, y] }]
        options          = Hash[(test['config'] || {}).map { |x, y| [x.to_sym, y] }]
        options[:format] = options[:format].to_sym if options.key?(:format)
        tilt = Tilt.new("#{name}.haml", nil, options) { haml }
        result = tilt.render(Object.new, locals)

        assert_equal html, result.strip
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
faml-0.6.0 haml_spec_test.rb
faml-0.5.1 haml_spec_test.rb
faml-0.5.0 haml_spec_test.rb
faml-0.4.2 haml_spec_test.rb
faml-0.4.1 haml_spec_test.rb
faml-0.4.0 haml_spec_test.rb
faml-0.3.6 haml_spec_test.rb
faml-0.3.5 haml_spec_test.rb
faml-0.3.4 haml_spec_test.rb
faml-0.3.3 haml_spec_test.rb