test/jini_test.rb in jini-1.1.5 vs test/jini_test.rb in jini-1.2.5

- old
+ new

@@ -281,24 +281,26 @@ .to_s ) end def test_nodes + nodes = Jini.new(PARENT) + .add_node(CHILD) + .add_attr('key', 'value') + .add_node('under_attr') + .add_nodes('many') + .at(3) + .nodes + assert_includes(nodes, 'under_attr') assert_equal( [].append( 'parent', 'child[@key="value"]', 'under_attr', 'many[3]' ), - Jini.new(PARENT) - .add_node(CHILD) - .add_attr('key', 'value') - .add_node('under_attr') - .add_nodes('many') - .at(3) - .nodes + nodes ) end def test_nodes_ctor assert_equal( @@ -326,8 +328,29 @@ Jini.new(PARENT) .add_node(CHILD) .count .to_s ) + end + + def test_from_xpath_success + x = '/parent/child[@toy="plane"]' + jini = Jini.new('/parent').add_node(CHILD).add_attr('toy', 'plane') + assert_nothing_raised do + Jini.from x + Jini.from jini.to_s + end + assert_equal Jini.from(x), Jini.from(jini.to_s) + end + + def test_from_xpath_fails + assert_raises(Jini::InvalidPath) { Jini.from '/parent/chld[' } + assert_raises(Jini::InvalidPath) { Jini.from '' } + end + + def test_method_missing_fails + assert_raises(Jini::UnsupportedOpertaion) do + Jini.new.bark + end end end # rubocop:enable Metrics/ClassLength