appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 270 forks source link

TyphoonDefinition withConfigName:bundle: does not behave as expected when running tests #602

Closed nicoabie closed 5 years ago

nicoabie commented 5 years ago

AFAIK That method was created because the former withConfigName assumed the main bundle which is not the case when running tests see this issue

Now withConfigName:bundle: accepts a bundle but does not work either when running as test target. For example this does not work as expected:

- (id)config {
    return [TyphoonDefinition withConfigName:@"SomeName-Info.plist" bundle:[NSBundle bundleForClass:[self class]]];
}

Instead a workaround should be made:

- (id)config {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSString *path = [bundle pathForResource:@"SomeName-Info" ofType:@"plist"];
    return [TyphoonDefinition withConfigPath:path];
}

I'm eager to help if needed.