Skip to content

Instantly share code, notes, and snippets.

@guillec
Last active March 21, 2018 19:27
Show Gist options
  • Save guillec/848dcb88c756d4ba34e71416d1b4a262 to your computer and use it in GitHub Desktop.
Save guillec/848dcb88c756d4ba34e71416d1b4a262 to your computer and use it in GitHub Desktop.
class Voyage
def prepare_voyage(vessel)
vessel.prepare
end
end
class Vessel
def prepare
.. do stuff ..
end
end
.. test ..
class VoyageTest
test "should prepare a vessel" do
os = OpenStruct.new(:prepare)
assert Voyage.new.prepare_voyage(os)
end
end
## If we update vessel to not have a prepare method ##
class Vessel
def not_prepare
.. do stuff ..
end
end
Our unit test for vessel will fail because prepare will no longer exists but we caught it and we can fix it.
Our unit test for voyage will pass because we are passing in a os that responds to prepare.
Our production work will fail because vessel no longer responds to prepare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment