Sha256: c89fd9af0a693f3b8c776434bef447e7a8d5c5081a4b6960d54d478b991e3e17

Contents?: true

Size: 933 Bytes

Versions: 16

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

RSpec.shared_examples 'a valid operation' do
  it 'is valid' do
    instance = described_class.new(resource: resource, client: client)
    if ENV.fetch('DEBUG', false) && !instance.valid?
      pd instance.errors
      byebug if ENV['DEBUG'] # rubocop:disable Lint/Debugger
    end
    expect(instance).to be_valid
  end
end

RSpec.shared_examples 'a successful operation' do |stubs: []|
  before do
    stubs = Array(stubs)
    stubs.each do |stub|
      if stub.is_a?(Array)
        send(*stub)
      else
        send(stub)
      end
    end
  end

  it 'is successful' do
    result = described_class.new(resource: resource, client: client).perform
    byebug if ENV.fetch('DEBUG', false) && result.failure? # rubocop:disable Lint/Debugger
    expect(result).to be_a(LedgerSync::OperationResult::Success)
  end
end

RSpec.shared_examples 'an operation' do
  it_behaves_like 'a valid operation'
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ledger_sync-2.6.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.5.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.4.4 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.3.1 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.2.3 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.2.1 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.2.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.0.2 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.0.1 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.0.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-1.8.1 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-1.8.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-1.7.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-1.6.0 lib/ledger_sync/test/support/operation_shared_examples.rb
ledger_sync-1.5.2 lib/ledger_sync/test/support/operation_shared_examples.rb