Module: CI::Reporter::StructureXmlHelpers

Included in:
TestCase, TestSuite
Defined in:
lib/ci/reporter/test_suite.rb

Instance Method Summary collapse

Instance Method Details

#attr_hashObject

Struct#to_h is not available in Ruby 1.9



10
11
12
# File 'lib/ci/reporter/test_suite.rb', line 10

def attr_hash
  Hash[self.members.zip(self.values)]
end

#cleaned_attributesObject

Removes empty attributes and truncates long attributes.



15
16
17
18
19
20
# File 'lib/ci/reporter/test_suite.rb', line 15

def cleaned_attributes
  attr_array = attr_hash
    .reject {|k,v| v.to_s.empty? }
    .map    {|k,v| [k, truncate_at_newline(v)] }
  Hash[attr_array]
end

#truncate_at_newline(txt) ⇒ Object



22
23
24
# File 'lib/ci/reporter/test_suite.rb', line 22

def truncate_at_newline(txt)
  txt.to_s.sub(/\n.*/m, '...')
end