Sha256: 4adbf34e581eeeb59196a022534e922ab62357543966107db669175462905c5f

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

module Generalis
  module RSpec
    module ResolveAmountHelper
      # @param amount [Money, Numeric]
      # @param currency [String, nil]
      # @return [Money]
      def resolve_amount(amount, currency = nil)
        case amount
        when Money
          amount
        when Numeric
          Money.from_amount(amount, currency)
        else
          raise ArgumentError, "Expected Money or Numeric, got #{amount.inspect}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generalis-0.1.0 lib/rspec/helpers/resolve_amount_helper.rb