Sha256: c87619d6f74c0b9458852310fd7c14f95eb46bccc8e05e2297f18f69f16bc927

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# -*- coding: utf-8 -*-
require "test_helper"

class EnvironmentTest < Sablon::TestCase
  def test_converts_symbol_keys_to_string_keys
    context = Sablon::Context.transform_hash(a: 1, b: { c: 2, "d" => 3 })
    assert_equal({ "a" => 1, "b" => { "c" => 2, "d" => 3 } }, context)
  end

  def test_recognizes_wordml_keys
    context = Sablon::Context.transform_hash("word_ml:mykey" => "<w:p><w:p>", "otherkey" => "<nope>")
    assert_equal({ "mykey" => Sablon.content(:word_ml, "<w:p><w:p>"),
                   "otherkey" => "<nope>"}, context)
  end

  def test_recognizes_html_keys
    context = Sablon::Context.transform_hash("html:mykey" => "**yay**", "otherkey" => "<nope>")
    assert_equal({ "mykey" => Sablon.content(:html, "**yay**"),
                   "otherkey" => "<nope>"}, context)
  end

  def test_does_not_wrap_html_and_wordml_with_nil_value
    context = Sablon::Context.transform_hash("html:mykey" => nil, "word_ml:otherkey" => nil, "normalkey" => nil)
    assert_equal({ "mykey" => nil,
                   "otherkey" => nil,
                   "normalkey" => nil}, context)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sablon-0.1.1 test/context_test.rb
sablon-0.1.0 test/context_test.rb
sablon-0.0.22 test/context_test.rb