Support for the XPath comment() test.
This commit is contained in:
1 parent
4e8cca258c
commit
ccd95d69d8
2 files changed
+59
No files matched your search
@@ -0,0 +1,42 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Evaluator do
|
||||
context 'comment() tests' do
|
||||
before do
|
||||
@document = parse('<a><!--foo--><b><!--bar--></b></a>')
|
||||
@evaluator = described_class.new(@document)
|
||||
end
|
||||
|
||||
context 'matching text nodes' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('a/comment()')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return a Comment instance' do
|
||||
@set[0].is_a?(Oga::XML::Comment).should == true
|
||||
end
|
||||
|
||||
example 'return the "foo" comment node' do
|
||||
@set[0].text.should == 'foo'
|
||||
end
|
||||
end
|
||||
|
||||
context 'matching nested text nodes' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('a/b/comment()')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return a Comment instance' do
|
||||
@set[0].is_a?(Oga::XML::Comment).should == true
|
||||
end
|
||||
|
||||
example 'return the "bar" comment node' do
|
||||
@set[0].text.should == 'bar'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user