require File.dirname(__FILE__) + '/../spec_helper' require 'etl' module ETL module Execution class Base < ETL::ActiveRecord::Base end end end describe "test.ctl" do before(:each) do #ETL::Engine.logger = Logger.new(STDOUT) #ETL::Engine.logger.level = Logger::DEBUG ETL::Execution::Base.should_receive(:establish_connection) require 'etl/execution' job = mock('job',:null_object => true) job.should_receive(:status=).with("completed") ETL::Execution::Job.should_receive(:create!).and_return(job) end after(:each) do @destination.should_receive(:close) ETL::Engine.process(@control_file) end def load(control_file,input_rows) @control_file = File.dirname(__FILE__) + '/' + control_file @control = ETL::Control::Control.resolve(@control_file) @source = ETL::Control::EnumerableSource.new(nil,{ :enumerable => input_rows},nil) @control.should_receive(:sources).and_return( [@source] ) @destination = mock("destination") @control.should_receive(:destinations).and_return( [@destination] ) ETL::Control::Control.should_receive(:resolve).with(@control_file).and_return(@control) end it "should store :first_name + :last_name under :name" do load 'test.ctl', [ {:first_name => 'john',:last_name => 'barry'} ] @destination.should_receive(:write).with( { :first_name => 'john', :last_name => 'barry', :name => 'john barry' } ) end end