Created
March 12, 2011 01:50
-
-
Save deepfryed/866940 to your computer and use it in GitHub Desktop.
should nokogiri css multiple selector work like xpath alternation ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'nokogiri' | |
require 'minitest/spec' | |
describe 'nokogiri css selectors' do | |
before do | |
@doc = Nokogiri::HTML %Q{ | |
<html> | |
<body> | |
<div> | |
<span> span 1 </span> | |
<abbr> abbr 1 </abbr> | |
<span> span 2 </span> | |
<abbr> abbr 2 </abbr> | |
</div> | |
</body> | |
</html> | |
} | |
end | |
it 'should emulate xpath alternation' do | |
xpath = @doc.xpath('.//div/span | .//div/abbr').map(&:text) | |
css = @doc.css('div > span, div > abbr').map(&:text) | |
assert_equal xpath, css | |
end | |
end | |
MiniTest::Unit.autorun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment