Skip to content

Instantly share code, notes, and snippets.

Created Apr 8, 2011
What would you like to do?
Please help this ruby idiot mock something
def MPQ path
class ReplayFile
def initailize path
@archive = MPQ(path)
# 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
Copy link

TrumpClone commented May 26, 2017

:\ 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