Created
November 1, 2010 13:56
-
-
Save peter/658203 to your computer and use it in GitHub Desktop.
Avoid Stubbing Non-Existent Methods with Mocha
This file contains 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
# In spec_helper.rb or test_helper.rb: | |
Mocha::Configuration.prevent(:stubbing_non_existent_method) | |
module MochaExtensions | |
module ObjectMethods | |
def expects_message(*args, &block) | |
Mocha::Configuration.allow(:stubbing_non_existent_method) { expects(*args, &block) } | |
end | |
def stubs_message(*args, &block) | |
Mocha::Configuration.allow(:stubbing_non_existent_method) { stubs(*args, &block) } | |
end | |
end | |
end | |
class Object | |
include MochaExtensions::ObjectMethods | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment