Added substring-before() spec for a predicate
This commit is contained in:
parent
32dba554d7
commit
b60ed03bb4
|
@ -4,8 +4,11 @@ describe Oga::XPath::Compiler do
|
||||||
describe 'substring-before() function' do
|
describe 'substring-before() function' do
|
||||||
before do
|
before do
|
||||||
@document = parse('<root><a>-</a><b>a-b-c</b></root>')
|
@document = parse('<root><a>-</a><b>a-b-c</b></root>')
|
||||||
|
|
||||||
|
@a1 = @document.children[0].children[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'at the top-level' do
|
||||||
it 'returns the substring of the 1st string before the 2nd string' do
|
it 'returns the substring of the 1st string before the 2nd string' do
|
||||||
evaluate_xpath(@document, 'substring-before("a-b-c", "-")').should == 'a'
|
evaluate_xpath(@document, 'substring-before("a-b-c", "-")').should == 'a'
|
||||||
end
|
end
|
||||||
|
@ -27,4 +30,12 @@ describe Oga::XPath::Compiler do
|
||||||
evaluate_xpath(@document, 'substring-before("", "")').should == ''
|
evaluate_xpath(@document, 'substring-before("", "")').should == ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'in a predicate' do
|
||||||
|
it 'returns a NodeSet containing all matching nodes' do
|
||||||
|
evaluate_xpath(@document, 'root/a[substring-before("foo-bar", "-")]')
|
||||||
|
.should == node_set(@a1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue