You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that you're writing a spec for a class under test (DogPicsViewController)
Given that you accidentally include ImageFetcher in your application target (DogPics) and your test target (DogPicsSpecs) that calls the main application it's host (DogPics is the host application of DogPicsSpecs)
Given than you inject a custom implementation (FakeImageFetcher) of a dependency of the class under test into the injector [injector bind:[ImageFetcher class] toInstance: fakeImageFetcher]
Given that you ask for an instance of that class (ImageFetcher) in the class under test, either through bsinitializer or bsproperties
When the injector goes to grab the requested ImageFetcher for the class DogPicsViewController while running a spec, it will initialize a new instance of ImageFetcher even though you've faked out and bound an instance in your specs.
This happens because you've included your ImageFetcher in both your host application and spec bundles.
To somebody who hasn't already encountered this a few times, this behavior is totally impossible to figure out ("why's it not getting the thing I just bound? Aren't these two classes equal?")
The injector should warn the user that this is happening.
The text was updated successfully, but these errors were encountered:
Given that you're writing a spec for a class under test (
DogPicsViewController
)Given that you accidentally include
ImageFetcher
in your application target (DogPics
) and your test target (DogPicsSpecs
) that calls the main application it's host (DogPics
is the host application ofDogPicsSpecs
)Given than you inject a custom implementation (
FakeImageFetcher
) of a dependency of the class under test into the injector[injector bind:[ImageFetcher class] toInstance: fakeImageFetcher]
Given that you ask for an instance of that class (
ImageFetcher
) in the class under test, either through bsinitializer or bspropertiesWhen the injector goes to grab the requested
ImageFetcher
for the classDogPicsViewController
while running a spec, it will initialize a new instance ofImageFetcher
even though you've faked out and bound an instance in your specs.This happens because you've included your
ImageFetcher
in both your host application and spec bundles.To somebody who hasn't already encountered this a few times, this behavior is totally impossible to figure out ("why's it not getting the thing I just bound? Aren't these two classes equal?")
The injector should warn the user that this is happening.
The text was updated successfully, but these errors were encountered: