diff --git a/lib/oga/xpath/compiler.rb b/lib/oga/xpath/compiler.rb
index 197e5ec..749c0f3 100644
--- a/lib/oga/xpath/compiler.rb
+++ b/lib/oga/xpath/compiler.rb
@@ -1276,7 +1276,7 @@ module Oga
# @return [Oga::Ruby::Node]
#
def on_type_test(ast, input, &block)
- name, followng = *ast
+ name, following = *ast
handler = name.gsub('-', '_')
diff --git a/spec/oga/xpath/compiler/type_tests/comment_spec.rb b/spec/oga/xpath/compiler/type_tests/comment_spec.rb
index 8a2ecf3..abdd7e0 100644
--- a/spec/oga/xpath/compiler/type_tests/comment_spec.rb
+++ b/spec/oga/xpath/compiler/type_tests/comment_spec.rb
@@ -1,20 +1,24 @@
require 'spec_helper'
describe Oga::XPath::Compiler do
- describe 'comment() tests' do
- before do
- @document = parse('')
+ before do
+ @document = parse('')
- @comment1 = @document.children[0].children[0]
- @comment2 = @document.children[0].children[1].children[0]
+ @comment1 = @document.children[0].children[0]
+ @comment2 = @document.children[0].children[1].children[0]
+ end
+
+ describe 'relative to a document' do
+ describe 'a/comment()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@comment1)
+ end
end
- it 'returns a node set containing comment nodes' do
- evaluate_xpath(@document, 'a/comment()').should == node_set(@comment1)
- end
-
- it 'returns a node set containing nested comments' do
- evaluate_xpath(@document, 'a/b/comment()').should == node_set(@comment2)
+ describe 'a/b/comment()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@comment2)
+ end
end
end
end
diff --git a/spec/oga/xpath/compiler/type_tests/node_spec.rb b/spec/oga/xpath/compiler/type_tests/node_spec.rb
index 42a928a..cd4e65a 100644
--- a/spec/oga/xpath/compiler/type_tests/node_spec.rb
+++ b/spec/oga/xpath/compiler/type_tests/node_spec.rb
@@ -1,27 +1,38 @@
require 'spec_helper'
describe Oga::XPath::Compiler do
- describe 'node() tests' do
- before do
- @document = parse('foo')
+ before do
+ @document = parse('foo')
- @a1 = @document.children[0]
- @b1 = @a1.children[0]
- @comment1 = @a1.children[1]
- @cdata1 = @a1.children[2]
+ @a1 = @document.children[0]
+ @b1 = @a1.children[0]
+ @comment1 = @a1.children[1]
+ @cdata1 = @a1.children[2]
+ end
+
+ describe 'relative to a document' do
+ describe 'node()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@a1)
+ end
end
- it 'returns a node set containing elements' do
- evaluate_xpath(@document, 'node()').should == node_set(@a1)
+ describe 'a/node()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@b1, @comment1, @cdata1)
+ end
end
- it 'returns a node set containing elements, comments and CDATA tags' do
- evaluate_xpath(@document, 'a/node()')
- .should == node_set(@b1, @comment1, @cdata1)
+ describe 'a/b/node()' do
+ it 'returns NodeSet' do
+ evaluate_xpath(@document).should == node_set(@b1.children[0])
+ end
end
- it 'returns a node set containing text nodes' do
- evaluate_xpath(@document, 'a/b/node()').should == node_set(@b1.children[0])
+ describe 'node()/b' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@b1)
+ end
end
end
end
diff --git a/spec/oga/xpath/compiler/type_tests/processing_instruction_spec.rb b/spec/oga/xpath/compiler/type_tests/processing_instruction_spec.rb
index 8e5066f..83b49ba 100644
--- a/spec/oga/xpath/compiler/type_tests/processing_instruction_spec.rb
+++ b/spec/oga/xpath/compiler/type_tests/processing_instruction_spec.rb
@@ -1,22 +1,24 @@
require 'spec_helper'
describe Oga::XPath::Compiler do
- describe 'processing-instruction() tests' do
- before do
- @document = parse('')
+ before do
+ @document = parse('')
- @proc_ins1 = @document.children[0].children[0]
- @proc_ins2 = @document.children[0].children[1].children[0]
+ @proc_ins1 = @document.children[0].children[0]
+ @proc_ins2 = @document.children[0].children[1].children[0]
+ end
+
+ describe 'relative to a document' do
+ describe 'a/processing-instruction()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@proc_ins1)
+ end
end
- it 'returns a node set containing processing instructions' do
- evaluate_xpath(@document, 'a/processing-instruction()')
- .should == node_set(@proc_ins1)
- end
-
- it 'returns a node set containing nested processing instructions' do
- evaluate_xpath(@document, 'a/b/processing-instruction()')
- .should == node_set(@proc_ins2)
+ describe 'a/b/processing-instruction()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@proc_ins2)
+ end
end
end
end
diff --git a/spec/oga/xpath/compiler/type_tests/text_spec.rb b/spec/oga/xpath/compiler/type_tests/text_spec.rb
index 401abbf..11de6c0 100644
--- a/spec/oga/xpath/compiler/type_tests/text_spec.rb
+++ b/spec/oga/xpath/compiler/type_tests/text_spec.rb
@@ -1,20 +1,24 @@
require 'spec_helper'
describe Oga::XPath::Compiler do
- describe 'text() tests' do
- before do
- @document = parse('foobar')
+ before do
+ @document = parse('foobar')
- @text1 = @document.children[0].children[0]
- @text2 = @document.children[0].children[1].children[0]
+ @text1 = @document.children[0].children[0]
+ @text2 = @document.children[0].children[1].children[0]
+ end
+
+ describe 'relative to a document' do
+ describe 'a/text()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@text1)
+ end
end
- it 'returns a node set containing text nodes' do
- evaluate_xpath(@document, 'a/text()').should == node_set(@text1)
- end
-
- it 'returns a node set containing nested text nodes' do
- evaluate_xpath(@document, 'a/b/text()').should == node_set(@text2)
+ describe 'a/b/text()' do
+ it 'returns a NodeSet' do
+ evaluate_xpath(@document).should == node_set(@text2)
+ end
end
end
end