Skip to content

Instantly share code, notes, and snippets.

@eyston
Created Apr 8, 2011
Embed
What would you like to do?
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

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