Sha256: 5755ac43f5a6900a563111ce8d48d85f165e7b8959c085801c7e2adbcc82acf9
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# # Testing OpenWFE # # John Mettraux at openwfe.org # require 'test/unit' require 'openwfe/utils' class LookupAttTest < Test::Unit::TestCase #def setup #end #def teardown #end def test_0 l0 = [ {"name"=>"companyA","DunsNr" => "JGE4753"}, {"name"=>"companyB","DunsNr" => "ZUTE8555"}, {"name"=>"companyC","DunsNr" => "GTI6775"}, {"name"=>"companyD","DunsNr" => "XUE6755"} ] h0 = { "supplierList" => l0 } do_lookup_test( h0, "supplierList", l0) do_lookup_test( h0, "supplierList.1", {"name"=>"companyB","DunsNr" => "ZUTE8555"}) do_lookup_test( h0, "supplierList.1.DunsNr", "ZUTE8555") do_has_attribute_test( h0, "supplierList.1.DunsNr", true) do_has_attribute_test( h0, "supplierList.1.Whatever", false) do_has_attribute_test( h0, "supplierList.whatever", false) do_has_attribute_test( h0, "whatever", false) h1 = { "supplierList" => l0.to_s } do_lookup_test( h1, "supplierList.1.DunsNr", nil) do_has_attribute_test( nil, "whatever", false) do_has_attribute_test( {}, "whatever", false) do_has_attribute_test( [], "whatever", false) do_has_attribute_test( "string", "whatever", false) do_has_attribute_test( [ nil, nil ], "1.name", false) end def test_1 h = { "0" => [ "a", "A" ], "1" => { "b" => "B"} } do_lookup_test(h, "0", [ "a", "A" ]) do_lookup_test(h, "1.b", "B") do_has_attribute_test(h, "0", true) do_has_attribute_test(h, "1.b", true) end protected def do_lookup_test (container, expression, expected_value) assert_equal( expected_value, OpenWFE::lookup_attribute(container, expression)) end def do_has_attribute_test (container, expression, expected_boolean) assert_equal( expected_boolean, OpenWFE::has_attribute?(container, expression)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruote-0.9.19 | test/lookup_att_test.rb |