Class: RSpec::Core::ExampleStatusDumper Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-core/lib/rspec/core/example_status_persister.rb |
Overview
Dumps a list of hashes in a pretty, human readable format for later parsing. The hashes are expected to have symbol keys and string values, and each hash should have the same set of keys.
Class Method Summary
- .dump(examples) Internal use only
- .new(examples) ⇒ ExampleStatusDumper constructor Internal use only
Instance Method Summary
- #dump Internal use only
- #column_widths private Internal use only
- #formatted_header_rows private Internal use only
- #formatted_row_from(row_values) private Internal use only
- #formatted_value_rows private Internal use only
- #headers private Internal use only
- #rows private Internal use only
Class Method Details
.dump(examples)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 144
def self.dump(examples) new(examples).dump end
Instance Method Details
#column_widths (private)
[ GitHub ]#dump
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 152
def dump return nil if @examples.empty? (formatted_header_rows + formatted_value_rows).join("\n") << "\n" end
#formatted_header_rows (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 159
def formatted_header_rows @formatted_header_rows ||= begin dividers = column_widths.map { |w| "-" * w } [formatted_row_from(headers.map(&:to_s)), formatted_row_from(dividers)] end end
#formatted_row_from(row_values) (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 176
def formatted_row_from(row_values) padded_values = row_values.each_with_index.map do |value, index| value.ljust(column_widths[index]) end padded_values.join(" | ") << " |" end
#formatted_value_rows (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 166
def formatted_value_rows @formatted_value_rows ||= rows.map do |row| formatted_row_from(row) end end
#headers (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 184
def headers @headers ||= @examples.first.keys end
#rows (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/example_status_persister.rb', line 172
def rows @rows ||= @examples.map { |ex| ex.values_at(*headers) } end