Sha256: ff5dff5d5040698bbf35b60fc617975698dc1d50dd7818e603b7c4277f89546e

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe ACH::Batch do
  before(:each) do
    @batch = ACH::Batch.new
  end
  
  it "should create entry with attributes" do
    entry = @batch.entry :amount => 100
    entry.should be_instance_of(ACH::Entry)
    entry.amount.should == 100
  end
  
  it "should create entry with attributes" do
    entry = @batch.entry do
      amount 100
    end
    entry.amount.should == 100
  end
  
  it "should return false for has_credit? and has_debit? for empty entries" do
    @batch.has_credit?.should be_false
    @batch.has_debit?.should be_false
  end
  
  it "should return true for has_credit? if contains credit entry" do
    @batch.entry :amount => 100, :transaction_code => 21
    @batch.has_credit?.should be_true
  end
  
  it "should return true for has_debit? if contains debit entry" do
    @batch.entry :amount => 100
    @batch.has_debit?.should be_true
  end
  
  it "should generate 225 service_class_code for header if with debit entry only" do
    @batch.entry :amount => 100
    @batch.header.service_class_code.should == 225
  end
  
  it "should generate 220 service_class_code for header if with credit entry only" do
    @batch.entry :amount => 100, :transaction_code => 21
    @batch.header.service_class_code.should == 220
  end
  
  it "should generate 200 service_class_code for header if with debit and credit entries" do
    @batch.entry :amount => 100
    @batch.entry :amount => 100, :transaction_code => 21
    @batch.header.service_class_code.should == 200
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ach_builder-0.0.1.1 spec/batch_spec.rb