Sha256: fc78f32ddbdd33e7ccd104afe54ca4df2bd3d647759239c7200311e4b4c0f4e6
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
# encoding: UTF-8 require 'test_helper' class TestMember < Test::Unit::TestCase def member(key, value=nil, &block) JSONBuilder::Member.new(key, nil, value, &block) end def test_is_a_builder_value assert_equal JSONBuilder::Member, member(:hello, true).class end def test_key_as_symbol assert_equal '"hello": true', member(:hello, true).to_s end def test_key_as_unicoded_symbol assert_equal '"hellyé": true', member('hellyé', true).to_s end def test_key_as_string assert_equal '"hello": true', member('hello', true).to_s end def test_value_as_array assert_equal '"hello": [{"ruby":true}]', member('hello', [{ :ruby => true }]).to_s end def test_value_as_block assert_equal '"hello": "hi"', member('hello') { 'hi' }.to_s end def test_value_as_block_with_hash assert_equal '"hello": {"ruby":true}', member('hello') { { :ruby => true } }.to_s end def test_custom_class assert_equal '"hello": "olleh"', member('hello', Dozer.new('hello')).to_s end def test_double_quoted_value assert_equal '"hello": "\"Hello\" he said"', member('hello', '"Hello" he said').to_s end def test_without_key assert_raises(JSONBuilder::MissingKeyError) { member(nil, true).to_s } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json_builder-3.1.4 | test/member_test.rb |
json_builder-3.1.3 | test/member_test.rb |