However, in the game.rb file, we clearly see that output is an ARGUMENT to the intialize method.
Yes, this allows your test to pass in an output
object designed for testing. It gets saved with this code here:
def initialize(output)
@output = output
end
So then,
@outputs
, the instance variable and NOT the argument parameter, has puts "Welcome to Codebreaker!" called to it.
It's the same object because initialize
sets whatever was passed in as an argument to the instance variable @output
. This instance variable is now available in every instance method.
Why should this test pass when clearly output is not receiving :puts, but @output is?
Because it's the same object. The test passes the object in, it gets saved to @output
and then eventually puts
is called on it.