Revamped compiler type test specs
This commit is contained in:
parent
001c57e0ad
commit
1b62dd3256
|
@ -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('-', '_')
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Compiler do
|
||||
describe 'comment() tests' do
|
||||
before do
|
||||
@document = parse('<a><!--foo--><b><!--bar--></b></a>')
|
||||
|
||||
|
@ -9,12 +8,17 @@ describe Oga::XPath::Compiler do
|
|||
@comment2 = @document.children[0].children[1].children[0]
|
||||
end
|
||||
|
||||
it 'returns a node set containing comment nodes' do
|
||||
evaluate_xpath(@document, 'a/comment()').should == node_set(@comment1)
|
||||
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 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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Compiler do
|
||||
describe 'node() tests' do
|
||||
before do
|
||||
@document = parse('<a><b>foo</b><!--foo--><![CDATA[bar]]></a>')
|
||||
|
||||
|
@ -11,17 +10,29 @@ describe Oga::XPath::Compiler do
|
|||
@cdata1 = @a1.children[2]
|
||||
end
|
||||
|
||||
it 'returns a node set containing elements' do
|
||||
evaluate_xpath(@document, 'node()').should == node_set(@a1)
|
||||
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, comments and CDATA tags' do
|
||||
evaluate_xpath(@document, 'a/node()')
|
||||
.should == node_set(@b1, @comment1, @cdata1)
|
||||
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 text nodes' do
|
||||
evaluate_xpath(@document, 'a/b/node()').should == node_set(@b1.children[0])
|
||||
describe 'a/b/node()' do
|
||||
it 'returns NodeSet' do
|
||||
evaluate_xpath(@document).should == node_set(@b1.children[0])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'node()/b' do
|
||||
it 'returns a NodeSet' do
|
||||
evaluate_xpath(@document).should == node_set(@b1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Compiler do
|
||||
describe 'processing-instruction() tests' do
|
||||
before do
|
||||
@document = parse('<a><?a foo ?><b><?b bar ?></b></a>')
|
||||
|
||||
|
@ -9,14 +8,17 @@ describe Oga::XPath::Compiler do
|
|||
@proc_ins2 = @document.children[0].children[1].children[0]
|
||||
end
|
||||
|
||||
it 'returns a node set containing processing instructions' do
|
||||
evaluate_xpath(@document, 'a/processing-instruction()')
|
||||
.should == node_set(@proc_ins1)
|
||||
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 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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Compiler do
|
||||
describe 'text() tests' do
|
||||
before do
|
||||
@document = parse('<a>foo<b>bar</b></a>')
|
||||
|
||||
|
@ -9,12 +8,17 @@ describe Oga::XPath::Compiler do
|
|||
@text2 = @document.children[0].children[1].children[0]
|
||||
end
|
||||
|
||||
it 'returns a node set containing text nodes' do
|
||||
evaluate_xpath(@document, 'a/text()').should == node_set(@text1)
|
||||
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 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
|
||||
|
|
Loading…
Reference in New Issue