Sha256: dc38f2e455008bcc906c6f5fceeca03b14091145467550f483d5387e5e7615f4

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

require 'minitest/autorun'
require 'rodimus'

Rodimus.configure do |config|
  config.logger = Logger.new(nil)
end

class TestIO < IO # Because we can't read closed StringIOs
  attr_reader :history

  def initialize
    @history = []
  end

  def close; nil; end

  def puts(string)
    history << string
  end
end

class TestStep < MiniTest::Unit::TestCase
  def setup
    @test_string = "row 1\nrow 2"
    @incoming = StringIO.new(@test_string)
    @outgoing = TestIO.new
    @step = Rodimus::Step.new
    @step.incoming = @incoming
    @step.outgoing = @outgoing
  end

  def test_streaming_rows
    @step.run
    assert_equal @test_string, @outgoing.history.join
  end

  def test_process_row
    @step.define_singleton_method(:process_row) do |row|
      row.upcase
    end
    @step.run
    assert_equal @test_string.upcase, @outgoing.history.join
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rodimus-1.2.0 test/rodimus/step_test.rb
rodimus-1.1.0 test/rodimus/step_test.rb
rodimus-1.0.0 test/rodimus/step_test.rb