Created
March 30, 2012 04:19
-
-
Save perryn/2246448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Duck | |
| def drink fluid | |
| bill.scoop(fluid) | |
| end | |
| end | |
| class Lion | |
| def drink fluid | |
| tongue.lap(fluid) | |
| end | |
| end | |
| class ZooKeeper | |
| def water animal | |
| animal.drink(WATER) | |
| end | |
| end | |
| #this doesn't help if I change the drink method 'interface' | |
| describe Zookeeper, 'water' do | |
| it 'ensures animal is hydrated' do | |
| animal = fire_double("Animal") | |
| animal.should_receive(:drink).with(WATER) | |
| Zookeeper.new.water(animal) | |
| end | |
| end | |
| #So instead I do this??? blech! | |
| describe Zookeeper, 'water' do | |
| it 'ensures duck is hydrated' do | |
| animal = fire_double("Duck") | |
| animal.should_receive(:drink).with(WATER) | |
| Zookeeper.new.water(animal) | |
| end | |
| it 'ensures lion is hydrated' do | |
| animal = fire_double("Lion") | |
| animal.should_receive(:drink).with(WATER) | |
| Zookeeper.new.water(animal) | |
| end | |
| end | |
| # I find myself returning to the position that I will write integration tests to tell me when I | |
| # have incompatible assumptions about 'interfaces', not unit tests | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment