Created
September 9, 2012 07:16
-
-
Save npras/3683129 to your computer and use it in GitHub Desktop.
Stubbing out a module
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
# spec/spec_helper_lite.rb | |
def stub_module(full_name) | |
full_name.to_s.split(/::/).inject(Object) do |context, name| | |
begin | |
context.const_get(name) | |
rescue NameError | |
context.const_set(name, Module.new) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment