Class: Cucumber::Formatter::OrderedXmlMarkup

Inherits:
Builder::XmlMarkup
  • Object
show all
Defined in:
lib/cucumber/formatter/ordered_xml_markup.rb

Overview

Emits attributes ordered alphabetically, so that we can predicatbly test output.

Instance Method Summary collapse

Instance Method Details

#_insert_attributes(attrs, order = []) ⇒ Object

:nodoc:



12
13
14
15
16
17
18
19
20
21
# File 'lib/cucumber/formatter/ordered_xml_markup.rb', line 12

def _insert_attributes(attrs, order=[])
  return if attrs.nil?
  keys = attrs.keys.map{|k| k.to_s}
  keys.sort!
  keys.reverse! if (attrs.keys - [:version, :encoding] == []) #HACK to ensure the 'version' attribute is first in xml declaration.
  keys.each do |k|
    v = attrs[k.to_sym] || attrs[k]
    @target << %{ #{k}="#{_attr_value(v)}"} if v
  end
end