Sha256: 01df7c36df5f3f7ac93dd46d6ad77004fa1c16e522331711b1eb24b0ef9b4acd
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
# encoding: utf-8 require 'spec_helper' class DummyTransaction < SEPA::Transaction def valid?; true end end class DummyMessage < SEPA::Message self.account_class = SEPA::Account self.transaction_class = DummyTransaction end describe SEPA::Message do describe :amount_total do subject do message = DummyMessage.new message.add_transaction amount: 1.1 message.add_transaction amount: 2.2 message end it 'should sum up all transactions' do expect(subject.amount_total).to eq(3.3) end it 'should sum up selected transactions' do expect(subject.amount_total([subject.transactions[0]])).to eq(1.1) end end describe 'validation' do subject { DummyMessage.new } it 'should fail with invalid account' do expect(subject).not_to be_valid expect(subject.errors_on(:account).size).to eq(2) end it 'should fail without transactions' do expect(subject).not_to be_valid expect(subject.errors_on(:transactions).size).to eq(1) end end describe :message_identification do subject { DummyMessage.new } it 'should have a reader method' do expect(subject.message_identification).to match(/SEPA-KING\/[0-9]+/) end it 'should have a writer method' do subject.message_identification = "MY_MESSAGE_ID/#{Time.now.to_i}" expect(subject.message_identification).to match(/MY_MESSAGE_ID/) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sepa_king-0.6.0 | spec/message_spec.rb |
sepa_king-0.5.0 | spec/message_spec.rb |
sepa_king-0.4.0 | spec/message_spec.rb |