Skip to content

Instantly share code, notes, and snippets.

@sethetter
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save sethetter/5b708cb362cdabb67201 to your computer and use it in GitHub Desktop.

Select an option

Save sethetter/5b708cb362cdabb67201 to your computer and use it in GitHub Desktop.
# Importer::BridgeRow
#
# Associates a row with a transaction
# Determine new or existing employee, pass off to new/existing instance
# Sets messages and state on transaction after processing
require 'importer/transaction_factory'
module Importer
class BridgeRow
attr_accessor :transaction
def initialize(bridge, row)
raise NoBridgeError unless bridge
raise NoRowError unless row
@bridge, @row = bridge, row
@transaction = TransactionFactory.new
end
def process
end
end
end
class NoBridgeError < Exception; end
class NoRowError < Exception; end
require 'importer/bridge_row'
describe Importer::BridgeRow do
before :each do
@bridge = double
@row = ['0', 'Jim', 'Rice']
end
it 'should raise an exception if no bridge is given' do
expect { Importer::BridgeRow.new(nil, @row) }.to raise_exception NoBridgeError
end
it 'should raise an exception if no row is given' do
expect { Importer::BridgeRow.new(@bridge, nil) }.to raise_exception NoRowError
end
context 'initialized with proper arity' do
before :each do
@bridge_row = Importer::BridgeRow.new(@bridge, @row)
end
it 'should create an associated transaction' do
expect(@bridge_row.transaction).to be_a(TransactionFactory)
end
end
end
class ImportTransaction; end
class TransactionFactory
def initialize
ImportTransaction.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment