Sha256: 993af1cc886dcd0a53bb5c0a63e158f3b7c248903ec4c4a69d02b790ecd8630b
Contents?: true
Size: 963 Bytes
Versions: 1
Compression:
Stored size: 963 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 def empty? @table.size == 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mortadella-0.0.2 | lib/mortadella.rb |