Skip to content

Instantly share code, notes, and snippets.

@npras
Created September 9, 2012 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npras/3683129 to your computer and use it in GitHub Desktop.
Save npras/3683129 to your computer and use it in GitHub Desktop.
Stubbing out a module
# 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