I’m having an issue with minitest. Consider this (simplified) example test
# The test
test "the truth" do
assert_equal true, ParentalLeaveCalculator.new(@employee).check_parental_leave_paid(@timesheet, 1, 8)
end
# The method
def check_parental_leave_paid(timesheet, day, current_hours)
...
used_hours_paid = calculate_used_hours_paid(current_hours)
puts "USED HOURS: #{used_hours_paid}"
...
end
# The test result
USED HOURS: 361.0
USED HOURS: 16.0
F
It does 1 assertion by calling the ParentalLeaveCalculator. Why does it show the puts twice when running the test?
No chance #check_parental_leave_paid is being called in the ParentalLeaveCalculator model’s initializer or anywhere else? (Or maybe as some by-product of calling #calculate_used_hours_paid?)
If you put this line at the top of #check_parental_leave_paid it will dump out a short trace of the last 5 places leading up to where it has been called from!