Sha256: 208f08f508e0e94d9cfb70b6d38836265fb532d9a61bf9f82e746eeda213310e

Contents?: true

Size: 1.34 KB

Versions: 28

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::OrderRefreshes do
  include SpecHelpers::Client
  subject { FinApps::REST::OrderRefreshes.new(client) }

  describe '#create' do
    context 'when missing id' do
      let(:create) { subject.create(nil) }
      it do
        expect { create }.to raise_error(FinAppsCore::MissingArgumentsError)
      end
    end

    context 'when valid id is provided' do
      let(:create) { subject.create(:valid_id) }
      it { expect { create }.not_to raise_error }
      it('returns an array') { expect(create).to be_a(Array) }
      it('performs a post and returns new refreshed order response') do
        expect(create[RESULTS]).to have_key(:public_id)
        expect(create[RESULTS]).to have_key(:original_order_id)
      end
      it('returns no error messages') do
        expect(create[ERROR_MESSAGES]).to be_empty
      end
    end

    context 'when invalid id is provided' do
      let(:create) { subject.create(:invalid_id) }
      it { expect { create }.not_to raise_error }
      it('returns an array') { expect(create).to be_a(Array) }
      it('results is nil') { expect(create[RESULTS]).to be_nil }
      it('error messages array is populated') do
        expect(create[ERROR_MESSAGES].first.downcase).to eq(
          'resource not found'
        )
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/rest/order_refreshes_spec.rb
finapps-5.0.31 spec/rest/order_refreshes_spec.rb
finapps-5.0.30 spec/rest/order_refreshes_spec.rb
finapps-5.0.29 spec/rest/order_refreshes_spec.rb
finapps-5.0.28 spec/rest/order_refreshes_spec.rb
finapps-5.0.27 spec/rest/order_refreshes_spec.rb
finapps-5.0.26 spec/rest/order_refreshes_spec.rb
finapps-5.0.25 spec/rest/order_refreshes_spec.rb
finapps-5.0.24 spec/rest/order_refreshes_spec.rb
finapps-5.0.23 spec/rest/order_refreshes_spec.rb
finapps-5.0.22 spec/rest/order_refreshes_spec.rb
finapps-5.0.21 spec/rest/order_refreshes_spec.rb
finapps-5.0.20 spec/rest/order_refreshes_spec.rb
finapps-5.0.19 spec/rest/order_refreshes_spec.rb
finapps-5.0.17 spec/rest/order_refreshes_spec.rb
finapps-5.0.16 spec/rest/order_refreshes_spec.rb
finapps-5.0.15 spec/rest/order_refreshes_spec.rb
finapps-5.0.14 spec/rest/order_refreshes_spec.rb
finapps-5.0.13 spec/rest/order_refreshes_spec.rb
finapps-5.0.12 spec/rest/order_refreshes_spec.rb