<commit_before>require 'spec_helper'
require 'fluent_helpers/themes/inspinia'

describe FluentHelpers::Helpers::Table do
  let(:person) { Struct.new :name, :birthday, :country }
  let(:alice) { person.new 'Alice', DateTime.new(1980, 1, 1), 'US' }
  let(:bob) { person.new 'Bob', DateTime.new(1981, 1, 1), 'UK' }
  let(:template) { TemplateStub.new.tap { |t|
    t.extend FluentHelpers::Themes::Inspinia
  } }

  example 'A simple table with 2 columns' do
    people = [alice, bob]

    html = described_class.new template, people, ->(t) {
      t[:name]
      t[:country]
    }

    expect(html.to_s).to have_tag('table') do
      with_tag 'thead tr th.name', text: '.name.'
      with_tag 'thead tr th.country', text: '.country.'

      with_tag 'tbody tr td.name', text: 'Alice'
      with_tag 'tbody tr td.name', text: 'Bob'

      with_tag 'tbody tr td.country', text: 'US'
      with_tag 'tbody tr td.country', text: 'UK'
    end
  end<commit_msg>include helpers only<commit_after>require 'spec_helper'
require 'fluent_helpers/themes/inspinia'

describe FluentHelpers::Helpers::Table do
  let(:person) { Struct.new :name, :birthday, :country }
  let(:alice) { person.new 'Alice', DateTime.new(1980, 1, 1), 'US' }
  let(:bob) { person.new 'Bob', DateTime.new(1981, 1, 1), 'UK' }
  let(:template) { TemplateStub.new.tap { |t|
    t.extend FluentHelpers::Helpers
  } }

  example 'A simple table with 2 columns' do
    people = [alice, bob]

    html = described_class.new template, people, ->(t) {
      t[:name]
      t[:country]
    }

    expect(html.to_s).to have_tag('table') do
      with_tag 'thead tr th.name', text: '.name.'
      with_tag 'thead tr th.country', text: '.country.'

      with_tag 'tbody tr td.name', text: 'Alice'
      with_tag 'tbody tr td.name', text: 'Bob'

      with_tag 'tbody tr td.country', text: 'US'
      with_tag 'tbody tr td.country', text: 'UK'
    end
  end
{'fraction_non_alphanumeric': 0.15667718191377497, 'fraction_numerical': 0.013669821240799159, 'mean_word_length': 3.315192743764172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4595572', 'n_tokens_mistral': 715, 'n_tokens_neox': 675, 'n_words': 181}