Skip to content

Commit

Permalink
Merge pull request Quick#220 from mkauppila/tests/before-each-objc
Browse files Browse the repository at this point in the history
Add BeforeEachTests+ObjC tests
  • Loading branch information
modocache committed Dec 16, 2014
2 parents bc2397e + 9c8acc3 commit 615c695
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Quick.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
34F375BC19515CA700CE1B99 /* World.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34F375A619515CA700CE1B99 /* World.swift */; };
479C31E31A36171B00DA8718 /* ItTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 479C31E11A36156E00DA8718 /* ItTests+ObjC.m */; };
479C31E41A36172700DA8718 /* ItTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 479C31E11A36156E00DA8718 /* ItTests+ObjC.m */; };
47FAEA361A3F49E6005A1D2F /* BeforeEachTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */; };
47FAEA371A3F49EB005A1D2F /* BeforeEachTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */; };
5A5D118719473F2100F6D13D /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A5D117C19473F2100F6D13D /* Quick.framework */; };
5A5D11A7194740E000F6D13D /* Quick.h in Headers */ = {isa = PBXBuildFile; fileRef = DAEB6B931943873100289F44 /* Quick.h */; settings = {ATTRIBUTES = (Public, ); }; };
5A5D11AC1947412800F6D13D /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEB6BCE194387D700289F44 /* Person.swift */; };
Expand Down Expand Up @@ -285,6 +287,7 @@
34F375A519515CA700CE1B99 /* QuickSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuickSpec.m; sourceTree = "<group>"; };
34F375A619515CA700CE1B99 /* World.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = World.swift; sourceTree = "<group>"; };
479C31E11A36156E00DA8718 /* ItTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ItTests+ObjC.m"; sourceTree = "<group>"; };
47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeforeEachTests+ObjC.m"; sourceTree = "<group>"; };
5A5D117C19473F2100F6D13D /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5A5D118619473F2100F6D13D /* Quick-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Quick-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5AFC5948195ED5B900D3E0A2 /* Failure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Failure.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -421,6 +424,7 @@
479C31E11A36156E00DA8718 /* ItTests+ObjC.m */,
DA8F919C19F31921006F6675 /* FailureTests+ObjC.m */,
DA87078219F48775008C04AC /* BeforeEachTests.swift */,
47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */,
DA05D60F19F73A3800771050 /* AfterEachTests.swift */,
DAA63EA219F7637300CD0A3B /* PendingTests.swift */,
DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */,
Expand Down Expand Up @@ -804,6 +808,7 @@
1F6BB86819693204009F1DBB /* FunctionalTests.swift in Sources */,
5A5D11AD1947412800F6D13D /* Poet.swift in Sources */,
479C31E41A36172700DA8718 /* ItTests+ObjC.m in Sources */,
47FAEA371A3F49EB005A1D2F /* BeforeEachTests+ObjC.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -857,6 +862,7 @@
1F6BB86A1969BF75009F1DBB /* FunctionalTests.swift in Sources */,
DAEB6BD5194387D700289F44 /* Poet.swift in Sources */,
479C31E31A36171B00DA8718 /* ItTests+ObjC.m in Sources */,
47FAEA361A3F49E6005A1D2F /* BeforeEachTests+ObjC.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
68 changes: 68 additions & 0 deletions QuickTests/FunctionalTests/BeforeEachTests+ObjC.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#import <XCTest/XCTest.h>
#import <Quick/Quick.h>

#import "QCKSpecRunner.h"

typedef NS_ENUM(NSUInteger, BeforeEachType) {
OuterOne,
OuterTwo,
InnerOne,
InnerTwo,
InnerThree,
NoExamples,
};

static NSMutableArray *beforeEachOrder;

QuickSpecBegin(FunctionalTests_BeforeEachSpec)

beforeEach(^{ [beforeEachOrder addObject:@(OuterOne)]; });
beforeEach(^{ [beforeEachOrder addObject:@(OuterTwo)]; });

it(@"executes the outer beforeEach closures once [1]", ^{});
it(@"executes the outer beforeEach closures a second time [2]", ^{});

context(@"when there are nested beforeEach", ^{
beforeEach(^{ [beforeEachOrder addObject:@(InnerOne)]; });
beforeEach(^{ [beforeEachOrder addObject:@(InnerTwo)]; });
beforeEach(^{ [beforeEachOrder addObject:@(InnerThree)]; });

it(@"executes the outer and inner beforeEach closures [3]", ^{});
});

context(@"when there are nested beforeEach without examples", ^{
beforeEach(^{ [beforeEachOrder addObject:@(NoExamples)]; });
});

QuickSpecEnd

@interface BeforeEachTests : XCTestCase; @end

@implementation BeforeEachTests

- (void)setUp {
beforeEachOrder = [NSMutableArray array];
[super setUp];
}

- (void)tearDown {
beforeEachOrder = [NSMutableArray array];
[super tearDown];
}

- (void)testBeforeEachIsExecutedInTheCorrectOrder {
qck_runSpec([FunctionalTests_BeforeEachSpec class]);
NSArray *expectedOrder = @[
// [1] The outer beforeEach closures are executed from top to bottom.
@(OuterOne), @(OuterTwo),
// [2] The outer beforeEach closures are executed from top to bottom.
@(OuterOne), @(OuterTwo),
// [3] The outer beforeEach closures are executed from top to bottom,
// then the innter beforeEach closures are executed from top to bottom.
@(OuterOne), @(OuterTwo), @(InnerOne), @(InnerTwo), @(InnerThree),
];

XCTAssertEqualObjects(beforeEachOrder, expectedOrder);
}

@end

0 comments on commit 615c695

Please sign in to comment.