Sha256: 98397994fb117d06e3a51006df59cb827943b05fe50e1fdacc92199e835e02ad
Contents?: true
Size: 922 Bytes
Versions: 1
Compression:
Stored size: 922 Bytes
Contents
# Makes it easy to build DRY Cucumber-compatible tables class Mortadella attr_reader :table def initialize headers:, dry: [] @headers = headers @dry = dry # The resulting Cucumber-compatible table structure @table = [headers] # The previously added row @previous_row = nil end # Adds the given row to the table def << row @table << dry_up(row) @previous_row = row end # Returns a dried up version of the given row # based on the row that came before in the table # # In a dried up row, any values that match the previous row are removed, # stopping on the first difference def dry_up row return row unless @previous_row result = row.clone @previous_row.each_with_index do |previous_value, i| if @dry.include?(@headers[i]) && row[i] == previous_value result[i] = '' else break end end result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mortadella-0.0.1 | lib/mortadella.rb |