Skip to content

Instantly share code, notes, and snippets.

@usutani
Last active June 14, 2020 06:48
Show Gist options
  • Select an option

  • Save usutani/72db9dcf90d496e6c4f57a46f5bc2fad to your computer and use it in GitHub Desktop.

Select an option

Save usutani/72db9dcf90d496e6c4f57a46f5bc2fad to your computer and use it in GitHub Desktop.
オブジェクト指向設計実践ガイド 9章 ダックタイプをテストする
# frozen_string_literal: true
class Trip
def prepare(preparers)
# ...
preparers.each do |preparer|
preparer.prepare_trip(foo: self)
end
# ...
end
end
# Chapter 9: Designing Cost-Effective Tests
# Testing Duck Type
require 'minitest/autorun'
class TripTest < Minitest::Test
def test_requests_trip_preparation
@preparer = Minitest::Mock.new
@trip = Trip.new
@preparer.expect(:prepare_trip, nil, [foo: @trip])
@trip.prepare([@preparer])
@preparer.verify
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment