Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/baza-rb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ def transfer(recipient, amount, summary, job: nil, badge: nil)
# @raise [ServerFailure] If the payment fails
def fee(tab, amount, summary, job)
raise(RuntimeError, 'The "tab" is nil') if tab.nil?
raise(RuntimeError, 'The "tab" may not be empty') if tab.empty?
raise(RuntimeError, 'The "amount" is nil') if amount.nil?
unless amount.is_a?(Float) || amount.is_a?(BigDecimal)
raise(RuntimeError, 'The "amount" must be Float or BigDecimal')
Expand Down
1 change: 1 addition & 0 deletions lib/baza-rb/fake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def transfer(recipient, amount, summary, job: nil, badge: nil)
# @return [Integer] Always returns 42 as the fake receipt ID
def fee(tab, amount, summary, job)
raise(RuntimeError, 'The "tab" is nil') if tab.nil?
raise(RuntimeError, 'The "tab" may not be empty') if tab.empty?
raise(RuntimeError, 'The "amount" is nil') if amount.nil?
unless amount.is_a?(Float) || amount.is_a?(BigDecimal)
raise(RuntimeError, 'The "amount" must be Float or BigDecimal')
Expand Down
7 changes: 7 additions & 0 deletions test/test_baza_edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,13 @@ def test_fee_raises_when_amount_is_not_positive
end
end

def test_fee_raises_when_tab_is_empty
assert_equal(
'The "tab" may not be empty',
assert_raises(RuntimeError) { fake_baza.fee('', 1.0, 'pay', 42) }.message
)
end

def test_fee_raises_when_summary_is_empty
assert_equal(
'The summary "" is empty',
Expand Down
7 changes: 7 additions & 0 deletions test/test_fake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ def test_fee_raises_when_amount_is_not_positive
)
end

def test_fee_raises_when_tab_is_empty
assert_equal(
'The "tab" may not be empty',
assert_raises(RuntimeError) { BazaRb::Fake.new.fee('', 1.0, 'for fun', 44) }.message
)
end

def test_fee_raises_when_job_is_not_positive
assert_equal(
'The "job" must be positive',
Expand Down
Loading