Parse content as HTML (unless the Content-Type is XML)

This commit is contained in:
Bryan Helmkamp 2009-01-18 16:34:42 -05:00
parent 4720a79d3c
commit f92f9bead8
2 changed files with 3 additions and 8 deletions

View File

@ -10,11 +10,11 @@ module Webrat
elsif Nokogiri::XML::NodeSet === stringlike elsif Nokogiri::XML::NodeSet === stringlike
stringlike stringlike
elsif StringIO === stringlike elsif StringIO === stringlike
Nokogiri.parse(stringlike.string) Nokogiri::HTML(stringlike.string)
elsif stringlike.respond_to?(:body) elsif stringlike.respond_to?(:body)
Nokogiri.parse(stringlike.body.to_s) Nokogiri::HTML(stringlike.body.to_s)
else else
Nokogiri.parse(stringlike.to_s) Nokogiri::HTML(stringlike.to_s)
end end
end end

View File

@ -17,11 +17,6 @@ describe Webrat::Matchers do
end end
describe "#have_xpath" do describe "#have_xpath" do
it "should work with non-HTML documents" do
xml = '<foo bar="baz"></foo>'
xml.should have_xpath('/foo[@bar="baz"]')
end
it "should be able to match an XPATH" do it "should be able to match an XPATH" do
@body.should have_xpath("//div") @body.should have_xpath("//div")
end end