From 9ac16e2e4ff8210f494de57f5e7e86ddaa706516 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sat, 3 Sep 2016 23:56:55 +0200 Subject: [PATCH] Fixed index check in Node#next An index can/should never be equal the length of a NodeSet, thus we should use "<" here instead of "<=". --- lib/oga/xml/node.rb | 2 +- spec/oga/xml/node_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/oga/xml/node.rb b/lib/oga/xml/node.rb index 2e40d73..457882e 100644 --- a/lib/oga/xml/node.rb +++ b/lib/oga/xml/node.rb @@ -70,7 +70,7 @@ module Oga index = node_set.index(self) + 1 length = node_set.length - index <= length ? node_set[index] : nil + index < length ? node_set[index] : nil end # Returns the previous element node or nil if there is none. diff --git a/spec/oga/xml/node_spec.rb b/spec/oga/xml/node_spec.rb index 6d33f4d..0f10308 100644 --- a/spec/oga/xml/node_spec.rb +++ b/spec/oga/xml/node_spec.rb @@ -86,7 +86,7 @@ describe Oga::XML::Node do @n1.next.should == @n2 end - it 'returns nil if there is no previous node' do + it 'returns nil if there is no next node' do @n2.next.nil?.should == true end end