Sha256: 31209f3a48bf7728e66bc6ca335d2e0e5c30e8f3b89934907e52225b79489870

Contents?: true

Size: 806 Bytes

Versions: 11

Compression:

Stored size: 806 Bytes

Contents

require 'minitest/autorun'
require 'json'
require 'fast_haml'

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

11 entries across 11 versions & 1 rubygems

Version Path
fast_haml-0.1.10 haml_spec_test.rb
fast_haml-0.1.9 haml_spec_test.rb
fast_haml-0.1.8 haml_spec_test.rb
fast_haml-0.1.7 haml_spec_test.rb
fast_haml-0.1.6 haml_spec_test.rb
fast_haml-0.1.5 haml_spec_test.rb
fast_haml-0.1.4 haml_spec_test.rb
fast_haml-0.1.3 haml_spec_test.rb
fast_haml-0.1.2 haml_spec_test.rb
fast_haml-0.1.1 haml_spec_test.rb
fast_haml-0.1.0 haml_spec_test.rb