Sha256: 50dbb84cf7aabb0c4686a9405594e210bc3050349472112237beb3e594e30348

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

module BicValidation
  describe Bic do
    context 'with bogus data' do
      it 'survives nil data' do
        bic = Bic.new(nil)
        expect(bic).to be_invalid
      end

      it 'survives integer data' do
        bic = Bic.new(123)
        expect(bic).to be_invalid
      end

      it 'survives float data' do
        bic = Bic.new(1.23)
        expect(bic).to be_invalid
      end
    end

    context 'basic methods 11 digit' do
      before { @bic = Bic.new 'MARKDEF1850' }

      subject { @bic }

      describe '#valid?' do
        it { should be_valid }
      end

      describe '#known?' do
        it { should be_known }
      end

      describe '#bank' do
        its(:bank) { should eq('MARK') }
      end

      describe '#country' do
        its(:country) { should eq('DE') }
      end

      describe '#location' do
        its(:location) { should eq('F1') }
      end

      describe '#branch' do
        its(:branch) { should eq('850') }
      end
    end

    context 'basic methods 8 digit' do
      before { @bic = Bic.new 'DEUTDEBB' }

      subject { @bic }

      describe '#valid?' do
        it { should be_valid }
      end

      describe '#known?' do
        it { should be_known }
      end

      describe '#bank' do
        its(:bank) { should eq('DEUT') }
      end

      describe '#country' do
        its(:country) { should eq('DE') }
      end

      describe '#location' do
        its(:location) { should eq('BB') }
      end

      describe '#branch' do
        its(:branch) { should be_nil }
      end
    end

    ['DEUTDEBB', 'CRESCHZZ10S', 'UBSWCHZH86N', 'OEKOATWWXXX',
     'OEKOATWW', 'BTRLRO22'].each do |swift|
      describe 'validity checks' do
        it "validates #{swift}" do
          bic = Bic.new(swift)
          expect(bic).to be_valid
          expect(bic).to be_known
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bic_validation-0.3.1 spec/bic_validation/bic_spec.rb