vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/table.rb
def diff!(other_table, options={})
        options = {:missing_row => true, :surplus_row => true, :missing_col => true, :surplus_col => false}.merge(options)

        other_table = ensure_table(other_table)
        other_table.convert_headers!
        other_table.convert_columns!
        ensure_green!
                
        convert_headers!
        convert_columns!

        original_width = cell_matrix[0].length
        other_table_cell_matrix = pad!(other_table.cell_matrix)
        padded_width = cell_matrix[0].length

        missing_col = cell_matrix[0].detect{|cell| cell.status == :undefined}
        surplus_col = padded_width > original_width

        require_diff_lcs
        cell_matrix.extend(Diff::LCS)
        changes = cell_matrix.diff(other_table_cell_matrix).flatten

        inserted = 0
        missing  = 0

        row_indices = Array.new(other_table_cell_matrix.length) {|n| n}

        last_change = nil
        missing_row_pos = nil
        insert_row_pos  = nil
        
        changes.each do |change|
          if(change.action == '-')
            missing_row_pos = change.position + inserted
            cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
            row_indices.insert(missing_row_pos, nil)
            missing += 1
          else # '+'
            insert_row_pos = change.position + missing
            inserted_row = change.element
            inserted_row.each{|cell| cell.status = :comment}
            cell_matrix.insert(insert_row_pos, inserted_row)
            row_indices[insert_row_pos] = nil
            inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change && last_change.action == '-'
            inserted += 1
          end
          last_change = change
        end

        other_table_cell_matrix.each_with_index do |other_row, i|
          row_index = row_indices.index(i)
          row = cell_matrix[row_index] if row_index
          if row
            (original_width..padded_width).each do |col_index|
              surplus_cell = other_row[col_index]
              row[col_index].value = surplus_cell.value if row[col_index]
            end
          end
        end
        
        clear_cache!
        should_raise = 
          missing_row_pos && options[:missing_row] ||
          insert_row_pos  && options[:surplus_row] ||
          missing_col     && options[:missing_col] ||
          surplus_col     && options[:surplus_col]
        raise Different.new(self) if should_raise
      end
# Compares +other_table+ to self. If +other_table+ contains columns
# and/or rows that are not in self, new columns/rows are added at the
# relevant positions, marking the cells in those rows/columns as
# <tt>surplus</tt>. Likewise, if +other_table+ lacks columns and/or 
# rows that are present in self, these are marked as <tt>missing</tt>.
#
# <tt>surplus</tt> and <tt>missing</tt> cells are recognised by formatters
# and displayed so that it's easy to read the differences.
#
# Cells that are different, but <em>look</em> identical (for example the
# boolean true and the string "true") are converted to their Object#inspect
# representation and preceded with (i) - to make it easier to identify
# where the difference actually is.
#
# Since all tables that are passed to StepDefinitions always have String
# objects in their cells, you may want to use #map_column! before calling
# #diff!. You can use #map_column! on either of the tables.
#
# A Different error is raised if there are missing rows or columns, or
# surplus rows. An error is <em>not</em> raised for surplus columns.
# Whether to raise or not raise can be changed by setting values in
# +options+ to true or false:
#
# * <tt>missing_row</tt> : Raise on missing rows (defaults to true)
# * <tt>surplus_row</tt> : Raise on surplus rows (defaults to true)
# * <tt>missing_col</tt> : Raise on missing columns (defaults to true)
# * <tt>surplus_col</tt> : Raise on surplus columns (defaults to false)
#
# The +other_table+ argument can be another Table, an Array of Array or
# an Array of Hash (similar to the structure returned by #hashes).
#
# Calling this method is particularly useful in <tt>Then</tt> steps that take
# a Table argument, if you want to compare that table to some actual values. 
#
Compares +other_table+ to self. If +other_table+ contains columns
and/or rows that are not in self, new columns/rows are added at the
relevant positions, marking the cells in those rows/columns as
surplus. Likewise, if +other_table+ lacks columns and/or
rows that are present in self, these are marked as missing.

surplus and missing cells are recognised by formatters
and displayed so that it's easy to read the differences.

Cells that are different, but look identical (for example the
boolean true and the string "true") are converted to their Object#inspect
representation and preceded with (i) - to make it easier to identify
where the difference actually is.

Since all tables that are passed to StepDefinitions always have String
objects in their cells, you may want to use #map_column. before calling
diff!. You can use #map_column. on either of the tables.

A Different error is raised if there are missing rows or columns, or
surplus rows. An error is not raised for surplus columns.
Whether to raise or not raise can be changed by setting values in
+options+ to true or false.

missing_row : Raise on missing rows (defaults to true)
surplus_row : Raise on surplus rows (defaults to true)
missing_col : Raise on missing columns (defaults to true)
surplus_col : Raise on surplus columns (defaults to false)

The +other_table+ argument can be another Table, an Array of Array or
an Array of Hash (similar to the structure returned by #hashes).

Calling this method is particularly useful in Then steps that take
a Table argument, if you want to compare that table to some actual values.
Compares + other_table + to self . If + other_table + contains columns and / or rows that are not in self new columns / rows are added at the relevant positions marking the cells in those rows / columns as surplus . Likewise if + other_table + lacks columns and / or rows that are present in self these are marked as missing . surplus and missing cells are recognised by formatters and displayed so that it ' s easy to read the differences . Cells that are different but look identical ( for example the boolean true and the string " true " ) are converted to their Object#inspect representation and preceded with ( i ) - to make it easier to identify where the difference actually is . Since all tables that are passed to StepDefinitions always have String objects in their cells you may want to use #map_column . before calling diff! . You can use #map_column . on either of the tables . A Different error is raised if there are missing rows or columns or surplus rows . An error is not raised for surplus columns . Whether to raise or not raise can be changed by setting values in + options + to true or false . missing_row : Raise on missing rows ( defaults to true ) surplus_row : Raise on surplus rows ( defaults to true ) missing_col : Raise on missing columns ( defaults to true ) surplus_col : Raise on surplus columns ( defaults to false ) The + other_table + argument can be another Table an Array of Array or an Array of Hash ( similar to the structure returned by #hashes ) . Calling this method is particularly useful in Then steps that take a Table argument if you want to compare that table to some actual values .
def diff!(other_table, options={})
        options = {:missing_row => true, :surplus_row => true, :missing_col => true, :surplus_col => false}.merge(options)
        other_table = ensure_table(other_table)
        other_table.convert_headers!
        other_table.convert_columns!
        ensure_green!
        convert_headers!
        convert_columns!
        original_width = cell_matrix[0].length
        other_table_cell_matrix = pad!(other_table.cell_matrix)
        padded_width = cell_matrix[0].length
        missing_col = cell_matrix[0].detect{|cell| cell.status == :undefined}
        surplus_col = padded_width > original_width
        require_diff_lcs
        cell_matrix.extend(Diff::LCS)
        changes = cell_matrix.diff(other_table_cell_matrix).flatten
        inserted = 0
        missing  = 0
        row_indices = Array.new(other_table_cell_matrix.length) {|n| n}
        last_change = nil
        missing_row_pos = nil
        insert_row_pos  = nil
        changes.each do |change|
          if(change.action == '-')
            missing_row_pos = change.position + inserted
            cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
            row_indices.insert(missing_row_pos, nil)
            missing += 1
          else 
            insert_row_pos = change.position + missing
            inserted_row = change.element
            inserted_row.each{|cell| cell.status = :comment}
            cell_matrix.insert(insert_row_pos, inserted_row)
            row_indices[insert_row_pos] = nil
            inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change && last_change.action == '-'
            inserted += 1
          end
          last_change = change
        end
        other_table_cell_matrix.each_with_index do |other_row, i|
          row_index = row_indices.index(i)
          row = cell_matrix[row_index] if row_index
          if row
            (original_width..padded_width).each do |col_index|
              surplus_cell = other_row[col_index]
              row[col_index].value = surplus_cell.value if row[col_index]
            end
          end
        end
        clear_cache!
        should_raise = 
          missing_row_pos && options[:missing_row] ||
          insert_row_pos  && options[:surplus_row] ||
          missing_col     && options[:missing_col] ||
          surplus_col     && options[:surplus_col]
        raise Different.new(self) if should_raise
      end
def diff! ( other_table , options = { } ) options = { :missing_row => true , :surplus_row => true , :missing_col => true , :surplus_col => false } . merge ( options ) other_table = ensure_table ( other_table ) other_table . convert_headers! other_table . convert_columns! ensure_green! convert_headers! convert_columns! original_width = cell_matrix [ 0 ] . length other_table_cell_matrix = pad! ( other_table . cell_matrix ) padded_width = cell_matrix [ 0 ] . length missing_col = cell_matrix [ 0 ] . detect { | cell | cell . status == :undefined } surplus_col = padded_width > original_width require_diff_lcs cell_matrix . extend ( Diff :: LCS ) changes = cell_matrix . diff ( other_table_cell_matrix ) . flatten inserted = 0 missing = 0 row_indices = Array . new ( other_table_cell_matrix . length ) { | n | n } last_change = nil missing_row_pos = nil insert_row_pos = nil changes . each do | change | if ( change . action == '-' ) missing_row_pos = change . position + inserted cell_matrix [ missing_row_pos ] . each { | cell | cell . status = :undefined } row_indices . insert ( missing_row_pos , nil ) missing += 1 else insert_row_pos = change . position + missing inserted_row = change . element inserted_row . each { | cell | cell . status = :comment } cell_matrix . insert ( insert_row_pos , inserted_row ) row_indices [ insert_row_pos ] = nil inspect_rows ( cell_matrix [ missing_row_pos ] , inserted_row ) if last_change && last_change . action == '-' inserted += 1 end last_change = change end other_table_cell_matrix . each_with_index do | other_row , i | row_index = row_indices . index ( i ) row = cell_matrix [ row_index ] if row_index if row ( original_width .. padded_width ) . each do | col_index | surplus_cell = other_row [ col_index ] row [ col_index ] . value = surplus_cell . value if row [ col_index ] end end end clear_cache! should_raise = missing_row_pos && options [ :missing_row ] || insert_row_pos && options [ :surplus_row ] || missing_col && options [ :missing_col ] || surplus_col && options [ :surplus_col ] raise Different . new ( self ) if should_raise end
Compares +other_table+ to self.
Compares + other_table + to self .
# '+'
other_table
options