Slide 4
Slide 4 text
Stub
(3/1)
Simple Stub w RSpec is usually:
allow(some_object).to receive(some_method).and_return(some_value)
Time.stub :now, Time.new(2023, 03, 07).utc do
MyObject.new.are_we_there_yet?
end
MiniTest, closer to pure ruby’ego we can for example:
Method now is stubbed on Time object and durin the testing of
MyObject we will always get now with the same value (when we call
are_we_there_yet? whic calls Time.now we will get the value of
Time.new(2023, 03, 07).utc)