Skip to content

Instantly share code, notes, and snippets.

@eyston
Created April 8, 2011 23:58
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 eyston/910952 to your computer and use it in GitHub Desktop.
Save eyston/910952 to your computer and use it in GitHub Desktop.
Please help this ruby idiot mock something
def MPQ path
path
end
class ReplayFile
def initailize path
@archive = MPQ(path)
end
end
# how do I mock MPQ in the context of ReplayFile's initializer?
# is trying to do this obviously stupid?
# this works (needs bang version), but not inside the initializer
# stub!(:MPQ).and_return("stub says hi")
# in a static language I would change the code to:
# class ReplayFile
# def initialize archive
# @archive = archive
# end
# end
# but like, my god, its ruby, I want to bend the universe to my will
@TrumpClone
Copy link

:\ dependency injection. do you hear about it? m>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment