Last active
August 29, 2015 14:05
-
-
Save sethetter/5b708cb362cdabb67201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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