Module: Generalis::RSpec::ResolveAmountHelper

Defined in:
lib/rspec/helpers/resolve_amount_helper.rb

Instance Method Summary collapse

Instance Method Details

#resolve_amount(amount, currency = nil) ⇒ Money

Parameters:

  • amount (Money, Numeric)
  • currency (String, nil) (defaults to: nil)

Returns:

  • (Money)


9
10
11
12
13
14
15
16
17
18
# File 'lib/rspec/helpers/resolve_amount_helper.rb', line 9

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