Sha256: d85a3efb4a0878847a7033a1cc7b2d148a2f5ead461c6b32aa2a18bd194a19d8
Contents?: true
Size: 928 Bytes
Versions: 6
Compression:
Stored size: 928 Bytes
Contents
require 'rubygems' require 'active_support/test_case' require_relative './mocks/mocks' require_relative './mocks/dictionaries' require_relative './support/fixtures' def to_xml_test(*names) names = names.first if names.size == 1 && names.first.is_a?(Hash) names.each do |name, xml_name| xml_name ||= name define_method "test_#{name}" do klass = name.is_a?(Symbol) ? name.to_s.camelize.constantize : name xml = xml_name.is_a?(Symbol) ? xml_fixture(xml_name) : xml_name dict = klass.from_xml(xml) xml = remove_children(xml) assert_equal xml.to_s, dict.to_xml.to_s end end end def remove_children(xml) xml = ROXML::XML.parse_string(xml).root if xml.is_a?(String) return unless xml.respond_to? :children xml.children.each do |child| if child.to_s.blank? defined?(Nokogiri) ? child.remove : child.remove! else remove_children(child) end end xml end
Version data entries
6 entries across 6 versions & 1 rubygems