Skip to content

Instantly share code, notes, and snippets.

@perryn
Created March 30, 2012 04:19
Show Gist options
  • Select an option

  • Save perryn/2246448 to your computer and use it in GitHub Desktop.

Select an option

Save perryn/2246448 to your computer and use it in GitHub Desktop.
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