Sha256: d23f7dd89d6d2db823d545677b9ddfab1dc32a2c294848e2641b0f8ba7fad823

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe SPS::DirectDebitTransaction do
  let(:structured_remittance_information) do
    SPS::StructuredRemittanceInformation.new(
      proprietary: 'ESR',
      reference:   '609323234234234353453423423'
    )
  end

  describe :initialize do
    it 'should create a valid transaction' do
      expect(
        SPS::DirectDebitTransaction.new(
          name:                      'Zahlemann & Söhne Gbr',
          iban:                      'CH7081232000001998736',
          amount:                    39.99,
          reference:                 'XYZ-1234/123',
          instruction:               '123',
          remittance_information:    'Vielen Dank für Ihren Einkauf!',
          structured_remittance_information: structured_remittance_information
        )
      ).to be_valid
    end
  end

  describe :schema_compatible? do
    context 'for pain.008.001.02.ch.03' do
      it 'should succeed for valid attributes' do
        expect(
          SPS::DirectDebitTransaction.new(
            structured_remittance_information: structured_remittance_information
          )
        ).to be_schema_compatible('pain.008.001.02.ch.03')
      end

      it 'should fail for invalid attributes' do
        expect(SPS::DirectDebitTransaction.new())
          .not_to be_schema_compatible('pain.008.001.02.ch.03')
      end
    end
  end

  context 'Requested date' do
    it 'should allow valid value' do
      expect(SPS::DirectDebitTransaction)
        .to accept(nil, Date.new(1999, 1, 1), Date.today.next, Date.today + 2, for: :requested_date)
    end

    it 'should not allow invalid value' do
      expect(SPS::DirectDebitTransaction)
        .not_to accept(Date.new(1995,12,21), Date.today - 1, Date.today, for: :requested_date)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sps_king-0.5.0 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.4.0 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.3.1 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.3.0 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.2.0 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.1.1 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb
sps_king-0.1.0 spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb