Hello everyone, I just reviewed the weekly iteration, “Stubs, Mocks, Spies, and Fakes”. It is really good and I enjoy it. I have a few questions regarding the code in the video.
describe "#solution" do
solution = double("solution")
clone = double("clone", solution: solution)
participation = Participation.new(clone: clone)
result = participation.solution
expect(clone).to have_received(:solution)
expect(result).to eq(solution)
end
Firstly, what’s the differences between Participation.new(clone: clone)
and Participation.new(clone)
? Are there any reasons we should use which one other than another?
In addition, since we are have clone = double("clone", solution: solution)
, shouldn’t the receiver of solution
method be clone
instead of participation
?
(like, result = clone.solution
)
These are my questions regarding the video. Thank you!