Say I have the following method:
#Create new guest object. Add it to array and save it to disc
def new_guest
printf "First name: "
first_name = gets.chomp
printf "Last name: "
last_name = gets.chomp
printf "Adress: "
adress = gets.chomp
printf "Phone:"
phone = gets.chomp
new_guest = Guest.new(first_name, last_name, adress, phone)
@guests.push(new_guest)
File.open("guests", 'w') {|f| Marshal.dump(@guests, f) }
end
How would I write a unit test for it that can pass in values for the gets? All I found was this article but I don't know how to use it in this case. Im also wondering if there is a good way to mark things that should not run when run from a test? I might not want to save the dummy objects for example.