Sha256: 6700b12cc008a5a7e5511576a26aa19c7d9da18dcceb17ef0f7724f2f43f4c7d

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require_relative '../../lib/csv_decision'

context 'simple example' do
  data = <<~DATA
    in :topic, in :region,  out :team_member
    sports,    Europe,      Alice
    sports,    ,            Bob
    finance,   America,     Charlie
    finance,   Europe,      Donald
    finance,   ,            Ernest
    politics,  Asia,        Fujio
    politics,  America,     Gilbert
    politics,  ,            Henry
    ,          ,            Zach
  DATA

  it 'makes correct decisions for CSV string' do
    table = CSVDecision.parse(data)

    result = table.decide(topic: 'finance', region: 'Europe')
    expect(result).to eq(team_member: 'Donald')

    result = table.decide(topic: 'sports', region: nil)
    expect(result).to eq(team_member: 'Bob')

    result = table.decide(topic: 'culture', region: 'America')
    expect(result).to eq(team_member: 'Zach')
  end


  it 'makes correct decisions for CSV file' do
    table = CSVDecision.parse(Pathname('spec/data/valid/simple_example.csv'))

    result = table.decide(topic: 'finance', region: 'Europe')
    expect(result).to eq(team_member: 'Donald')

    result = table.decide(topic: 'sports', region: nil)
    expect(result).to eq(team_member: 'Bob')

    result = table.decide(topic: 'culture', region: 'America')
    expect(result).to eq(team_member: 'Zach')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv_decision-0.0.2 spec/csv_decision/simple_example_spec.rb