Fixed eval specs of :first-of-type & :last-of-type
This commit is contained in:
parent
b0b572a584
commit
8f3553f8f1
|
@ -4,24 +4,22 @@ describe 'CSS selector evaluation' do
|
||||||
context ':first-of-type pseudo class' do
|
context ':first-of-type pseudo class' do
|
||||||
before do
|
before do
|
||||||
@document = parse(<<-EOF)
|
@document = parse(<<-EOF)
|
||||||
<dl>
|
<root>
|
||||||
<dt>foo</dt>
|
<a id="1" />
|
||||||
<dd>
|
<a id="2">
|
||||||
<dl>
|
<a id="3" />
|
||||||
<dt>bar</dt>
|
<a id="4" />
|
||||||
<dd>baz</dd>
|
</a>
|
||||||
</dl>
|
</root>
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@dt1 = @document.at_xpath('dl/dt')
|
@a1 = @document.at_xpath('root/a[1]')
|
||||||
@dt2 = @document.at_xpath('dl/dd/dl/dt')
|
@a3 = @document.at_xpath('root/a[2]/a[2]')
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'return a node set containing all <dt> nodes' do
|
example 'return a node set containing all first <a> nodes' do
|
||||||
evaluate_css(@document, 'dl dt:first-of-type')
|
evaluate_css(@document, 'root a:first-of-type')
|
||||||
.should == node_set(@dt1, @dt2)
|
.should == node_set(@a1, @a3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,22 +3,23 @@ require 'spec_helper'
|
||||||
describe 'CSS selector evaluation' do
|
describe 'CSS selector evaluation' do
|
||||||
context ':last-of-type pseudo class' do
|
context ':last-of-type pseudo class' do
|
||||||
before do
|
before do
|
||||||
@document = parse('<root><a /><b /><a /></root>')
|
@document = parse(<<-EOF)
|
||||||
|
<root>
|
||||||
|
<a id="1" />
|
||||||
|
<a id="2">
|
||||||
|
<a id="3" />
|
||||||
|
<a id="4" />
|
||||||
|
</a>
|
||||||
|
</root>
|
||||||
|
EOF
|
||||||
|
|
||||||
@b1 = @document.children[0].children[1]
|
@a2 = @document.at_xpath('root/a[2]')
|
||||||
@a2 = @document.children[0].children[2]
|
@a4 = @document.at_xpath('root/a[2]/a[2]')
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'return a node set containing the last node' do
|
example 'return a node set containing all last <a> nodes' do
|
||||||
evaluate_css(@document, 'root :last-of-type').should == node_set(@a2)
|
evaluate_css(@document, 'root a:last-of-type')
|
||||||
end
|
.should == node_set(@a2, @a4)
|
||||||
|
|
||||||
example 'return a node set containing the last node with a node test' do
|
|
||||||
evaluate_css(@document, 'root b:last-of-type').should == node_set(@b1)
|
|
||||||
end
|
|
||||||
|
|
||||||
example 'return a node set containing the last <a> node' do
|
|
||||||
evaluate_css(@document, 'root a:last-of-type').should == node_set(@a2)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue