Sha256: 3a2d80ede7ebbb46d45d3c9c0c0eb3fb55672e65a9512d8e52b8fa39c310abc6

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

require_relative '../context/hook_context'
require_relative '../../lib/mangopay/api/service/hooks'
require_relative '../../lib/mangopay/model/enum/hook_status'
require_relative '../../lib/mangopay/common/sort_field'
require_relative '../../lib/mangopay/common/sort_direction'

describe MangoApi::Hooks do
  include_context 'hook_context'


  describe '.create' do

    context 'given a valid object' do
      hook = HOOK_DATA

      it 'creates the hook entity' do
        expect { MangoApi::Hooks.create hook }.to raise_error(MangoPay::ResponseError, /already.+registered/)
      end
    end
  end

  describe '.update' do

    context 'given a valid object' do
      url = 'https://www.hello.com/hook'
      status = MangoModel::HookStatus::DISABLED
      created = HOOK_PERSISTED
      created.url = url
      created.status = status

      it 'updates the corresponding entity' do
        updated = MangoApi::Hooks.update created

        expect(updated).to be_kind_of MangoModel::Hook
        expect(updated.id).to eq created.id
        expect(updated.url).to eq url
        expect(updated.status).to be status
      end
    end
  end

  describe '.get' do

    context "given an existing entity's ID" do
      id = HOOK_PERSISTED.id

      it 'retrieves the corresponding entity' do
        retrieved = MangoApi::Hooks.get id

        expect(retrieved).to be_kind_of MangoModel::Hook
        expect(retrieved.id).to eq id
      end
    end
  end

  describe '.all' do

    context 'not having specified filters' do

      it 'retrieves list of all events' do
        results = MangoApi::Hooks.all

        expect(results).to be_kind_of Array
        results.each do |result|
          expect(result).to be_kind_of MangoModel::Hook
          expect(result.id).not_to be_nil
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-v4-4.1.0 spec/mangopay/hooks_spec.rb
mangopay-v4-4.0.2 spec/mangopay/hooks_spec.rb
mangopay-v4-4.0.1 spec/mangopay/hooks_spec.rb