Skip to content

Commit

Permalink
SpecHelper -> CDRSpecHelper
Browse files Browse the repository at this point in the history
- SpecHelper.h is retained for compatibility with a deprecation warning,
  as it is likely to be imported at the top of users' spec files.
  • Loading branch information
Brian Croom committed May 8, 2014
1 parent 490df9e commit bc9791c
Show file tree
Hide file tree
Showing 68 changed files with 224 additions and 213 deletions.
100 changes: 53 additions & 47 deletions Cedar.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion OCUnitAppLogicTests/OCUnitAppLogicTests.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "DummyModel.h" // should be included in OCUnitAppLogicTests target

using namespace Cedar::Matchers;
Expand Down
2 changes: 1 addition & 1 deletion OCUnitAppTests/OCUnitApplicationTests.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "OCUnitAppAppDelegate.h" // should NOT be included in OCUnitAppTests target

using namespace Cedar::Matchers;
Expand Down
2 changes: 1 addition & 1 deletion Source/CDRExample.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "CDRExample.h"
#import "CDRSpecFailure.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRReportDispatcher.h"

const CDRSpecBlock PENDING = nil;
Expand Down
4 changes: 2 additions & 2 deletions Source/CDRExampleBase.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "CDRExampleBase.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRReportDispatcher.h"

@implementation CDRExampleBase
Expand Down Expand Up @@ -34,7 +34,7 @@ - (void)runWithDispatcher:(CDRReportDispatcher *)dispatcher {
}

- (BOOL)shouldRun {
BOOL shouldOnlyRunFocused = [SpecHelper specHelper].shouldOnlyRunFocused;
BOOL shouldOnlyRunFocused = [CDRSpecHelper specHelper].shouldOnlyRunFocused;
return !shouldOnlyRunFocused || (shouldOnlyRunFocused && (self.isFocused || parent_.shouldRun));
}

Expand Down
10 changes: 5 additions & 5 deletions Source/CDRFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import "CDRExampleGroup.h"
#import "CDRExampleReporter.h"
#import "CDRDefaultReporter.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRFunctions.h"
#import "CDRReportDispatcher.h"
#import "CDROTestNamer.h"
Expand Down Expand Up @@ -65,11 +65,11 @@ BOOL CDRClassHasClassMethod(Class class, SEL selector) {
}

void CDRDefineGlobalBeforeAndAfterEachBlocks() {
[SpecHelper specHelper].globalBeforeEachClasses = CDRSelectClasses(^BOOL(Class class) {
[CDRSpecHelper specHelper].globalBeforeEachClasses = CDRSelectClasses(^BOOL(Class class) {
return CDRClassHasClassMethod(class, @selector(beforeEach));
});

[SpecHelper specHelper].globalAfterEachClasses = CDRSelectClasses(^BOOL(Class class) {
[CDRSpecHelper specHelper].globalAfterEachClasses = CDRSelectClasses(^BOOL(Class class) {
return CDRClassHasClassMethod(class, @selector(afterEach));
});
}
Expand Down Expand Up @@ -156,7 +156,7 @@ void CDRMarkFocusedExamplesInSpecs(NSArray *specs) {
}

for (CDRSpec *spec in specs) {
SpecHelper.specHelper.shouldOnlyRunFocused |= spec.rootGroup.hasFocusedExamples;
CDRSpecHelper.specHelper.shouldOnlyRunFocused |= spec.rootGroup.hasFocusedExamples;
}
}

Expand Down Expand Up @@ -220,7 +220,7 @@ void CDRMarkXcodeFocusedExamplesInSpecs(NSArray *specs, NSArray *arguments) {
[testNamer release];

for (CDRSpec *spec in specs) {
SpecHelper.specHelper.shouldOnlyRunFocused |= spec.rootGroup.hasFocusedExamples;
CDRSpecHelper.specHelper.shouldOnlyRunFocused |= spec.rootGroup.hasFocusedExamples;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Source/CDRSharedExampleGroupPool.m
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#import "CDRSharedExampleGroupPool.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRSpec.h"
#import "CDRExampleGroup.h"
#import "CDRSpecFailure.h"

extern CDRSpec *currentSpec;

@interface SpecHelper (CDRSharedExampleGroupPoolFriend)
@interface CDRSpecHelper (CDRSharedExampleGroupPoolFriend)
@property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleGroups;
@end

void sharedExamplesFor(NSString *groupName, CDRSharedExampleGroupBlock block) {
[[[SpecHelper specHelper] sharedExampleGroups] setObject:[[block copy] autorelease] forKey:groupName];
[[[CDRSpecHelper specHelper] sharedExampleGroups] setObject:[[block copy] autorelease] forKey:groupName];
}

void itShouldBehaveLike(NSString *groupName) {
CDRSharedExampleGroupBlock sharedExampleGroupBlock = [[[SpecHelper specHelper] sharedExampleGroups] objectForKey:groupName];
CDRSharedExampleGroupBlock sharedExampleGroupBlock = [[[CDRSpecHelper specHelper] sharedExampleGroups] objectForKey:groupName];
if (!sharedExampleGroupBlock) {
NSString *message = [NSString stringWithFormat:@"Unknown shared example group with description: '%@'", groupName];
[[NSException exceptionWithName:NSInternalInconsistencyException reason:message userInfo:nil] raise];
Expand All @@ -25,7 +25,7 @@ void itShouldBehaveLike(NSString *groupName) {
currentSpec.currentGroup = [CDRExampleGroup groupWithText:[NSString stringWithFormat:@"(as %@)", groupName]];
[parentGroup add:currentSpec.currentGroup];

sharedExampleGroupBlock([SpecHelper specHelper].sharedExampleContext);
sharedExampleGroupBlock([CDRSpecHelper specHelper].sharedExampleContext);
currentSpec.currentGroup = parentGroup;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/CDRSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "CDRExample.h"
#import "CDRExampleGroup.h"
#import "CDRSpecFailure.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRSymbolicator.h"

CDRSpec *currentSpec;
Expand Down Expand Up @@ -98,7 +98,7 @@ @implementation CDRSpec
- (id)init {
if (self = [super init]) {
self.rootGroup = [[[CDRExampleGroup alloc] initWithText:[[self class] description] isRoot:YES] autorelease];
self.rootGroup.parent = [SpecHelper specHelper];
self.rootGroup.parent = [CDRSpecHelper specHelper];
self.currentGroup = self.rootGroup;
self.symbolicator = [[[CDRSymbolicator alloc] init] autorelease];
}
Expand Down
10 changes: 5 additions & 5 deletions Source/SpecHelper.m → Source/CDRSpecHelper.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import "SpecHelper.h"
#import "CDRSpecHelper.h"

static SpecHelper *specHelper__;
static CDRSpecHelper *specHelper__;

@interface SpecHelper ()
@interface CDRSpecHelper ()
@property (nonatomic, retain, readwrite) NSMutableDictionary *sharedExampleGroups, *sharedExampleContext;
@end

@implementation SpecHelper
@implementation CDRSpecHelper

@synthesize
sharedExampleGroups = sharedExampleGroups_,
Expand All @@ -17,7 +17,7 @@ @implementation SpecHelper

+ (id)specHelper {
if (!specHelper__) {
specHelper__ = [[SpecHelper alloc] init];
specHelper__ = [[CDRSpecHelper alloc] init];
}
return specHelper__;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Headers/CDRSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "CDRExampleBase.h"

@protocol CDRExampleReporter;
@class CDRExampleGroup, CDRExample, SpecHelper, CDRSymbolicator;
@class CDRExampleGroup, CDRExample, CDRSpecHelper, CDRSymbolicator;

@protocol CDRSpec
@end
Expand Down
21 changes: 21 additions & 0 deletions Source/Headers/CDRSpecHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#import "CDRSpec.h"
#import "CDRHooks.h"
#import "CDRSharedExampleGroupPool.h"
#import "CDRExampleParent.h"

@interface CDRSpecHelper : NSObject <CDRExampleParent> {
NSMutableDictionary *sharedExampleContext_, *sharedExampleGroups_;
NSArray *globalBeforeEachClasses_, *globalAfterEachClasses_;
BOOL shouldOnlyRunFocused_;
}

@property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleContext;
@property (nonatomic, retain) NSArray *globalBeforeEachClasses, *globalAfterEachClasses;

@property (nonatomic, assign) BOOL shouldOnlyRunFocused;

+ (CDRSpecHelper *)specHelper;

@end

@compatibility_alias SpecHelper CDRSpecHelper;
2 changes: 1 addition & 1 deletion Source/Headers/Cedar.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#import "CDRFunctions.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
20 changes: 2 additions & 18 deletions Source/Headers/SpecHelper.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
#import "CDRSpec.h"
#import "CDRHooks.h"
#import "CDRSharedExampleGroupPool.h"
#import "CDRExampleParent.h"
#import "CDRSpecHelper.h"

@interface SpecHelper : NSObject <CDRExampleParent> {
NSMutableDictionary *sharedExampleContext_, *sharedExampleGroups_;
NSArray *globalBeforeEachClasses_, *globalAfterEachClasses_;
BOOL shouldOnlyRunFocused_;
}

@property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleContext;
@property (nonatomic, retain) NSArray *globalBeforeEachClasses, *globalAfterEachClasses;

@property (nonatomic, assign) BOOL shouldOnlyRunFocused;

+ (SpecHelper *)specHelper;

@end
#warning SpecHelper is deprecated. Please import Cedar.h or Cedar-iOS.h and use CDRSpecHelper instead.
4 changes: 2 additions & 2 deletions Source/Reporters/CDRDefaultReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "CDRExample.h"
#import "CDRExampleGroup.h"
#import "CDRSymbolicator.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRSlowTestStatistics.h"

@interface CDRDefaultReporter (private)
Expand Down Expand Up @@ -60,7 +60,7 @@ - (void)runDidComplete {
}

- (int)result {
if ([SpecHelper specHelper].shouldOnlyRunFocused || [failureMessages_ count]) {
if ([CDRSpecHelper specHelper].shouldOnlyRunFocused || [failureMessages_ count]) {
return 1;
} else {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions Source/Reporters/CDROTestReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "CDRFunctions.h"
#import "CDRExample.h"
#import "CDRExampleGroup.h"
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRSpec.h"
#import "CDROTestNamer.h"

Expand Down Expand Up @@ -120,7 +120,7 @@ - (void)logMessage:(NSString *)message {
#pragma mark - Private

- (BOOL)isFocused {
return [SpecHelper specHelper].shouldOnlyRunFocused;
return [CDRSpecHelper specHelper].shouldOnlyRunFocused;
}

- (NSString *)rootSuiteName {
Expand Down
4 changes: 2 additions & 2 deletions Spec/CDRExampleGroupSpec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Normally you would include this file out of the framework. However, we're
// testing the framework here, so including the file from the framework will
// conflict with the compiler attempting to include the file from the project.
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#else
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#endif

#import "CDRExampleBase.h"
Expand Down
16 changes: 8 additions & 8 deletions Spec/CDRExampleSpec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Normally you would include this file out of the framework. However, we're
// testing the framework here, so including the file from the framework will
// conflict with the compiler attempting to include the file from the project.
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#else
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#endif

#import "CDRExample.h"
Expand All @@ -19,12 +19,12 @@
using namespace Cedar::Doubles;

void (^runInFocusedSpecsMode)(CDRExampleBase *, CDRReportDispatcher *) = ^(CDRExampleBase *example, CDRReportDispatcher *dispatcher) {
BOOL before = [SpecHelper specHelper].shouldOnlyRunFocused;
[SpecHelper specHelper].shouldOnlyRunFocused = YES;
BOOL before = [CDRSpecHelper specHelper].shouldOnlyRunFocused;
[CDRSpecHelper specHelper].shouldOnlyRunFocused = YES;
@try {
[example runWithDispatcher:dispatcher];
} @finally {
[SpecHelper specHelper].shouldOnlyRunFocused = before;
[CDRSpecHelper specHelper].shouldOnlyRunFocused = before;
}
};

Expand Down Expand Up @@ -140,13 +140,13 @@
example = [[[CDRExample alloc] initWithText:exampleText andBlock:^{}] autorelease];

// if you focus any of these specs, they will fail without this
beforeFocused = [SpecHelper specHelper].shouldOnlyRunFocused;
[SpecHelper specHelper].shouldOnlyRunFocused = NO;
beforeFocused = [CDRSpecHelper specHelper].shouldOnlyRunFocused;
[CDRSpecHelper specHelper].shouldOnlyRunFocused = NO;
// end
});

afterEach(^{
[SpecHelper specHelper].shouldOnlyRunFocused = beforeFocused;
[CDRSpecHelper specHelper].shouldOnlyRunFocused = beforeFocused;
});

describe(@"runWithDispatcher:", ^{
Expand Down
4 changes: 2 additions & 2 deletions Spec/CDRSpecFailureSpec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Normally you would include this file out of the framework. However, we're
// testing the framework here, so including the file from the framework will
// conflict with the compiler attempting to include the file from the project.
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#else
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#endif

#import "CDRSpecFailure.h"
Expand Down
4 changes: 2 additions & 2 deletions Spec/CDRSpecSpec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Normally you would include this file out of the framework. However, we're
// testing the framework here, so including the file from the framework will
// conflict with the compiler attempting to include the file from the project.
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#else
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#endif

#import "CDRSpec.h"
Expand Down
2 changes: 1 addition & 1 deletion Spec/CDRSymbolicatorSpec.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "SpecHelper.h"
#import "CDRSpecHelper.h"
#import "CDRExample.h"
#import "CDRExampleGroup.h"
#import "CDRSymbolicator.h"
Expand Down
2 changes: 1 addition & 1 deletion Spec/CDRTypeUtilitiesSpec.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#import "CDRTypeUtilities.h"

using namespace Cedar::Matchers;
Expand Down
6 changes: 3 additions & 3 deletions Spec/Doubles/CDRClassFakeSpec.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <Cedar/SpecHelper.h>
#import <Cedar/CDRSpecHelper.h>
#import "SimpleIncrementer.h"
#import "ObjectWithForwardingTarget.h"
#import "ObjectWithWeakDelegate.h"
Expand Down Expand Up @@ -78,7 +78,7 @@
beforeEach(^{
fake = fake_for([SimpleIncrementer class]);

[[SpecHelper specHelper].sharedExampleContext setObject:fake forKey:@"double"];
[[CDRSpecHelper specHelper].sharedExampleContext setObject:fake forKey:@"double"];
});

itShouldBehaveLike(@"a Cedar double");
Expand All @@ -99,7 +99,7 @@
beforeEach(^{
niceFake = nice_fake_for([SimpleIncrementer class]);

[[SpecHelper specHelper].sharedExampleContext setObject:niceFake forKey:@"double"];
[[CDRSpecHelper specHelper].sharedExampleContext setObject:niceFake forKey:@"double"];
});

itShouldBehaveLike(@"a Cedar double");
Expand Down
Loading

0 comments on commit bc9791c

Please sign in to comment.