Slide 24
Slide 24 text
Rspec Stubbing
let(:video) { double.as_null_object }
before do
video
.stub(:time)
.and_return(14.minutes)
end
it {
user.watch(video)
expect(user.busy_for).to eq(14.minutes)
1 example, 0 failures
passes even if video.time
doesn’t exist
class User
...
def busy_for
current_video.time
end
...
end
class Video
def duration
...
end
Thursday, 26 September 13