Sha256: a1011c45efcc285706a84052f9a58f3a3b827fe3d454a36a9cff74d74fedb92c

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

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

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

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

  def test_recognizes_markdown_keys
    transformed = Sablon::Context.transform({"markdown:mykey" => "**yay**", "otherkey" => "<nope>"})
    assert_equal({ "mykey"=>Sablon.content(:markdown, "**yay**"),
                   "otherkey"=>"<nope>"}, transformed)
  end

  def test_does_not_wrap_markdown_and_wordml_with_nil_value
    transformed = Sablon::Context.transform({"markdown:mykey" => nil, "word_ml:otherkey" => nil, "normalkey" => nil})
    assert_equal({ "mykey" => nil,
                   "otherkey" => nil,
                   "normalkey" => nil}, transformed)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sablon-0.0.19 test/context_test.rb
sablon-0.0.19.beta5 test/context_test.rb
sablon-0.0.19.beta4 test/context_test.rb
sablon-0.0.19.beta3 test/context_test.rb
sablon-0.0.19.beta2 test/context_test.rb
sablon-0.0.19.beta1 test/context_test.rb
sablon-0.0.18 test/context_test.rb
sablon-0.0.17 test/context_test.rb
sablon-0.0.16 test/context_test.rb
sablon-0.0.15 test/context_test.rb
sablon-0.0.14 test/context_test.rb
sablon-0.0.13 test/context_test.rb