Skip to content

Commit

Permalink
Improve invoice_form_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Feb 28, 2024
1 parent e1d41fb commit cf00121
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/integration/invoice_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ class NewInvoiceTest < ActionDispatch::IntegrationTest
end

test 'sets calculated total on page load' do
expected_total = '%.2f' % (billable_hours * rate).round(2)

text_on_page =
find('#invoice_total_amount')
.text
.delete("'")
.delete('&#39;')
expected_total = delimited_number(billable_hours * rate)
text_on_page = find('#invoice_total_amount').text

assert_match expected_total, text_on_page
end
Expand Down Expand Up @@ -213,4 +208,12 @@ def assert_checkboxes(checkboxes, models, checked = models)
send assertion, checkboxes.find { |checkbox| checkbox.value == model.id.to_s }.checked?
end
end

def delimited_number(number)
ActiveSupport::NumberHelper.number_to_rounded(
number,
precision: 2,
delimiter: "'"
)
end
end

0 comments on commit cf00121

Please sign in to comment.