Sha256: b47620cbb1e478f7e3811c854859e803ad1b5441d8a050db2d945786d5c53a86

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

RSpec.describe RockRMS::Response::Transaction, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('transactions.json')) }

  describe '.format' do
    subject(:result) { described_class.format(parsed) }

    context 'when response is array' do
      it 'returns an array' do
        expect(described_class.format([])).to be_a(Array)
      end
    end

    it 'translates keys' do
      result.zip(parsed) do |r, p|
        expect(r[:id]).to eq(p['Id'])
        expect(r[:date]).to eq(p['TransactionDateTime'])
        expect(r[:batch_id]).to eq(p['BatchId'])
        expect(r[:recurring_donation_id]).to eq(p['ScheduledTransactionId'])
        expect(r[:summary]).to eq(p['Summary'])
        expect(r[:transaction_code]).to eq(p['TransactionCode'])
        expect(r[:details]).to eq(
          RockRMS::Response::TransactionDetail.format(p['TransactionDetails'])
        )
        expect(r[:amount]).to eq(100.00)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rock_rms-3.0.2 spec/rock_rms/response/transaction_spec.rb
rock_rms-3.0.1 spec/rock_rms/response/transaction_spec.rb
rock_rms-3.0.0 spec/rock_rms/response/transaction_spec.rb