require File.expand_path '../test_helper.rb', __FILE__ class TestBadgerfish < Minitest::Test def setup @parser = Badgerfish::Parser.new end def test_badgerfish_ning_com_nr_2 xml = 'bob' expected_json = <<-json { "alice":{ "$":"bob" } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_3 xml = 'charlieedgar' expected_json = <<-json { "alice":{ "bob":{ "$":"charlie" }, "david":{ "$":"edgar" } } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_4 xml = 'charliedavid' expected_json = <<-json { "alice":{ "bob":[ { "$":"charlie" }, { "$":"david" } ] } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_5 xml = 'bob' expected_json = <<-json { "alice":{ "@charlie":"david", "$":"bob" } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_7 xml = 'bob' expected_json = <<-json { "alice":{ "@xmlns":{ "$":"http://some-namespace" }, "$":"bob" } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_8 xml = <<-xml bob xml expected_json = <<-json { "alice":{ "@xmlns":{ "$":"http://some-namespace", "charlie":"http://some-other-namespace" }, "$":"bob" } } json assert_badgerfish xml, expected_json end def test_badgerfish_ning_com_nr_9 skip("child node namespaces not supported yet") xml = <<-xml david frank xml expected_json = <<-json { "alice":{ "@xmlns":{ "$":"http://some-namespace", "charlie":"http://some-other-namespace" }, "bob":{ "@xmlns":{ "$":"http://some-namespace", "charlie":"http://some-other-namespace" }, "$":"david" }, "charlie:edgar":{ "$":"frank", "@xmlns":{ "$":"http://some-namespace", "charlie":"http://some-other-namespace" } } } } json assert_badgerfish xml, expected_json end end