diff --git a/.travis.yml b/.travis.yml index 493e215..b47788a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,15 @@ env: - JAVA_OPTS=-Djava.security.egd=file:/dev/urandom rvm: - - 2.3.3 - - 2.4.1 - - jruby-9.1.8.0 + - 2.2 + - 2.3 + - 2.4 + - jruby-9.1.15.0 + - 2.5 + +matrix: + allow_failures: + - rvm: 2.5 + +before_install: + - gem update bundler \ No newline at end of file diff --git a/lib/xpath/version.rb b/lib/xpath/version.rb index c9ba7cc..c5c398b 100644 --- a/lib/xpath/version.rb +++ b/lib/xpath/version.rb @@ -1,3 +1,3 @@ module XPath - VERSION = '2.1.0' + VERSION = '3.0.0.dev' end diff --git a/spec/union_spec.rb b/spec/union_spec.rb index c73e384..50b8091 100644 --- a/spec/union_spec.rb +++ b/spec/union_spec.rb @@ -9,7 +9,7 @@ @expr1 = XPath.generate { |x| x.descendant(:p) } @expr2 = XPath.generate { |x| x.descendant(:div) } @collection = XPath::Union.new(@expr1, @expr2) - @collection.expressions.should == [@expr1, @expr2] + @collection.expressions.should eq [@expr1, @expr2] end end @@ -20,7 +20,7 @@ @collection = XPath::Union.new(@expr1, @expr2) exprs = [] @collection.each { |expr| exprs << expr } - exprs.should == [@expr1, @expr2] + exprs.should eq [@expr1, @expr2] end end @@ -29,7 +29,7 @@ @expr1 = XPath.generate { |x| x.descendant(:p) } @expr2 = XPath.generate { |x| x.descendant(:div) } @collection = XPath::Union.new(@expr1, @expr2) - @collection.map { |expr| expr.expression }.should == [:descendant, :descendant] + @collection.map { |expr| expr.expression }.should eq [:descendant, :descendant] end end @@ -39,9 +39,9 @@ @expr2 = XPath.generate { |x| x.descendant(:div).where(x.attr(:id) == 'foo') } @collection = XPath::Union.new(@expr1, @expr2) @results = doc.xpath(@collection.to_xpath) - @results[0][:title].should == 'fooDiv' - @results[1].text.should == 'Blah' - @results[2].text.should == 'Bax' + @results[0][:title].should eq 'fooDiv' + @results[1].text.should eq 'Blah' + @results[2].text.should eq 'Bax' end end @@ -54,9 +54,9 @@ @xpath1 = @collection.where(XPath.attr(:id) == 'foo').to_xpath @xpath2 = @collection.where(XPath.attr(:id) == 'fooDiv').to_xpath @results = doc.xpath(@xpath1) - @results[0][:title].should == 'fooDiv' + @results[0][:title].should eq 'fooDiv' @results = doc.xpath(@xpath2) - @results[0][:id].should == 'fooDiv' + @results[0][:id].should eq 'fooDiv' end end diff --git a/spec/xpath_spec.rb b/spec/xpath_spec.rb index bd2f01a..2752c6e 100644 --- a/spec/xpath_spec.rb +++ b/spec/xpath_spec.rb @@ -20,14 +20,14 @@ def xpath(type=nil, &block) it "should work as a mixin" do xpath = Thingy.new.foo_div.to_xpath - doc.xpath(xpath).first[:title].should == 'fooDiv' + doc.xpath(xpath).first[:title].should eq 'fooDiv' end describe '#descendant' do it "should find nodes that are nested below the current node" do @results = xpath { |x| x.descendant(:p) } - @results[0].text.should == "Blah" - @results[1].text.should == "Bax" + @results[0].text.should eq "Blah" + @results[1].text.should eq "Bax" end it "should not find nodes outside the context" do @@ -40,22 +40,22 @@ def xpath(type=nil, &block) it "should find multiple kinds of nodes" do @results = xpath { |x| x.descendant(:p, :ul) } - @results[0].text.should == 'Blah' - @results[3].text.should == 'A list' + @results[0].text.should eq 'Blah' + @results[3].text.should eq 'A list' end it "should find all nodes when no arguments given" do @results = xpath { |x| x.descendant[x.attr(:id) == 'foo'].descendant } - @results[0].text.should == 'Blah' - @results[4].text.should == 'A list' + @results[0].text.should eq 'Blah' + @results[4].text.should eq 'A list' end end describe '#child' do it "should find nodes that are nested directly below the current node" do @results = xpath { |x| x.descendant(:div).child(:p) } - @results[0].text.should == "Blah" - @results[1].text.should == "Bax" + @results[0].text.should eq "Blah" + @results[1].text.should eq "Bax" end it "should not find nodes that are nested further down below the current node" do @@ -65,46 +65,46 @@ def xpath(type=nil, &block) it "should find multiple kinds of nodes" do @results = xpath { |x| x.descendant(:div).child(:p, :ul) } - @results[0].text.should == 'Blah' - @results[3].text.should == 'A list' + @results[0].text.should eq 'Blah' + @results[3].text.should eq 'A list' end it "should find all nodes when no arguments given" do @results = xpath { |x| x.descendant[x.attr(:id) == 'foo'].child } - @results[0].text.should == 'Blah' - @results[3].text.should == 'A list' + @results[0].text.should eq 'Blah' + @results[3].text.should eq 'A list' end end describe '#axis' do it "should find nodes given the xpath axis" do @results = xpath { |x| x.axis(:descendant, :p) } - @results[0].text.should == "Blah" + @results[0].text.should eq "Blah" end it "should find nodes given the xpath axis without a specific tag" do @results = xpath { |x| x.descendant(:div)[x.attr(:id) == 'foo'].axis(:descendant) } - @results[0][:id].should == "fooDiv" + @results[0][:id].should eq "fooDiv" end end describe '#next_sibling' do it "should find nodes which are immediate siblings of the current node" do - xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling(:p) }.first.text.should == 'Bax' - xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling(:ul, :p) }.first.text.should == 'Bax' - xpath { |x| x.descendant(:p)[x.attr(:title) == 'monkey'].next_sibling(:ul, :p) }.first.text.should == 'A list' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling(:p) }.first.text.should eq 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling(:ul, :p) }.first.text.should eq 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:title) == 'monkey'].next_sibling(:ul, :p) }.first.text.should eq 'A list' xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling(:ul, :li) }.first.should be_nil - xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling }.first.text.should == 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'fooDiv'].next_sibling }.first.text.should eq 'Bax' end end describe '#previous_sibling' do it "should find nodes which are exactly preceding the current node" do - xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling(:p) }.first.text.should == 'Bax' - xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling(:ul, :p) }.first.text.should == 'Bax' - xpath { |x| x.descendant(:p)[x.attr(:title) == 'gorilla'].previous_sibling(:ul, :p) }.first.text.should == 'A list' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling(:p) }.first.text.should eq 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling(:ul, :p) }.first.text.should eq 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:title) == 'gorilla'].previous_sibling(:ul, :p) }.first.text.should eq 'A list' xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling(:ul, :li) }.first.should be_nil - xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling }.first.text.should == 'Bax' + xpath { |x| x.descendant(:p)[x.attr(:id) == 'wooDiv'].previous_sibling }.first.text.should eq 'Bax' end end @@ -114,7 +114,7 @@ def xpath(type=nil, &block) foo_div = x.anywhere(:div).where(x.attr(:id) == 'foo') x.descendant(:p).where(x.attr(:id) == foo_div.attr(:title)) end - @results[0].text.should == "Blah" + @results[0].text.should eq "Blah" end it "should find multiple kinds of nodes regardless of the context" do @@ -123,10 +123,10 @@ def xpath(type=nil, &block) context.anywhere(:p, :ul) end - @results[0].text.should == 'Blah' - @results[3].text.should == 'A list' - @results[4].text.should == 'A list' - @results[6].text.should == 'Bax' + @results[0].text.should eq 'Blah' + @results[3].text.should eq 'A list' + @results[4].text.should eq 'A list' + @results[6].text.should eq 'Bax' end it "should find all nodes when no arguments given regardless of the context" do @@ -134,13 +134,13 @@ def xpath(type=nil, &block) context=x.descendant(:div).where(x.attr(:id)=='woo') context.anywhere end - @results[0].name.should == 'html' - @results[1].name.should == 'head' - @results[2].name.should == 'body' - @results[6].text.should == 'Blah' - @results[10].text.should == 'A list' - @results[13].text.should == 'A list' - @results[15].text.should == 'Bax' + @results[0].name.should eq 'html' + @results[1].name.should eq 'head' + @results[2].name.should eq 'body' + @results[6].text.should eq 'Blah' + @results[10].text.should eq 'A list' + @results[13].text.should eq 'A list' + @results[15].text.should eq 'Bax' end end @@ -150,7 +150,7 @@ def xpath(type=nil, &block) @results = xpath do |x| x.descendant(:div).where(x.attr(:title).contains('ooD')) end - @results[0][:id].should == "foo" + @results[0][:id].should eq "foo" end it "should find nodes that contain the given expression" do @@ -158,7 +158,7 @@ def xpath(type=nil, &block) expression = x.anywhere(:div).where(x.attr(:title) == 'fooDiv').attr(:id) x.descendant(:div).where(x.attr(:title).contains(expression)) end - @results[0][:id].should == "foo" + @results[0][:id].should eq "foo" end end @@ -167,9 +167,9 @@ def xpath(type=nil, &block) @results = xpath do |x| x.descendant.where(x.attr(:class).contains_word('fish')) end - @results[0].text.should == "Bax" - @results[1].text.should == "llama" - @results.length.should == 2 + @results[0].text.should eq "Bax" + @results[1].text.should eq "llama" + @results.length.should eq 2 end end @@ -178,9 +178,9 @@ def xpath(type=nil, &block) @results = xpath do |x| x.descendant(:*).where(x.attr(:id).starts_with('foo')) end - @results.size.should == 2 - @results[0][:id].should == "foo" - @results[1][:id].should == "fooDiv" + @results.size.should eq 2 + @results[0][:id].should eq "foo" + @results[1][:id].should eq "fooDiv" end it "should find nodes that contain the given expression" do @@ -188,17 +188,17 @@ def xpath(type=nil, &block) expression = x.anywhere(:div).where(x.attr(:title) == 'fooDiv').attr(:id) x.descendant(:div).where(x.attr(:title).starts_with(expression)) end - @results[0][:id].should == "foo" + @results[0][:id].should eq "foo" end end describe '#text' do it "should select a node's text" do @results = xpath { |x| x.descendant(:p).where(x.text == 'Bax') } - @results[0].text.should == 'Bax' - @results[1][:title].should == 'monkey' + @results[0].text.should eq 'Bax' + @results[1][:title].should eq 'monkey' @results = xpath { |x| x.descendant(:div).where(x.descendant(:p).text == 'Bax') } - @results[0][:title].should == 'fooDiv' + @results[0][:title].should eq 'fooDiv' end end @@ -206,14 +206,14 @@ def xpath(type=nil, &block) context "when called with one argument" do it "should select the part of a string after the specified character" do @results = xpath { |x| x.descendant(:span).where(x.attr(:id) == "substring").text.substring(7) } - @results.should == "there" + @results.should eq "there" end end context "when called with two arguments" do it "should select the part of a string after the specified character, up to the given length" do @results = xpath { |x| x.descendant(:span).where(x.attr(:id) == "substring").text.substring(2, 4) } - @results.should == "ello" + @results.should eq "ello" end end end @@ -221,78 +221,78 @@ def xpath(type=nil, &block) describe '#function' do it "should call the given xpath function" do @results = xpath { |x| x.function(:boolean, x.function(:true) == x.function(:false)) } - @results.should == false + @results.should eq false end end describe '#method' do it "should call the given xpath function with the current node as the first argument" do @results = xpath { |x| x.descendant(:span).where(x.attr(:id) == "string-length").text.method(:"string-length") } - @results.should == 11 + @results.should eq 11 end end describe '#string_length' do it "should return the length of a string" do @results = xpath { |x| x.descendant(:span).where(x.attr(:id) == "string-length").text.string_length } - @results.should == 11 + @results.should eq 11 end end describe '#where' do it "should limit the expression to find only certain nodes" do - xpath { |x| x.descendant(:div).where(:"@id = 'foo'") }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(:"@id = 'foo'") }.first[:title].should eq "fooDiv" end it "should be aliased as []" do - xpath { |x| x.descendant(:div)[:"@id = 'foo'"] }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div)[:"@id = 'foo'"] }.first[:title].should eq "fooDiv" end end describe '#inverse' do it "should invert the expression" do - xpath { |x| x.descendant(:p).where(x.attr(:id).equals('fooDiv').inverse) }.first.text.should == 'Bax' + xpath { |x| x.descendant(:p).where(x.attr(:id).equals('fooDiv').inverse) }.first.text.should eq 'Bax' end it "should be aliased as the unary tilde" do - xpath { |x| x.descendant(:p).where(~x.attr(:id).equals('fooDiv')) }.first.text.should == 'Bax' + xpath { |x| x.descendant(:p).where(~x.attr(:id).equals('fooDiv')) }.first.text.should eq 'Bax' end it "should be aliased as the unary bang" do - xpath { |x| x.descendant(:p).where(!x.attr(:id).equals('fooDiv')) }.first.text.should == 'Bax' + xpath { |x| x.descendant(:p).where(!x.attr(:id).equals('fooDiv')) }.first.text.should eq 'Bax' end end describe '#equals' do it "should limit the expression to find only certain nodes" do - xpath { |x| x.descendant(:div).where(x.attr(:id).equals('foo')) }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id).equals('foo')) }.first[:title].should eq "fooDiv" end it "should be aliased as ==" do - xpath { |x| x.descendant(:div).where(x.attr(:id) == 'foo') }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id) == 'foo') }.first[:title].should eq "fooDiv" end end describe '#not_equals' do it "should match only when not equal" do - xpath { |x| x.descendant(:div).where(x.attr(:id).not_equals('bar')) }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id).not_equals('bar')) }.first[:title].should eq "fooDiv" end it "should be aliased as !=" do - xpath { |x| x.descendant(:div).where(x.attr(:id) != 'bar') }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id) != 'bar') }.first[:title].should eq "fooDiv" end end describe '#is' do it "uses equality when :exact given" do - xpath(:exact) { |x| x.descendant(:div).where(x.attr(:id).is('foo')) }.first[:title].should == "fooDiv" + xpath(:exact) { |x| x.descendant(:div).where(x.attr(:id).is('foo')) }.first[:title].should eq "fooDiv" xpath(:exact) { |x| x.descendant(:div).where(x.attr(:id).is('oo')) }.first.should be_nil end it "uses substring matching otherwise" do - xpath { |x| x.descendant(:div).where(x.attr(:id).is('foo')) }.first[:title].should == "fooDiv" - xpath { |x| x.descendant(:div).where(x.attr(:id).is('oo')) }.first[:title].should == "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id).is('foo')) }.first[:title].should eq "fooDiv" + xpath { |x| x.descendant(:div).where(x.attr(:id).is('oo')) }.first[:title].should eq "fooDiv" end end @@ -302,9 +302,9 @@ def xpath(type=nil, &block) p = x.anywhere(:div).where(x.attr(:id) == 'foo').attr(:title) x.descendant(:*).where(x.attr(:id).one_of('foo', p, 'baz')) end - @results[0][:title].should == "fooDiv" - @results[1].text.should == "Blah" - @results[2][:title].should == "bazDiv" + @results[0][:title].should eq "fooDiv" + @results[1].text.should eq "Blah" + @results[2][:title].should eq "bazDiv" end end @@ -313,14 +313,14 @@ def xpath(type=nil, &block) @results = xpath do |x| x.descendant(:*).where(x.contains('Bax').and(x.attr(:title).equals('monkey'))) end - @results[0][:title].should == "monkey" + @results[0][:title].should eq "monkey" end it "should be aliased as ampersand (&)" do @results = xpath do |x| x.descendant(:*).where(x.contains('Bax') & x.attr(:title).equals('monkey')) end - @results[0][:title].should == "monkey" + @results[0][:title].should eq "monkey" end end @@ -329,57 +329,57 @@ def xpath(type=nil, &block) @results = xpath do |x| x.descendant(:*).where(x.attr(:id).equals('foo').or(x.attr(:id).equals('fooDiv'))) end - @results[0][:title].should == "fooDiv" - @results[1].text.should == "Blah" + @results[0][:title].should eq "fooDiv" + @results[1].text.should eq "Blah" end it "should be aliased as pipe (|)" do @results = xpath do |x| x.descendant(:*).where(x.attr(:id).equals('foo') | x.attr(:id).equals('fooDiv')) end - @results[0][:title].should == "fooDiv" - @results[1].text.should == "Blah" + @results[0][:title].should eq "fooDiv" + @results[1].text.should eq "Blah" end end describe '#attr' do it "should be an attribute" do @results = xpath { |x| x.descendant(:div).where(x.attr(:id)) } - @results[0][:title].should == "barDiv" - @results[1][:title].should == "fooDiv" + @results[0][:title].should eq "barDiv" + @results[1][:title].should eq "fooDiv" end end describe '#css' do it "should find nodes by the given CSS selector" do @results = xpath { |x| x.css('#preference p') } - @results[0].text.should == 'allamas' - @results[1].text.should == 'llama' + @results[0].text.should eq 'allamas' + @results[1].text.should eq 'llama' end it "should respect previous expression" do @results = xpath { |x| x.descendant[x.attr(:id) == 'moar'].css('p') } - @results[0].text.should == 'chimp' - @results[1].text.should == 'flamingo' + @results[0].text.should eq 'chimp' + @results[1].text.should eq 'flamingo' end it "should be composable" do @results = xpath { |x| x.css('#moar').descendant(:p) } - @results[0].text.should == 'chimp' - @results[1].text.should == 'flamingo' + @results[0].text.should eq 'chimp' + @results[1].text.should eq 'flamingo' end it "should allow comma separated selectors" do @results = xpath { |x| x.descendant[x.attr(:id) == 'moar'].css('div, p') } - @results[0].text.should == 'chimp' - @results[1].text.should == 'elephant' - @results[2].text.should == 'flamingo' + @results[0].text.should eq 'chimp' + @results[1].text.should eq 'elephant' + @results[2].text.should eq 'flamingo' end end describe '#qname' do it "should match the node's name" do - xpath { |x| x.descendant(:*).where(x.qname == 'ul') }.first.text.should == "A list" + xpath { |x| x.descendant(:*).where(x.qname == 'ul') }.first.text.should eq "A list" end end @@ -391,9 +391,9 @@ def xpath(type=nil, &block) @xpath1 = @collection.where(XPath.attr(:id) == 'foo').to_xpath @xpath2 = @collection.where(XPath.attr(:id) == 'fooDiv').to_xpath @results = doc.xpath(@xpath1) - @results[0][:title].should == 'fooDiv' + @results[0][:title].should eq 'fooDiv' @results = doc.xpath(@xpath2) - @results[0][:id].should == 'fooDiv' + @results[0][:id].should eq 'fooDiv' end it "should be aliased as +" do @@ -403,119 +403,119 @@ def xpath(type=nil, &block) @xpath1 = @collection.where(XPath.attr(:id) == 'foo').to_xpath @xpath2 = @collection.where(XPath.attr(:id) == 'fooDiv').to_xpath @results = doc.xpath(@xpath1) - @results[0][:title].should == 'fooDiv' + @results[0][:title].should eq 'fooDiv' @results = doc.xpath(@xpath2) - @results[0][:id].should == 'fooDiv' + @results[0][:id].should eq 'fooDiv' end end describe "#last" do it "returns the number of elements in the context" do @results = xpath { |x| x.descendant(:p)[XPath.position() == XPath.last()] } - @results[0].text.should == "Bax" - @results[1].text.should == "Blah" - @results[2].text.should == "llama" + @results[0].text.should eq "Bax" + @results[1].text.should eq "Blah" + @results[2].text.should eq "llama" end end describe "#position" do it "returns the position of elements in the context" do @results = xpath { |x| x.descendant(:p)[XPath.position() == 2] } - @results[0].text.should == "Bax" - @results[1].text.should == "Bax" + @results[0].text.should eq "Bax" + @results[1].text.should eq "Bax" end end describe "#count" do it "counts the number of occurrences" do @results = xpath { |x| x.descendant(:div)[x.descendant(:p).count == 2] } - @results[0][:id].should == "preference" + @results[0][:id].should eq "preference" end end describe "#lte" do it "checks lesser than or equal" do @results = xpath { |x| x.descendant(:p)[XPath.position() <= 2] } - @results[0].text.should == "Blah" - @results[1].text.should == "Bax" - @results[2][:title].should == "gorilla" - @results[3].text.should == "Bax" + @results[0].text.should eq "Blah" + @results[1].text.should eq "Bax" + @results[2][:title].should eq "gorilla" + @results[3].text.should eq "Bax" end end describe "#lt" do it "checks lesser than" do @results = xpath { |x| x.descendant(:p)[XPath.position() < 2] } - @results[0].text.should == "Blah" - @results[1][:title].should == "gorilla" + @results[0].text.should eq "Blah" + @results[1][:title].should eq "gorilla" end end describe "#gte" do it "checks greater than or equal" do @results = xpath { |x| x.descendant(:p)[XPath.position() >= 2] } - @results[0].text.should == "Bax" - @results[1][:title].should == "monkey" - @results[2].text.should == "Bax" - @results[3].text.should == "Blah" + @results[0].text.should eq "Bax" + @results[1][:title].should eq "monkey" + @results[2].text.should eq "Bax" + @results[3].text.should eq "Blah" end end describe "#gt" do it "checks greater than" do @results = xpath { |x| x.descendant(:p)[XPath.position() > 2] } - @results[0][:title].should == "monkey" - @results[1].text.should == "Blah" + @results[0][:title].should eq "monkey" + @results[1].text.should eq "Blah" end end describe "#plus" do it "adds stuff" do @results = xpath { |x| x.descendant(:p)[XPath.position().plus(1) == 2] } - @results[0][:id].should == "fooDiv" - @results[1][:title].should == "gorilla" + @results[0][:id].should eq "fooDiv" + @results[1][:title].should eq "gorilla" end end describe "#minus" do it "subtracts stuff" do @results = xpath { |x| x.descendant(:p)[XPath.position().minus(1) == 0] } - @results[0][:id].should == "fooDiv" - @results[1][:title].should == "gorilla" + @results[0][:id].should eq "fooDiv" + @results[1][:title].should eq "gorilla" end end describe "#multiply" do it "multiplies stuff" do @results = xpath { |x| x.descendant(:p)[XPath.position() * 3 == 3] } - @results[0][:id].should == "fooDiv" - @results[1][:title].should == "gorilla" + @results[0][:id].should eq "fooDiv" + @results[1][:title].should eq "gorilla" end end describe "#divide" do it "divides stuff" do @results = xpath { |x| x.descendant(:p)[XPath.position() / 2 == 1] } - @results[0].text.should == "Bax" - @results[1].text.should == "Bax" + @results[0].text.should eq "Bax" + @results[1].text.should eq "Bax" end end describe "#mod" do it "take modulo" do @results = xpath { |x| x.descendant(:p)[XPath.position() % 2 == 1] } - @results[0].text.should == "Blah" - @results[1][:title].should == "monkey" - @results[2][:title].should == "gorilla" + @results[0].text.should eq "Blah" + @results[1][:title].should eq "monkey" + @results[2][:title].should eq "gorilla" end end describe "#ancestor" do it "finds ancestor nodes" do @results = xpath { |x| x.descendant(:p)[1].ancestor } - @results[0].node_name.should == "html" - @results[1].node_name.should == "body" - @results[2][:id].should == "foo" + @results[0].node_name.should eq "html" + @results[1].node_name.should eq "body" + @results[2][:id].should eq "foo" end end end diff --git a/xpath.gemspec b/xpath.gemspec index 808429c..6c04df2 100644 --- a/xpath.gemspec +++ b/xpath.gemspec @@ -5,7 +5,7 @@ require 'xpath/version' Gem::Specification.new do |s| s.name = "xpath" s.version = XPath::VERSION - s.required_ruby_version = ">= 1.9.3" + s.required_ruby_version = ">= 2.2" s.authors = ["Jonas Nicklas"] s.email = ["jonas.nicklas@gmail.com"] @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/teamcapybara/xpath" s.summary = "Generate XPath expressions from Ruby" - s.add_dependency("nokogiri", ["~> 1.3"]) + s.add_dependency("nokogiri", ["~> 1.8"]) s.add_development_dependency("rspec", ["~> 3.0"]) s.add_development_dependency("yard", [">= 0.5.8"])