Sha256: de7eb57b00e9387b3934c40039b101046db897b65cad787c872dcfc6067ba869

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

require 'test_helper'

class TestJason < MiniTest::Unit::TestCase
  test '#render without binding' do
    template = <<-EOF
      foo: bar
      baz:
        % if true
          - quz
        - quuz
    EOF
    
    assert_equal({'foo' => 'bar', 'baz' => ['quz', 'quuz']}, JSON.load(Jason.render(template)))
  end
  
  test '#render with binding' do
    test_string = 'bar'
    template = <<-EOF
      foo: <%= test_string %>
    EOF
    
    assert_equal({'foo' => 'bar' }, JSON.load(Jason.render(template, binding)))
  end
  
  test '#compile' do
    test_string = 'bar'
    template = <<-EOF
      foo: <%= test_string %>
    EOF
    
    assert_equal({'foo' => 'bar' }, JSON.load(eval(Jason.compile(template))))
  end
end

puts Jason.render(<<-EOS
test:
  % if true
    - foo
  - bar
EOS
)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jason-0.2.0 test/test_jason.rb