Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (32 sloc) 1.657 kb
#import "SpecHelper.h"
#import "Fixtures.h"
#import "ModuleFixtures.h"
SPEC_BEGIN(AddAndRemoveModulesSpecs)
__block SecondModule *module = nil;
__block JSObjectionInjector *injector = nil;
beforeEach(^{
module = [[SecondModule alloc] init];
gEagerSingletonHook = NO;
injector = [JSObjection createInjector:module];
});
it(@"builds a new injector with new modules", ^{
assertThat([injector getObject:@protocol(GearBox)], is(instanceOf([AfterMarketGearBox class])));
assertThat([injector getObject:[Car class]], isNot(instanceOf([FiveSpeedCar class])));
assertThatBool(gEagerSingletonHook, equalToBool(NO));
injector = [injector withModules:
[[ProviderModule alloc] init],
[[FirstModule alloc] init], nil];
assertThat([injector getObject:@protocol(GearBox)], is(instanceOf([AfterMarketGearBox class])));
assertThat([injector getObject:[Car class]], is(instanceOf([FiveSpeedCar class])));
assertThatBool(gEagerSingletonHook, equalToBool(YES));
});
it(@"builds a new module without the module types", ^{
injector = [injector withModules:
[[ProviderModule alloc] init], nil];
assertThat([injector getObject:@protocol(GearBox)], is(instanceOf([AfterMarketGearBox class])));
assertThat([injector getObject:[Car class]], is(instanceOf([FiveSpeedCar class])));
injector = [injector withoutModuleOfTypes:[SecondModule class], [ProviderModule class], nil];
assertThat([injector getObject:@protocol(GearBox)], is(nilValue()));
assertThat([injector getObject:[Car class]], isNot(instanceOf([FiveSpeedCar class])));
});
SPEC_END
Jump to Line
Something went wrong with that request. Please try again.