Created
March 29, 2012 02:21
-
-
Save geelen/2232573 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 Dependency | |
def self.foo | |
puts "Foo" | |
end | |
def self.bar | |
puts "Bar" | |
end | |
end | |
class ClassUnderTest | |
def self.go | |
Dependency.foo | |
Dependency.bar | |
end | |
end | |
describe ClassUnderTest do | |
it "should call dependencies" do | |
# This script prints "Bar" and passes. | |
# I want it to explode because calling Dependency.bar was not mocked out. | |
# i.e. I don't want to accidentally call a real method on the dependency. | |
# The only way I can see to do this is to add the following line, but that sucks: | |
# | |
# Dependency = mock | |
Dependency.should_receive(:foo) | |
ClassUnderTest.go | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment