Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move hook examples into their own file.

  • Loading branch information...
commit d3a2b8d4456def429e0cc50ce23d18871bbd4a95 1 parent aa3dcf0
@lukeredpath lukeredpath authored
View
148 Examples/KiwiHooksSpec.m
@@ -0,0 +1,148 @@
+//
+// KiwiHooksSpec.m
+// Kiwi
+//
+// Created by Luke Redpath on 19/10/2011.
+// Copyright 2011 Allen Ding. All rights reserved.
+//
+
+#import "Kiwi.h"
+#import "KiwiTestConfiguration.h"
+
+SPEC_BEGIN(BeforeHooksBehaviour)
+
+describe(@"before hooks behaviour", ^{
+ __block NSInteger calls = 0;
+
+ beforeAll(^{
+ calls++;
+ });
+
+ beforeEach(^{
+ calls++;
+ });
+
+ it(@"will call beforeAll and beforeEach before this spec", ^{
+ [[theValue(calls) should] equal:theValue(2)];
+ });
+
+ it(@"will call beforeEach but not beforeAll before this spec", ^{
+ [[theValue(calls) should] equal:theValue(3)];
+ });
+
+ context(@"with nested contexts", ^{
+ beforeAll(^{
+ calls++;
+ });
+
+ beforeEach(^{
+ calls++;
+ });
+
+ it(@"will call inner beforeAll and inner and outer beforeEach before this spec", ^{
+ [[theValue(calls) should] equal:theValue(6)];
+ });
+
+ it(@"will call inner and outer beforeEach but neither beforeAll before this spec", ^{
+ [[theValue(calls) should] equal:theValue(8)];
+ });
+
+ context(@"and another", ^{
+ beforeAll(^{
+ calls++;
+ });
+
+ beforeEach(^{
+ calls++;
+ });
+
+ it(@"will call inner beforeAll and all inner and outer beforeEach hooks before this spec", ^{
+ [[theValue(calls) should] equal:theValue(12)];
+ });
+
+ it(@"will call all inner and outer beforeEach but none of the beforeAll hooks before this spec", ^{
+ [[theValue(calls) should] equal:theValue(15)];
+ });
+
+ });
+
+ it(@"will call this after the nested context specs above", ^{
+ [[theValue(calls) should] equal:theValue(17)];
+ });
+ });
+
+ it(@"will call this after both nested context specs above", ^{
+ [[theValue(calls) should] equal:theValue(18)];
+ });
+});
+
+SPEC_END
+
+SPEC_BEGIN(AfterHooksBehaviour)
+
+describe(@"after hooks behaviour", ^{
+ __block NSInteger calls = 0;
+
+ afterEach(^{
+ calls++;
+ });
+
+ it(@"will call afterEach but not afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(0)];
+ });
+
+ it(@"will call afterEach but not afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(1)];
+ });
+
+ context(@"with nested contexts", ^{
+ afterAll(^{
+ calls++;
+ });
+
+ afterEach(^{
+ calls++;
+ });
+
+ it(@"will call inner afterEach and outer afterEach but not afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(2)];
+ });
+
+ it(@"will call inner afterEach and outer afterEach but not afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(4)];
+ });
+
+ context(@"and another", ^{
+ afterAll(^{
+ calls++;
+ });
+
+ afterEach(^{
+ calls++;
+ });
+
+ it(@"will call inner afterEach and each outer afterEach but not afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(6)];
+ });
+
+ it(@"will call inner afterEach and each outer afterEach and the inner afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(9)];
+ });
+
+ });
+
+ it(@"will call this after the nested context specs above, reflecting the result of its afterAll, and this context's afterAll after this spec", ^{
+ [[theValue(calls) should] equal:theValue(13)];
+ });
+ });
+
+ it(@"will call this after both nested context specs above", ^{
+ [[theValue(calls) should] equal:theValue(16)];
+ });
+
+ afterAll(^{
+ NSLog(@"Can't test this as it's the last thing to run, but verify with log output");
+ });
+});
+
+SPEC_END
View
137 Examples/SimpleSpec.m
@@ -39,141 +39,4 @@
SPEC_END
-SPEC_BEGIN(BeforeHooksBehaviour)
-
-describe(@"before hooks behaviour", ^{
- __block NSInteger calls = 0;
-
- beforeAll(^{
- calls++;
- });
-
- beforeEach(^{
- calls++;
- });
-
- it(@"will call beforeAll and beforeEach before this spec", ^{
- [[theValue(calls) should] equal:theValue(2)];
- });
-
- it(@"will call beforeEach but not beforeAll before this spec", ^{
- [[theValue(calls) should] equal:theValue(3)];
- });
-
- context(@"with nested contexts", ^{
- beforeAll(^{
- calls++;
- });
-
- beforeEach(^{
- calls++;
- });
-
- it(@"will call inner beforeAll and inner and outer beforeEach before this spec", ^{
- [[theValue(calls) should] equal:theValue(6)];
- });
-
- it(@"will call inner and outer beforeEach but neither beforeAll before this spec", ^{
- [[theValue(calls) should] equal:theValue(8)];
- });
-
- context(@"and another", ^{
- beforeAll(^{
- calls++;
- });
-
- beforeEach(^{
- calls++;
- });
-
- it(@"will call inner beforeAll and all inner and outer beforeEach hooks before this spec", ^{
- [[theValue(calls) should] equal:theValue(12)];
- });
-
- it(@"will call all inner and outer beforeEach but none of the beforeAll hooks before this spec", ^{
- [[theValue(calls) should] equal:theValue(15)];
- });
-
- });
-
- it(@"will call this after the nested context specs above", ^{
- [[theValue(calls) should] equal:theValue(17)];
- });
- });
-
- it(@"will call this after both nested context specs above", ^{
- [[theValue(calls) should] equal:theValue(18)];
- });
-});
-
-SPEC_END
-
-SPEC_BEGIN(AfterHooksBehaviour)
-
-describe(@"after hooks behaviour", ^{
- __block NSInteger calls = 0;
-
- afterEach(^{
- calls++;
- });
-
- it(@"will call afterEach but not afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(0)];
- });
-
- it(@"will call afterEach but not afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(1)];
- });
-
- context(@"with nested contexts", ^{
- afterAll(^{
- calls++;
- });
-
- afterEach(^{
- calls++;
- });
-
- it(@"will call inner afterEach and outer afterEach but not afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(2)];
- });
-
- it(@"will call inner afterEach and outer afterEach but not afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(4)];
- });
-
- context(@"and another", ^{
- afterAll(^{
- calls++;
- });
-
- afterEach(^{
- calls++;
- });
-
- it(@"will call inner afterEach and each outer afterEach but not afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(6)];
- });
-
- it(@"will call inner afterEach and each outer afterEach and the inner afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(9)];
- });
-
- });
-
- it(@"will call this after the nested context specs above, reflecting the result of its afterAll, and this context's afterAll after this spec", ^{
- [[theValue(calls) should] equal:theValue(13)];
- });
- });
-
- it(@"will call this after both nested context specs above", ^{
- [[theValue(calls) should] equal:theValue(16)];
- });
-
- afterAll(^{
- NSLog(@"Can't test this as it's the last thing to run, but verify with log output");
- });
-});
-
-SPEC_END
View
4 Kiwi.xcodeproj/project.pbxproj
@@ -10,6 +10,7 @@
9F4E04DC12DFB71F00A3440B /* KWFutureObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F4E04D712DFB71F00A3440B /* KWFutureObject.m */; };
9F4E04DF12DFB71F00A3440B /* KWProbePoller.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F4E04DA12DFB71F00A3440B /* KWProbePoller.m */; };
9FB1D28412DFB60400693E30 /* KWAsyncVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FB1D28312DFB60400693E30 /* KWAsyncVerifier.m */; };
+ A34D117D144E554600AD1B61 /* KiwiHooksSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = A34D117A144E51B200AD1B61 /* KiwiHooksSpec.m */; };
A34FAD9413BBF4A4003968B2 /* KWBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = F5E9FC2F11AE6A0F0089BACE /* KWBlock.h */; settings = {ATTRIBUTES = (Public, ); }; };
A34FAD9513BBF4A4003968B2 /* KWCallSite.h in Headers */ = {isa = PBXBuildFile; fileRef = F5015B571158398E002E9A98 /* KWCallSite.h */; settings = {ATTRIBUTES = (Public, ); }; };
A34FAD9613BBF4A4003968B2 /* KWCountType.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F79B7411AD002100EE6571 /* KWCountType.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -253,6 +254,7 @@
9F4E04D912DFB71F00A3440B /* KWProbePoller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWProbePoller.h; sourceTree = "<group>"; };
9F4E04DA12DFB71F00A3440B /* KWProbePoller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWProbePoller.m; sourceTree = "<group>"; };
9FB1D28312DFB60400693E30 /* KWAsyncVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWAsyncVerifier.m; sourceTree = "<group>"; };
+ A34D117A144E51B200AD1B61 /* KiwiHooksSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KiwiHooksSpec.m; sourceTree = "<group>"; };
A352E9E712EDC30A0049C691 /* KWHaveValueMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWHaveValueMatcherTest.m; sourceTree = "<group>"; };
A352E9E912EDC33C0049C691 /* KWHaveValueMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWHaveValueMatcher.h; sourceTree = "<group>"; };
A352E9EA12EDC33C0049C691 /* KWHaveValueMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWHaveValueMatcher.m; sourceTree = "<group>"; };
@@ -879,6 +881,7 @@
F5ECAEE3116711D200B0BEEF /* ExampleTestCase.m */,
F5CDEC4811C151120022A0BF /* SimpleSpec.m */,
A3A1739B12E47068004DFD70 /* ExampleAsyncSpec.m */,
+ A34D117A144E51B200AD1B61 /* KiwiHooksSpec.m */,
);
path = Examples;
sourceTree = "<group>";
@@ -1139,6 +1142,7 @@
A3B1655D1399694900E9CC6E /* SpaceShip.m in Sources */,
A3B1655E1399694900E9CC6E /* Robot.m in Sources */,
A3B1655F1399695000E9CC6E /* StringPrefixMatcher.m in Sources */,
+ A34D117D144E554600AD1B61 /* KiwiHooksSpec.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.