Skip to content

Instantly share code, notes, and snippets.

@jacobo
Created June 20, 2013 20:59
Show Gist options
  • Save jacobo/5826593 to your computer and use it in GitHub Desktop.
Save jacobo/5826593 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
str = "<select id=\"cluster_configuration_data_snapshot_id\" name=\"cluster_configuration[data_snapshot_id]\"></select>"
#This one fails
failing = Proc.new do
innards = "<option data-size=\"15\" value=\"\" volume_size=\"\">New volume</option>\n<option class=\"time\" data-html-suffix=\" (snap-f2e4f551) (Application Master) [64-bit]\" data-size=\"15\" datetime=\"2013-06-20T20:29:32+00:00\" value=\"8\" volume_id=\"14\" volume_size=\"15\" selected>\nThu Jun 20 20:29:32 2013 (snap-f2e4f551) (Application Master) [64-bit]\n</option>"
x = Nokogiri::XML::Element.new('select', Nokogiri::XML(str))
x.inner_html = innards
if x.xpath(".//option[contains(normalize-space(string(.)), '8')]").empty?
puts "bug reproduced"
else
puts "UNEXPECTED"
end
end
#This one works
working = Proc.new do
innards = "<option data-size=\"15\" value=\"\" volume_size=\"\">New volume</option>\n<option class=\"time\" data-html-suffix=\" (snap-f2e4f551) (Application Master) [64-bit]\" data-size=\"15\" datetime=\"2013-06-20T20:29:32+00:00\" value=\"8\" volume_id=\"14\" volume_size=\"15\" selected>\nThu Jun 20 20:29:32 2013 (snap-484a1eda) (Application Master) [64-bit]\n</option>"
x = Nokogiri::XML::Element.new('select', Nokogiri::XML(str))
x.inner_html = innards
if x.xpath(".//option[contains(normalize-space(string(.)), '8')]").empty?
puts "UNEXPECTED"
else
puts "CONTROL example still passes"
end
end
working.call
failing.call
working.call
failing.call
failing.call
working.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment