test/jini_test.rb in jini-0.0.7 vs test/jini_test.rb in jini-0.0.8

- old
+ new

@@ -42,10 +42,20 @@ .at(1) .to_s ) end + def test_at_raise_invalid_path + assert_raises(Jini::InvalidPath) do + Jini.new(PARENT) + .add_node(CHILD) + .selection + .at(3) + .to_s + end + end + def test_remove_path assert_equal( 'parent/toy', Jini.new(PARENT) .add_node(CHILD) @@ -63,10 +73,20 @@ .add_attr('key', 'value') .to_s ) end + def test_add_attrs_success + assert_equal( + 'parent/child@toy', + Jini.new(PARENT) + .add_node(CHILD) + .add_attrs('toy') + .to_s + ) + end + def test_all_success assert_equal( '/parent/child/*', Jini.new .add_node(PARENT) @@ -75,11 +95,11 @@ .to_s ) end def test_all_fail - assert_raises do + assert_raises(Jini::InvalidPath) do Jini.new .add_node(PARENT) .add_attr('key', 'value') .all end @@ -110,14 +130,14 @@ .remove_attr('age') .to_s ) end - def test_add_all + def test_add_nodes assert_equal( 'parent//children', - Jini.new(PARENT).add_all('children').to_s + Jini.new(PARENT).add_nodes('children').to_s ) end def test_selection_success assert_equal( @@ -128,11 +148,11 @@ .to_s ) end def test_selection_fail - assert_raises do + assert_raises(Jini::InvalidPath) do Jini.new .add_node(PARENT) .add_node(CHILD) .add_attr('k', 'v') .selection @@ -166,7 +186,41 @@ Jini.new(PARENT) .add_node(CHILD) .gt('toys', 10) .to_s ) + end + + def test_add_property + assert_equal( + 'parent/child/property()', + Jini.new(PARENT) + .add_node(CHILD) + .add_property('property') + .to_s + ) + end + + def test_to_s_not_raised + Jini.new(PARENT) + .add_node(CHILD) + .add_node(PARENT) + .add_node(CHILD) + .add_node(PARENT) + .add_node(CHILD) + .add_attr('key', 'value') + .add_node(PARENT) + .or('a', 'b') + .add_node(CHILD) + .to_s + end + + def test_to_s_raised_invalid_path + assert_raises(Jini::InvalidPath) do + Jini.new(PARENT) + .add_node(CHILD) + .or('toy', 'animal') + .add_node('p arent') + .to_s + end end end