Last active
August 29, 2015 14:04
-
-
Save chrisphelps/edb18992ff82c4d248e5 to your computer and use it in GitHub Desktop.
Implicit arguments for mocking
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
class Foo (name: String) { | |
def apply() = "Foo " + name + "results" | |
} | |
class Bar(name: String) { | |
def apply()(implicit f: Foo) = "Bar" + name + "results: " + f() | |
} | |
class Baz { | |
implicit val myfoo = new Foo("production") | |
val mybar = new Bar("production") | |
def apply() = mybar() | |
} | |
class Quux { | |
implicit val testfoo = new Foo("test") | |
val mybar = new Bar("production") | |
def apply() = mybar() | |
} | |
val mybaz = new Baz | |
val myquux = new Quux | |
mybaz() | |
myquux() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment