-
-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hey, following positive and communicative feedback on the other issue I wanted to pitch an idea.
I've come to nokogiri-diff for testing pages (we have a ICAP proxy that we are trying to test). We need to verify that certain pages have been correctly modified, here's our workflow:
curl -is http://wwwexample.com > www_example_com.orig
cp www_example_com.{orig,mod}
Modify the modified version to meet our spec requirements, and then test it something like this:
it "should catch them all" do
get "/proxy/http://www.example.com"
html_diff(last_response.body, mod_body).should be_empty
end
The mocks are done with Webmock, and load as one spec with any spec fixture.
The HTML diff method I wrote had to screen out some whitespace differences (no semantic value):
def html_diff(one, two)
Nokogiri::HTML(one).diff(
Nokogiri::HTML(two)
).select do |change, node|
!change.strip.empty?
end.collect do |change, node|
puts "#{change} at #{node.to_s} #{node.path}"
end.to_a
end
I'm not too happy with the implementation, but it more or less works:- unfortunately this is client work into which I can't afford to invest a lot of time into testing infrastructure (“Just ship it!”
) - but I'd like to get your feedback on whether you can see the gem adding those features?
I noticed as well, probably for the best that text nodes don't register as changes, just the attributes and hierarchy.