Sha256: 68749bd81d510f1481750c28d8ac2673eb58aa5b9577e2ec39eb502a809fa41b

Contents?: true

Size: 877 Bytes

Versions: 6

Compression:

Stored size: 877 Bytes

Contents

module ETL
  module Control
    # Usage:
    # - declare in the ctl file:
    #   destination :out, { :type => :mock, :name => :my_mock_output  }
    # - run the .ctl from your test
    # - then assert the content of the rows
    #   assert_equal [{:name => 'John Barry'},{:name => 'Gary Moore'}], MockDestination[:my_mock_output]
    class MockDestination < Destination
      def initialize(control, configuration, mapping={})
        super
        @mock_destination_name = configuration[:name] || 'mock_destination'
        @@registry ||= {}
        @@registry[@mock_destination_name] ||= []
      end
      def self.[](mock_destination_name)
        @@registry[mock_destination_name]
      end
      def write(row)
        @@registry[@mock_destination_name] << row
      end
      # the presence of close is asserted - just do nothing
      def close; end
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
activewarehouse-etl-1.0.0 test/mocks/mock_destination.rb
activewarehouse-etl-1.0.0.rc1 test/mocks/mock_destination.rb
etl-0.9.5.rc1 test/mocks/mock_destination.rb
activewarehouse-etl-sgonyea-0.9.6 test/mocks/mock_destination.rb
activewarehouse-etl-0.9.5.rc1 test/mocks/mock_destination.rb
balinterdi-activewarehouse-etl-0.9.2 test/mocks/mock_destination.rb