Skip to content

Commit 8439359

Browse files
committed
Add Specta / Expecta test dependencies through Carthage
* Add OCMock dependency * Add some LoggerController tests
1 parent 54158d5 commit 8439359

15 files changed

+795
-2
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ xcuserdata
3838
# Carthage
3939
#
4040
# Add this line if you want to avoid checking in source code from Carthage dependencies.
41-
# Carthage/Checkouts
42-
41+
Carthage/Checkouts
4342
Carthage/Build
4443

4544
SuperLogger.xcodeproj/project.xcworkspace/xcuserdata/joel.xcuserdatad/UserInterfaceState.xcuserstate

Cartfile.private

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github "specta/specta" ~> 1.0
2+
github "specta/expecta" ~> 1.0

Cartfile.resolved

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github "specta/expecta" "v1.0.2"
2+
github "specta/specta" "v1.0.3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2009-2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCObserverMockObject;
20+
21+
22+
@interface NSNotificationCenter(OCMAdditions)
23+
24+
- (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender;
25+
26+
@end

Libs/OCMock/OCMArg.h

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2009-2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface OCMArg : NSObject
20+
21+
// constraining arguments
22+
23+
+ (id)any;
24+
+ (SEL)anySelector;
25+
+ (void *)anyPointer;
26+
+ (id __autoreleasing *)anyObjectRef;
27+
+ (id)isNil;
28+
+ (id)isNotNil;
29+
+ (id)isEqual:(id)value;
30+
+ (id)isNotEqual:(id)value;
31+
+ (id)isKindOfClass:(Class)cls;
32+
+ (id)checkWithSelector:(SEL)selector onObject:(id)anObject;
33+
+ (id)checkWithBlock:(BOOL (^)(id obj))block;
34+
35+
// manipulating arguments
36+
37+
+ (id *)setTo:(id)value;
38+
+ (void *)setToValue:(NSValue *)value;
39+
40+
// internal use only
41+
42+
+ (id)resolveSpecialValues:(NSValue *)value;
43+
44+
@end
45+
46+
#define OCMOCK_ANY [OCMArg any]
47+
48+
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
49+
#define OCMOCK_VALUE(variable) \
50+
({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; })
51+
#else
52+
#define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))]
53+
#endif

Libs/OCMock/OCMConstraint.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2007-2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
20+
@interface OCMConstraint : NSObject
21+
22+
+ (instancetype)constraint;
23+
- (BOOL)evaluate:(id)value;
24+
25+
// if you are looking for any, isNil, etc, they have moved to OCMArg
26+
27+
// try to use [OCMArg checkWith...] instead of the constraintWith... methods below
28+
29+
+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject;
30+
+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue;
31+
32+
33+
@end
34+
35+
@interface OCMAnyConstraint : OCMConstraint
36+
@end
37+
38+
@interface OCMIsNilConstraint : OCMConstraint
39+
@end
40+
41+
@interface OCMIsNotNilConstraint : OCMConstraint
42+
@end
43+
44+
@interface OCMIsNotEqualConstraint : OCMConstraint
45+
{
46+
@public
47+
id testValue;
48+
}
49+
50+
@end
51+
52+
@interface OCMInvocationConstraint : OCMConstraint
53+
{
54+
@public
55+
NSInvocation *invocation;
56+
}
57+
58+
@end
59+
60+
@interface OCMBlockConstraint : OCMConstraint
61+
{
62+
BOOL (^block)(id);
63+
}
64+
65+
- (instancetype)initWithConstraintBlock:(BOOL (^)(id))block;
66+
67+
@end
68+
69+
70+
#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self]
71+
#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)]

Libs/OCMock/OCMLocation.h

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface OCMLocation : NSObject
20+
{
21+
id testCase;
22+
NSString *file;
23+
NSUInteger line;
24+
}
25+
26+
+ (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine;
27+
28+
- (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine;
29+
30+
- (id)testCase;
31+
- (NSString *)file;
32+
- (NSUInteger)line;
33+
34+
@end
35+
36+
extern OCMLocation *OCMMakeLocation(id testCase, const char *file, int line);

Libs/OCMock/OCMMacroState.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCMLocation;
20+
@class OCMRecorder;
21+
@class OCMStubRecorder;
22+
@class OCMockObject;
23+
24+
25+
@interface OCMMacroState : NSObject
26+
{
27+
OCMRecorder *recorder;
28+
}
29+
30+
+ (void)beginStubMacro;
31+
+ (OCMStubRecorder *)endStubMacro;
32+
33+
+ (void)beginExpectMacro;
34+
+ (OCMStubRecorder *)endExpectMacro;
35+
36+
+ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation;
37+
+ (void)endVerifyMacro;
38+
39+
+ (OCMMacroState *)globalState;
40+
41+
- (OCMRecorder *)recorder;
42+
43+
- (void)switchToClassMethod;
44+
45+
@end

Libs/OCMock/OCMRecorder.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCMockObject;
20+
@class OCMInvocationMatcher;
21+
22+
23+
@interface OCMRecorder : NSProxy
24+
{
25+
OCMockObject *mockObject;
26+
OCMInvocationMatcher *invocationMatcher;
27+
}
28+
29+
- (instancetype)init;
30+
- (instancetype)initWithMockObject:(OCMockObject *)aMockObject;
31+
32+
- (void)setMockObject:(OCMockObject *)aMockObject;
33+
34+
- (OCMInvocationMatcher *)invocationMatcher;
35+
36+
- (id)classMethod;
37+
- (id)ignoringNonObjectArgs;
38+
39+
@end

Libs/OCMock/OCMStubRecorder.h

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2004-2014 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import "OCMRecorder.h"
18+
19+
20+
@interface OCMStubRecorder : OCMRecorder
21+
22+
- (id)andReturn:(id)anObject;
23+
- (id)andReturnValue:(NSValue *)aValue;
24+
- (id)andThrow:(NSException *)anException;
25+
- (id)andPost:(NSNotification *)aNotification;
26+
- (id)andCall:(SEL)selector onObject:(id)anObject;
27+
- (id)andDo:(void (^)(NSInvocation *invocation))block;
28+
- (id)andForwardToRealObject;
29+
30+
@end
31+
32+
33+
@interface OCMStubRecorder (Properties)
34+
35+
#define andReturn(aValue) _andReturn(({ __typeof__(aValue) _v = (aValue); [NSValue value:&_v withObjCType:@encode(__typeof__(_v))]; }))
36+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *);
37+
38+
#define andThrow(anException) _andThrow(anException)
39+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *);
40+
41+
#define andPost(aNotification) _andPost(aNotification)
42+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *);
43+
44+
#define andCall(anObject, aSelector) _andCall(anObject, aSelector)
45+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL);
46+
47+
#define andDo(aBlock) _andDo(aBlock)
48+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *));
49+
50+
#define andForwardToRealObject() _andForwardToRealObject()
51+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void);
52+
53+
@end
54+
55+
56+

0 commit comments

Comments
 (0)