budget/test/system/expenses_test.rb
Andrew Tomaka e1a7f4fbbd
All checks were successful
continuous-integration/drone/push Build is passing
Add some model tests (#9)
Reviewed-on: #9
2023-11-22 21:41:03 -05:00

49 lines
1.3 KiB
Ruby

require "application_system_test_case"
class ExpensesTest < ApplicationSystemTestCase
setup do
@expense = expenses(:monthly_expense)
end
test "visiting the index" do
visit expenses_url
assert_selector "h1", text: "Expenses"
end
test "should create expense" do
visit expenses_url
click_on "New expense"
check "Credit card" if @expense.credit_card
fill_in "Description", with: @expense.description
check "Estimated" if @expense.estimated
fill_in "Payment", with: @expense.payment
select @expense.period.capitalize, from: "Period"
click_on "Create Expense"
assert_text "Expense was successfully created"
click_on "Back"
end
test "should update Expense" do
visit expense_url(@expense)
click_on "Edit this expense", match: :first
check "Credit card" if @expense.credit_card
fill_in "Description", with: @expense.description
check "Estimated" if @expense.estimated
fill_in "Payment", with: @expense.payment
select @expense.period.capitalize, from: "Period"
click_on "Update Expense"
assert_text "Expense was successfully updated"
click_on "Back"
end
test "should destroy Expense" do
visit expense_url(@expense)
click_on "Destroy this expense", match: :first
assert_text "Expense was successfully destroyed"
end
end