<commit_before>require 'spec_helper'

describe "diffing tables" do

  [
    "planetary_bodies",
  ].each do |name|

    it "should generate correct HTML for #{name}" do

      old_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_old.csv")))
      new_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_new.csv")))
 
      alignment = Coopy.compare_tables(old_table,new_table).align

      table_diff = Coopy::SimpleTable.new(5,5)

      flags = Coopy::CompareFlags.new
      highlighter = Coopy::TableDiff.new(alignment,flags)
      highlighter.hilite table_diff

      # Commented tests are currently failing - not sure why at the moment

      table_diff.get_cell(0,0).to_s.should == '!'
      table_diff.get_cell(1,0).to_s.should == ''
      table_diff.get_cell(2,0).to_s.should == '+++'
      table_diff.get_cell(3,0).to_s.should == ''

      #table_diff.get_cell(0,2).to_s.should == '+'
      table_diff.get_cell(1,2).to_s.should == 'Earth'
      table_diff.get_cell(2,2).to_s.should == '152098232'
      table_diff.get_cell(3,2).to_s.should == '9.80665'

      table_diff.get_cell(0,5).to_s.should == '+++'
      table_diff.get_cell(1,5).to_s.should == 'Mercury'
      table_diff.get_cell(2,5).to_s.should == '69816900'
      table_diff.get_cell(3,5).to_s.should == '3.7'

      #table_diff.get_cell(0,9).to_s.should == ''
      table_diff.get_cell(1,9).to_s.should == 'Io'
      table_diff.get_cell(2,9).to_s.should == ''
      table_diff.get_cell(3,9).to_s.should == '1.789'

      #table_diff.get_cell(0,19).to_s.should == '->'
      table_diff.get_cell(1,19).to_s.should == 'Triton'
      table_diff.get_cell(2,19).to_s.should == ''
      #table_diff.get_cell(3,19).to_s.should == ' 0.779->0.779'

    end

    it "should generate correct HTML for #{name}" do

      old_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_old.csv")))
      new_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_new.csv")))
 
      alignment = Coopy.compare_tables(old_table,new_table).align

      table_diff = Coopy::SimpleTable.new(5,5)

      flags = Coopy::CompareFlags.new
      highlighter = Coopy::TableDiff.new(alignment,flags)
      highlighter.hilite table_diff

      # Not implemented yet below here

      # diff2html = Coopy::DiffRender.new
      # diff2html.render table_diff
      # diff_html = diff2html.html<commit_msg>don't need to have a sized SimpleTable in tests<commit_after>require 'spec_helper'

describe "diffing tables" do

  [
    "planetary_bodies",
  ].each do |name|

    it "should generate correct HTML for #{name}" do

      old_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_old.csv")))
      new_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_new.csv")))
 
      alignment = Coopy.compare_tables(old_table,new_table).align

      table_diff = Coopy::SimpleTable.new(0,0)

      flags = Coopy::CompareFlags.new
      highlighter = Coopy::TableDiff.new(alignment,flags)
      highlighter.hilite table_diff

      # Commented tests are currently failing - not sure why at the moment

      table_diff.get_cell(0,0).to_s.should == '!'
      table_diff.get_cell(1,0).to_s.should == ''
      table_diff.get_cell(2,0).to_s.should == '+++'
      table_diff.get_cell(3,0).to_s.should == ''

      #table_diff.get_cell(0,2).to_s.should == '+'
      table_diff.get_cell(1,2).to_s.should == 'Earth'
      table_diff.get_cell(2,2).to_s.should == '152098232'
      table_diff.get_cell(3,2).to_s.should == '9.80665'

      table_diff.get_cell(0,5).to_s.should == '+++'
      table_diff.get_cell(1,5).to_s.should == 'Mercury'
      table_diff.get_cell(2,5).to_s.should == '69816900'
      table_diff.get_cell(3,5).to_s.should == '3.7'

      #table_diff.get_cell(0,9).to_s.should == ''
      table_diff.get_cell(1,9).to_s.should == 'Io'
      table_diff.get_cell(2,9).to_s.should == ''
      table_diff.get_cell(3,9).to_s.should == '1.789'

      #table_diff.get_cell(0,19).to_s.should == '->'
      table_diff.get_cell(1,19).to_s.should == 'Triton'
      table_diff.get_cell(2,19).to_s.should == ''
      #table_diff.get_cell(3,19).to_s.should == ' 0.779->0.779'

    end

    it "should generate correct HTML for #{name}" do

      old_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_old.csv")))
      new_table = Coopy::CsvTable.new(CSV.parse(load_fixture("#{name}_new.csv")))
 
      alignment = Coopy.compare_tables(old_table,new_table).align

      table_diff = Coopy::SimpleTable.new(0,0)

      flags = Coopy::CompareFlags.new
      highlighter = Coopy::TableDiff.new(alignment,flags)
      highlighter.hilite table_diff

      # Not implemented yet below here

      # diff2html = Coopy::DiffRender.new
      # diff2html.render table_diff
      # diff_html = diff2html.html
{'fraction_non_alphanumeric': 0.15821458507963118, 'fraction_numerical': 0.036881810561609385, 'mean_word_length': 3.4565826330532214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4134130', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1808, 'n_words': 221}