From 62217c70d8fbaec5ba7878033228e560850d876c Mon Sep 17 00:00:00 2001 From: cheyueyong Date: Wed, 8 Feb 2017 14:21:07 +0800 Subject: [PATCH] fix https://github.com/kiwi-bdd/Kiwi/issues/689 --- Classes/Core/KWSpec.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Classes/Core/KWSpec.m b/Classes/Core/KWSpec.m index 3e845170..9e92cfcf 100644 --- a/Classes/Core/KWSpec.m +++ b/Classes/Core/KWSpec.m @@ -19,6 +19,8 @@ @interface KWSpec() @end +NSMutableDictionary *kw_examples; + @implementation KWSpec /* Methods are only implemented by sub-classes */ @@ -31,6 +33,12 @@ - (NSString *)name { return [self description]; } ++ (void)initialize { + kw_examples = [NSMutableDictionary new]; + [self testInvocations]; +} + + /* Use camel case to make method friendly names from example description. */ - (NSString *)description { @@ -58,6 +66,7 @@ + (NSArray *)testInvocations { for (KWExample *example in exampleSuite) { SEL selector = [self addInstanceMethodForExample:example]; NSInvocation *invocation = [self invocationForExample:example selector:selector]; + [kw_examples setObject:example forKey:NSStringFromSelector(invocation.selector)]; [invocations addObject:invocation]; } @@ -114,7 +123,9 @@ + (BOOL)respondsToSelector:(SEL)aSelector { - (void)runExample { self.currentExample = self.invocation.kw_example; - + if (self.currentExample == nil) { + self.currentExample = [kw_examples objectForKey:NSStringFromSelector(self.invocation.selector)]; + } @try { [self.currentExample runWithDelegate:self]; } @catch (NSException *exception) {