Added substring-after() spec for a predicate

This commit is contained in:
Yorick Peterse 2015-08-18 15:15:14 +02:00
parent b60ed03bb4
commit be05008be9
1 changed files with 28 additions and 17 deletions

View File

@ -4,8 +4,11 @@ describe Oga::XPath::Compiler do
describe 'substring-after() function' do
before do
@document = parse('<root><a>-</a><b>a-b-c</b></root>')
@a1 = @document.children[0].children[0]
end
describe 'at the top-level' do
it 'returns the substring of the 1st string after the 2nd string' do
evaluate_xpath(@document, 'substring-after("a-b-c", "-")').should == 'b-c'
end
@ -27,4 +30,12 @@ describe Oga::XPath::Compiler do
evaluate_xpath(@document, 'substring-after("", "")').should == ''
end
end
describe 'in a predicate' do
it 'returns a NodeSet containing all matching nodes' do
evaluate_xpath(@document, 'root/a[substring-after("foo-bar", "-")]')
.should == node_set(@a1)
end
end
end
end