Sha256: 14eeaf26b5c6ec7c858f486af089748838a6ae7fa5952e5ab0d8f4157efe9f48

Contents?: true

Size: 801 Bytes

Versions: 20

Compression:

Stored size: 801 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

20 entries across 20 versions & 1 rubygems

Version Path
faml-0.3.2 haml_spec_test.rb
faml-0.3.1 haml_spec_test.rb
faml-0.3.0 haml_spec_test.rb
faml-0.2.16 haml_spec_test.rb
faml-0.2.15 haml_spec_test.rb
faml-0.2.14 haml_spec_test.rb
faml-0.2.13 haml_spec_test.rb
faml-0.2.12 haml_spec_test.rb
faml-0.2.11 haml_spec_test.rb
faml-0.2.10 haml_spec_test.rb
faml-0.2.9 haml_spec_test.rb
faml-0.2.8 haml_spec_test.rb
faml-0.2.7 haml_spec_test.rb
faml-0.2.6 haml_spec_test.rb
faml-0.2.5 haml_spec_test.rb
faml-0.2.4 haml_spec_test.rb
faml-0.2.3 haml_spec_test.rb
faml-0.2.2 haml_spec_test.rb
faml-0.2.1 haml_spec_test.rb
faml-0.2.0 haml_spec_test.rb