Sha256: 4beed1df94100791f944264a8f41b9fa532ae6b3e22593adae32a7c0a1c29473

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

require "spec_helper"
require "cascade/data_parser"

describe Cascade::DataParser do
  def described_class
    Cascade::DataParser
  end

  class FakeDataProvider
    def self.open(_)
      [
        ["Sally Whittaker", "2018", "McCarren House", "312",
         "3.75", "France", "+", "123.123"],
        ["Jeff Smith", "2018", "Prescott House", "17-D", "3.20",
         "Austria", "45.12"]
      ]
    end
  end

  let(:filename) { "spec/examples/data_test.txt" }
  let(:data_provider) { FakeDataProvider.open(filename) }

  before do
    @processor_calls_count = 0
    @data_saves_count = 0
    row_processor =  ->(_row) { @processor_calls_count += 1 }
    data_saver    =  ->(*)   { @data_saves_count += 1 }
    @parser = described_class.new(row_processor: row_processor,
      data_saver: data_saver, data_provider: data_provider)
  end

  it "calls row processor for each file line" do
    @parser.call
    assert_equal @processor_calls_count, 2
    assert_equal @data_saves_count, 2
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cascade-rb-0.2.3 spec/lib/data_parser_spec.rb
cascade-rb-0.2.2 spec/lib/data_parser_spec.rb
cascade-rb-0.2.1 spec/lib/data_parser_spec.rb
cascade-rb-0.2.0 spec/lib/data_parser_spec.rb