Authored by Jonas Budelmann

update Podfile.lock

Showing 34 changed files with 347 additions and 74 deletions
1 PODS: 1 PODS:
2 - - Expecta (0.2.3)  
3 - - Masonry (0.4.0) 2 + - Expecta (0.3.0)
  3 + - Masonry (0.5.0)
4 4
5 DEPENDENCIES: 5 DEPENDENCIES:
6 - Expecta 6 - Expecta
@@ -11,7 +11,7 @@ EXTERNAL SOURCES: @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
11 :path: ./ 11 :path: ./
12 12
13 SPEC CHECKSUMS: 13 SPEC CHECKSUMS:
14 - Expecta: 2434bb2e2b3b1814280ec5d9a11359433d035975  
15 - Masonry: d673617c9cbc24aaea90fba20b10e47fd9970a39 14 + Expecta: 322f1dc42610106a5ba9871b4924cf1635d80833
  15 + Masonry: bef482b29f00b33a2da916e1011af85f5d371d66
16 16
17 COCOAPODS: 0.32.1 17 COCOAPODS: 0.32.1
  1 +../../Expecta/src/matchers/EXPMatchers+beSupersetOf.h
  1 +../../Expecta/src/matchers/EXPMatchers+beginWith.h
  1 +../../Expecta/src/matchers/EXPMatchers+endWith.h
  1 +../../Expecta/src/matchers/EXPMatchers+notify.h
  1 +../../Expecta/src/matchers/EXPMatchers+respondTo.h
1 -# Expecta 1 +#Expecta
2 2
3 A Matcher Framework for Objective-C/Cocoa 3 A Matcher Framework for Objective-C/Cocoa
4 4
5 ## NOTICE 5 ## NOTICE
6 6
7 -Expecta 0.2.x has a new syntax that is slightly different from Expecta 0.1.x. For example `expect(x).toEqual(y)` should now be written as `expect(x).to.equal(y)`. You can do `#define EXP_OLD_SYNTAX` before importing `Expecta.h` to enable backward-compatiblity mode, but keep in mind that the old syntax is deprecated. 7 +Expecta 0.3.x removes support for Garbage Collected targets, as support for these has been removed from Xcode 5.1 and greater. If you need Garbage Collection support, please continue to use Expecta 0.2.4. The minimum deployment targets have also been raised to iOS 5.x and OS X 10.7 or greater.
  8 +
  9 +Expecta 0.2.x and later has a new syntax that is slightly different from Expecta 0.1.x. For example `expect(x).toEqual(y)` should now be written as `expect(x).to.equal(y)`. You can do `#define EXP_OLD_SYNTAX` before importing `Expecta.h` to enable backward-compatiblity mode, but keep in mind that the old syntax is deprecated.
8 10
9 ## INTRODUCTION 11 ## INTRODUCTION
10 12
@@ -17,14 +19,11 @@ assertThat(@"foo", is(equalTo(@"foo"))); @@ -17,14 +19,11 @@ assertThat(@"foo", is(equalTo(@"foo")));
17 assertThatUnsignedInteger(foo, isNot(equalToUnsignedInteger(1))); 19 assertThatUnsignedInteger(foo, isNot(equalToUnsignedInteger(1)));
18 assertThatBool([bar isBar], is(equalToBool(YES))); 20 assertThatBool([bar isBar], is(equalToBool(YES)));
19 assertThatDouble(baz, is(equalToDouble(3.14159))); 21 assertThatDouble(baz, is(equalToDouble(3.14159)));
20 -```  
21 -  
22 -vs. 22 +``` vs. **Expecta **
23 23
24 -**Expecta**  
25 -  
26 -```objective-c  
27 -expect(@"foo").to.equal(@"foo"); // `to` is a syntatic sugar and can be safely omitted. 24 +```objective -
  25 + c expect(@"foo").to.equal(
  26 + @"foo"); // `to` is a syntatic sugar and can be safely omitted.
28 expect(foo).notTo.equal(1); 27 expect(foo).notTo.equal(1);
29 expect([bar isBar]).to.equal(YES); 28 expect([bar isBar]).to.equal(YES);
30 expect(baz).to.equal(3.14159); 29 expect(baz).to.equal(3.14159);
@@ -36,12 +35,12 @@ Use [CocoaPods](https://github.com/CocoaPods/CocoaPods) @@ -36,12 +35,12 @@ Use [CocoaPods](https://github.com/CocoaPods/CocoaPods)
36 35
37 ```ruby 36 ```ruby
38 target :MyApp do 37 target :MyApp do
39 - # your app dependencies 38 +#your app dependencies
40 end 39 end
41 40
42 target :MyAppTests do 41 target :MyAppTests do
43 - pod 'Expecta', '~> 0.2.3' # expecta matchers  
44 - # pod 'Specta', '~> 0.1.11' # specta bdd framework 42 + pod 'Expecta', '~> 0.2.4' # expecta matchers
  43 +#pod 'Specta', '~> 0.1.11' #specta bdd framework
45 end 44 end
46 ``` 45 ```
47 46
@@ -77,7 +76,9 @@ Expecta is framework-agnostic. It works well with OCUnit (SenTestingKit) and OCU @@ -77,7 +76,9 @@ Expecta is framework-agnostic. It works well with OCUnit (SenTestingKit) and OCU
77 > 76 >
78 >`expect(x).to.beFalsy();` passes if x evaluates to false (zero). 77 >`expect(x).to.beFalsy();` passes if x evaluates to false (zero).
79 > 78 >
80 ->`expect(x).to.contain(y);` passes if an instance of NSArray, NSDictionary or NSString x contains y. 79 +>`expect(x).to.contain(y);` passes if an instance of NSArray or NSString x contains y.
  80 +>
  81 +>`expect(x).to.beSupersetOf(y);` passes if an instance of NSArray, NSSet, NSDictionary or NSOrderedSet x contains all elements of y.
81 > 82 >
82 >`expect(x).to.haveCountOf(y);` passes if an instance of NSArray, NSSet, NSDictionary or NSString x has a count or length of y. 83 >`expect(x).to.haveCountOf(y);` passes if an instance of NSArray, NSSet, NSDictionary or NSString x has a count or length of y.
83 > 84 >
@@ -106,6 +107,18 @@ Expecta is framework-agnostic. It works well with OCUnit (SenTestingKit) and OCU @@ -106,6 +107,18 @@ Expecta is framework-agnostic. It works well with OCUnit (SenTestingKit) and OCU
106 >`expect(^{ /* code */ }).to.raise(@"ExceptionName");` passes if a given block of code raises an exception named `ExceptionName`. 107 >`expect(^{ /* code */ }).to.raise(@"ExceptionName");` passes if a given block of code raises an exception named `ExceptionName`.
107 > 108 >
108 >`expect(^{ /* code */ }).to.raiseAny();` passes if a given block of code raises any exception. 109 >`expect(^{ /* code */ }).to.raiseAny();` passes if a given block of code raises any exception.
  110 +>
  111 +>`expect(x).to.conformTo(y);` passes if `x` conforms to the protocol `y`.
  112 +>
  113 +>`expect(x).to.respondTo(y);` passes if `x` responds to the selector `y`.
  114 +>
  115 +>`expect(^{ /* code */ }).to.notify(@"NotificationName");` passes if a given block of code generates an NSNotification named `NotificationName`.
  116 +>
  117 +>`expect(^{ /* code */ }).to.notify(notification);` passes if a given block of code generates an NSNotification equal to the passed `notification`.
  118 +>
  119 +>`expect(x).to.beginWith(y);` passes if an instance of NSString, NSArray, or NSOrderedSet `x` begins with `y`. Also aliased by `startWith`
  120 +>
  121 +>`expect(x).to.endWith(y);` passes if an instance of NSString, NSArray, or NSOrderedSet `x` ends with `y`.
109 122
110 **Please contribute more matchers.** 123 **Please contribute more matchers.**
111 124
@@ -136,7 +149,8 @@ Writing a new matcher is easy with special macros provided by Expecta. Take a lo @@ -136,7 +149,8 @@ Writing a new matcher is easy with special macros provided by Expecta. Take a lo
136 149
137 EXPMatcherInterface(beKindOf, (Class expected)); 150 EXPMatcherInterface(beKindOf, (Class expected));
138 // 1st argument is the name of the matcher function 151 // 1st argument is the name of the matcher function
139 -// 2nd argument is the list of arguments that may be passed in the function call. 152 +// 2nd argument is the list of arguments that may be passed in the function
  153 +// call.
140 // Multiple arguments are fine. (e.g. (int foo, float bar)) 154 // Multiple arguments are fine. (e.g. (int foo, float bar))
141 155
142 #define beAKindOf beKindOf 156 #define beAKindOf beKindOf
@@ -151,31 +165,38 @@ EXPMatcherImplementationBegin(beKindOf, (Class expected)) { @@ -151,31 +165,38 @@ EXPMatcherImplementationBegin(beKindOf, (Class expected)) {
151 BOOL actualIsNil = (actual == nil); 165 BOOL actualIsNil = (actual == nil);
152 BOOL expectedIsNil = (expected == nil); 166 BOOL expectedIsNil = (expected == nil);
153 167
154 - prerequisite(^BOOL{ 168 + prerequisite(^BOOL {
155 return !(actualIsNil || expectedIsNil); 169 return !(actualIsNil || expectedIsNil);
156 - // Return `NO` if matcher should fail whether or not the result is inverted using `.Not`. 170 + // Return `NO` if matcher should fail whether or not the result is inverted
  171 + // using `.Not`.
157 }); 172 });
158 173
159 - match(^BOOL{ 174 + match(^BOOL {
160 return [actual isKindOfClass:expected]; 175 return [actual isKindOfClass:expected];
161 // Return `YES` if the matcher should pass, `NO` if it should not. 176 // Return `YES` if the matcher should pass, `NO` if it should not.
162 // The actual value/object is passed as `actual`. 177 // The actual value/object is passed as `actual`.
163 // Please note that primitive values will be wrapped in NSNumber/NSValue. 178 // Please note that primitive values will be wrapped in NSNumber/NSValue.
164 }); 179 });
165 180
166 - failureMessageForTo(^NSString *{  
167 - if(actualIsNil) return @"the actual value is nil/null";  
168 - if(expectedIsNil) return @"the expected value is nil/null";  
169 - return [NSString stringWithFormat:@"expected: a kind of %@, " 181 + failureMessageForTo(^NSString * {
  182 + if (actualIsNil)
  183 + return @"the actual value is nil/null";
  184 + if (expectedIsNil)
  185 + return @"the expected value is nil/null";
  186 + return [NSString
  187 + stringWithFormat:@"expected: a kind of %@, "
170 "got: an instance of %@, which is not a kind of %@", 188 "got: an instance of %@, which is not a kind of %@",
171 [expected class], [actual class], [expected class]]; 189 [expected class], [actual class], [expected class]];
172 // Return the message to be displayed when the match function returns `YES`. 190 // Return the message to be displayed when the match function returns `YES`.
173 }); 191 });
174 192
175 - failureMessageForNotTo(^NSString *{  
176 - if(actualIsNil) return @"the actual value is nil/null";  
177 - if(expectedIsNil) return @"the expected value is nil/null";  
178 - return [NSString stringWithFormat:@"expected: not a kind of %@, " 193 + failureMessageForNotTo(^NSString * {
  194 + if (actualIsNil)
  195 + return @"the actual value is nil/null";
  196 + if (expectedIsNil)
  197 + return @"the expected value is nil/null";
  198 + return [NSString
  199 + stringWithFormat:@"expected: not a kind of %@, "
179 "got: an instance of %@, which is a kind of %@", 200 "got: an instance of %@, which is a kind of %@",
180 [expected class], [actual class], [expected class]]; 201 [expected class], [actual class], [expected class]];
181 // Return the message to be displayed when the match function returns `NO`. 202 // Return the message to be displayed when the match function returns `NO`.
@@ -131,16 +131,13 @@ void EXPFail(id testCase, int lineNumber, const char *fileName, NSString *messag @@ -131,16 +131,13 @@ void EXPFail(id testCase, int lineNumber, const char *fileName, NSString *messag
131 NSString *EXPDescribeObject(id obj) { 131 NSString *EXPDescribeObject(id obj) {
132 if(obj == nil) { 132 if(obj == nil) {
133 return @"nil/null"; 133 return @"nil/null";
134 - } else if([obj isKindOfClass:[NSValue class]]) {  
135 - if([obj isKindOfClass:[NSValue class]] && ![obj isKindOfClass:[NSNumber class]]) {  
136 - void *pointerValue = [obj pointerValue]; 134 + } else if([obj isKindOfClass:[NSValue class]] && ![obj isKindOfClass:[NSNumber class]]) {
137 const char *type = [(NSValue *)obj _EXP_objCType]; 135 const char *type = [(NSValue *)obj _EXP_objCType];
138 if(type) { 136 if(type) {
139 if(strcmp(type, @encode(SEL)) == 0) { 137 if(strcmp(type, @encode(SEL)) == 0) {
140 return [NSString stringWithFormat:@"@selector(%@)", NSStringFromSelector([obj pointerValue])]; 138 return [NSString stringWithFormat:@"@selector(%@)", NSStringFromSelector([obj pointerValue])];
141 } else if(strcmp(type, @encode(Class)) == 0) { 139 } else if(strcmp(type, @encode(Class)) == 0) {
142 - return NSStringFromClass(pointerValue);  
143 - } 140 + return NSStringFromClass([obj pointerValue]);
144 } 141 }
145 } 142 }
146 } 143 }
@@ -164,6 +161,8 @@ NSString *EXPDescribeObject(id obj) { @@ -164,6 +161,8 @@ NSString *EXPDescribeObject(id obj) {
164 [arr addObject:[NSString stringWithFormat:@"%@ = %@;",EXPDescribeObject(k), EXPDescribeObject(v)]]; 161 [arr addObject:[NSString stringWithFormat:@"%@ = %@;",EXPDescribeObject(k), EXPDescribeObject(v)]];
165 } 162 }
166 description = [NSString stringWithFormat:@"{%@}", [arr componentsJoinedByString:@" "]]; 163 description = [NSString stringWithFormat:@"{%@}", [arr componentsJoinedByString:@" "]];
  164 + } else if([obj isKindOfClass:[NSAttributedString class]]) {
  165 + description = [obj string];
167 } else { 166 } else {
168 description = [description stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 167 description = [description stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
169 } 168 }
1 #import "Expecta.h" 1 #import "Expecta.h"
2 2
3 EXPMatcherInterface(_beIdenticalTo, (void *expected)); 3 EXPMatcherInterface(_beIdenticalTo, (void *expected));
  4 +EXPMatcherInterface(beIdenticalTo, (void *expected)); // to aid code completion
4 5
5 #if __has_feature(objc_arc) 6 #if __has_feature(objc_arc)
6 #define beIdenticalTo(expected) _beIdenticalTo((__bridge void*)expected) 7 #define beIdenticalTo(expected) _beIdenticalTo((__bridge void*)expected)
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(beSupersetOf, (id subset));
  4 +
  1 +#import "EXPMatchers+contain.h"
  2 +
  3 +EXPMatcherImplementationBegin(beSupersetOf, (id subset)) {
  4 + BOOL actualIsCompatible = [actual isKindOfClass:[NSDictionary class]] || [actual respondsToSelector:@selector(containsObject:)];
  5 + BOOL subsetIsNil = (subset == nil);
  6 + BOOL classMatches = [subset isKindOfClass:[actual class]];
  7 +
  8 + prerequisite(^BOOL{
  9 + return actualIsCompatible && !subsetIsNil && classMatches;
  10 + });
  11 +
  12 + match(^BOOL{
  13 + if(!actualIsCompatible) return NO;
  14 +
  15 + if([actual isKindOfClass:[NSDictionary class]]) {
  16 + for (id key in subset) {
  17 + id actualValue = [actual valueForKey:key];
  18 + id subsetValue = [subset valueForKey:key];
  19 +
  20 + if (![subsetValue isEqual:actualValue]) return NO;
  21 + }
  22 + } else {
  23 + for (id object in subset) {
  24 + if (![actual containsObject:object]) return NO;
  25 + }
  26 + }
  27 +
  28 + return YES;
  29 + });
  30 +
  31 + failureMessageForTo(^NSString *{
  32 + if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary and does not implement -containsObject:", EXPDescribeObject(actual)];
  33 +
  34 + if(subsetIsNil) return @"the expected value is nil/null";
  35 +
  36 + if(!classMatches) return [NSString stringWithFormat:@"%@ does not match the class of %@", EXPDescribeObject(subset), EXPDescribeObject(actual)];
  37 +
  38 + return [NSString stringWithFormat:@"expected %@ to be a superset of %@", EXPDescribeObject(actual), EXPDescribeObject(subset)];
  39 + });
  40 +
  41 + failureMessageForNotTo(^NSString *{
  42 + if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary and does not implement -containsObject:", EXPDescribeObject(actual)];
  43 +
  44 + if(subsetIsNil) return @"the expected value is nil/null";
  45 +
  46 + if(!classMatches) return [NSString stringWithFormat:@"%@ does not match the class of %@", EXPDescribeObject(subset), EXPDescribeObject(actual)];
  47 +
  48 + return [NSString stringWithFormat:@"expected %@ not to be a superset of %@", EXPDescribeObject(actual), EXPDescribeObject(subset)];
  49 + });
  50 +}
  51 +EXPMatcherImplementationEnd
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(beginWith, (id expected));
  4 +
  5 +#define startWith beginWith
  1 +#import "EXPMatchers+beginWith.h"
  2 +
  3 +EXPMatcherImplementationBegin(beginWith, (id expected)) {
  4 + BOOL actualIsNil = (actual == nil);
  5 + BOOL expectedIsNil = (expected == nil);
  6 + //This condition allows the comparison of an immutable string or ordered collection to the mutable type of the same
  7 + BOOL actualAndExpectedAreCompatible = (([actual isKindOfClass:[NSString class]] && [expected isKindOfClass:[NSString class]])
  8 + || ([actual isKindOfClass:[NSArray class]] && [expected isKindOfClass:[NSArray class]])
  9 + || ([actual isKindOfClass:[NSOrderedSet class]] && [expected isKindOfClass:[NSOrderedSet class]]));
  10 +
  11 + prerequisite(^BOOL {
  12 + return actualAndExpectedAreCompatible;
  13 + });
  14 +
  15 + match(^BOOL {
  16 + if ([actual isKindOfClass:[NSString class]]) {
  17 + return [actual hasPrefix:expected];
  18 + } else if ([actual isKindOfClass:[NSArray class]]) {
  19 + if ([expected count] > [actual count] || [expected count] == 0) {
  20 + return NO;
  21 + }
  22 + NSArray *subArray = [actual subarrayWithRange:NSMakeRange(0, [expected count])];
  23 + return [subArray isEqualToArray:expected];
  24 + } else {
  25 + if ([expected count] > [actual count] || [expected count] == 0) {
  26 + return NO;
  27 + }
  28 +
  29 + NSOrderedSet *subset = [NSOrderedSet orderedSetWithOrderedSet:actual range:NSMakeRange(0, [expected count]) copyItems:NO];
  30 + return [subset isEqualToOrderedSet:expected];
  31 + }
  32 + });
  33 +
  34 + failureMessageForTo(^NSString *{
  35 + if (actualIsNil) return @"the object is nil/null";
  36 + if (expectedIsNil) return @"the expected value is nil/null";
  37 + if (!actualAndExpectedAreCompatible) return [NSString stringWithFormat:@"%@ and %@ are not instances of one of %@, %@, or %@", EXPDescribeObject(actual), EXPDescribeObject(expected), [NSString class], [NSArray class], [NSOrderedSet class]];
  38 + return [NSString stringWithFormat:@"expected: %@ to begin with %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
  39 + });
  40 +
  41 + failureMessageForNotTo(^NSString *{
  42 + if (actualIsNil) return @"the object is nil/null";
  43 + if (expectedIsNil) return @"the expected value is nil/null";
  44 + if (!actualAndExpectedAreCompatible) return [NSString stringWithFormat:@"%@ and %@ are not instances of one of %@, %@, or %@", EXPDescribeObject(actual), EXPDescribeObject(expected), [NSString class], [NSArray class], [NSOrderedSet class]];
  45 +
  46 + return [NSString stringWithFormat:@"expected: %@ not to begin with %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
  47 + });
  48 +}
  49 +EXPMatcherImplementationEnd
@@ -3,25 +3,15 @@ @@ -3,25 +3,15 @@
3 EXPMatcherImplementationBegin(_contain, (id expected)) { 3 EXPMatcherImplementationBegin(_contain, (id expected)) {
4 BOOL actualIsCompatible = [actual isKindOfClass:[NSString class]] || [actual conformsToProtocol:@protocol(NSFastEnumeration)]; 4 BOOL actualIsCompatible = [actual isKindOfClass:[NSString class]] || [actual conformsToProtocol:@protocol(NSFastEnumeration)];
5 BOOL expectedIsNil = (expected == nil); 5 BOOL expectedIsNil = (expected == nil);
6 - BOOL actualIsDictionary = [actual isKindOfClass:[NSDictionary class]];  
7 - BOOL expectedIsDictionary = [expected isKindOfClass:[NSDictionary class]];  
8 - BOOL bothOrNeitherDictionaries = (actualIsDictionary && expectedIsDictionary) || (!actualIsDictionary && !expectedIsDictionary);  
9 6
10 prerequisite(^BOOL{ 7 prerequisite(^BOOL{
11 - return actualIsCompatible && !expectedIsNil && bothOrNeitherDictionaries; 8 + return actualIsCompatible && !expectedIsNil;
12 }); 9 });
13 10
14 match(^BOOL{ 11 match(^BOOL{
15 if(actualIsCompatible) { 12 if(actualIsCompatible) {
16 if([actual isKindOfClass:[NSString class]]) { 13 if([actual isKindOfClass:[NSString class]]) {
17 return [(NSString *)actual rangeOfString:[expected description]].location != NSNotFound; 14 return [(NSString *)actual rangeOfString:[expected description]].location != NSNotFound;
18 - } else if ([actual isKindOfClass:[NSDictionary class]]) {  
19 - NSArray *expectedKeys = [expected allKeys];  
20 - id notFoundMarker = [NSObject new];  
21 - NSArray *expectedValues = [expected objectsForKeys:expectedKeys notFoundMarker:notFoundMarker];  
22 - NSArray *actualValues = [actual objectsForKeys:expectedKeys notFoundMarker:notFoundMarker];  
23 - [notFoundMarker release];  
24 - return [actualValues isEqual:expectedValues];  
25 } else { 15 } else {
26 for (id object in actual) { 16 for (id object in actual) {
27 if ([object isEqual:expected]) { 17 if ([object isEqual:expected]) {
@@ -36,26 +26,12 @@ EXPMatcherImplementationBegin(_contain, (id expected)) { @@ -36,26 +26,12 @@ EXPMatcherImplementationBegin(_contain, (id expected)) {
36 failureMessageForTo(^NSString *{ 26 failureMessageForTo(^NSString *{
37 if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)]; 27 if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)];
38 if(expectedIsNil) return @"the expected value is nil/null"; 28 if(expectedIsNil) return @"the expected value is nil/null";
39 - if(!bothOrNeitherDictionaries) {  
40 - if (actualIsDictionary) {  
41 - return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary", EXPDescribeObject(expected)];  
42 - } else {  
43 - return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary", EXPDescribeObject(actual)];  
44 - }  
45 - }  
46 return [NSString stringWithFormat:@"expected %@ to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; 29 return [NSString stringWithFormat:@"expected %@ to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
47 }); 30 });
48 31
49 failureMessageForNotTo(^NSString *{ 32 failureMessageForNotTo(^NSString *{
50 if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)]; 33 if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)];
51 if(expectedIsNil) return @"the expected value is nil/null"; 34 if(expectedIsNil) return @"the expected value is nil/null";
52 - if(!bothOrNeitherDictionaries) {  
53 - if (actualIsDictionary) {  
54 - return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary", EXPDescribeObject(expected)];  
55 - } else {  
56 - return [NSString stringWithFormat:@"%@ is not an instance of NSDictionary", EXPDescribeObject(actual)];  
57 - }  
58 - }  
59 return [NSString stringWithFormat:@"expected %@ not to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; 35 return [NSString stringWithFormat:@"expected %@ not to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
60 }); 36 });
61 } 37 }
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(endWith, (id expected));
  1 +#import "EXPMatchers+endWith.h"
  2 +
  3 +EXPMatcherImplementationBegin(endWith, (id expected)) {
  4 + BOOL actualIsNil = (actual == nil);
  5 + BOOL expectedIsNil = (expected == nil);
  6 + //This condition allows the comparison of an immutable string or ordered collection to the mutable type of the same
  7 + BOOL actualAndExpectedAreCompatible = (([actual isKindOfClass:[NSString class]] && [expected isKindOfClass:[NSString class]])
  8 + || ([actual isKindOfClass:[NSArray class]] && [expected isKindOfClass:[NSArray class]])
  9 + || ([actual isKindOfClass:[NSOrderedSet class]] && [expected isKindOfClass:[NSOrderedSet class]]));
  10 +
  11 + prerequisite(^BOOL {
  12 + return actualAndExpectedAreCompatible;
  13 + });
  14 +
  15 + match(^BOOL {
  16 + if ([actual isKindOfClass:[NSString class]]) {
  17 + return [actual hasSuffix:expected];
  18 + } else if ([actual isKindOfClass:[NSArray class]]) {
  19 + if ([expected count] > [actual count] || [expected count] == 0) {
  20 + return NO;
  21 + }
  22 + NSArray *subArray = [actual subarrayWithRange:NSMakeRange([actual count] - [expected count], [expected count])];
  23 + return [subArray isEqualToArray:expected];
  24 + } else {
  25 + if ([expected count] > [actual count] || [expected count] == 0) {
  26 + return NO;
  27 + }
  28 +
  29 + NSOrderedSet *subset = [NSOrderedSet orderedSetWithOrderedSet:actual range:NSMakeRange([actual count] - [expected count], [expected count]) copyItems:NO];
  30 + return [subset isEqualToOrderedSet:expected];
  31 + }
  32 + });
  33 +
  34 + failureMessageForTo(^NSString *{
  35 + if (actualIsNil) return @"the object is nil/null";
  36 + if (expectedIsNil) return @"the expected value is nil/null";
  37 + if (!actualAndExpectedAreCompatible) return [NSString stringWithFormat:@"%@ and %@ are not instances of one of %@, %@, or %@", EXPDescribeObject(actual), EXPDescribeObject(expected), [NSString class], [NSArray class], [NSOrderedSet class]];
  38 + return [NSString stringWithFormat:@"expected: %@ to end with %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
  39 + });
  40 +
  41 + failureMessageForNotTo(^NSString *{
  42 + if (actualIsNil) return @"the object is nil/null";
  43 + if (expectedIsNil) return @"the expected value is nil/null";
  44 + if (!actualAndExpectedAreCompatible) return [NSString stringWithFormat:@"%@ and %@ are not instances of one of %@, %@, or %@", EXPDescribeObject(actual), EXPDescribeObject(expected), [NSString class], [NSArray class], [NSOrderedSet class]];
  45 +
  46 + return [NSString stringWithFormat:@"expected: %@ not to end with %@", EXPDescribeObject(actual), EXPDescribeObject(expected)];
  47 + });
  48 +}
  49 +EXPMatcherImplementationEnd
@@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
2 2
3 EXPMatcherInterface(_equal, (id expected)); 3 EXPMatcherInterface(_equal, (id expected));
4 EXPMatcherInterface(equal, (id expected)); // to aid code completion 4 EXPMatcherInterface(equal, (id expected)); // to aid code completion
5 -#define equal(expected) _equal(EXPObjectify((expected))) 5 +#define equal(...) _equal(EXPObjectify((__VA_ARGS__)))
1 #import "EXPMatchers+haveCountOf.h" 1 #import "EXPMatchers+haveCountOf.h"
2 2
3 EXPMatcherImplementationBegin(haveCountOf, (NSUInteger expected)) { 3 EXPMatcherImplementationBegin(haveCountOf, (NSUInteger expected)) {
4 - BOOL actualIsCompatible = [actual isKindOfClass:[NSString class]] || [actual respondsToSelector:@selector(count)]; 4 + BOOL actualIsStringy = [actual isKindOfClass:[NSString class]] || [actual isKindOfClass:[NSAttributedString class]];
  5 + BOOL actualIsCompatible = actualIsStringy || [actual respondsToSelector:@selector(count)];
5 6
6 prerequisite(^BOOL{ 7 prerequisite(^BOOL{
7 return actualIsCompatible; 8 return actualIsCompatible;
8 }); 9 });
9 10
10 NSUInteger (^count)(id) = ^(id actual) { 11 NSUInteger (^count)(id) = ^(id actual) {
11 - if([actual isKindOfClass:[NSString class]]) { 12 + if(actualIsStringy) {
12 return [actual length]; 13 return [actual length];
13 } else { 14 } else {
14 return [actual count]; 15 return [actual count];
@@ -23,12 +24,12 @@ EXPMatcherImplementationBegin(haveCountOf, (NSUInteger expected)) { @@ -23,12 +24,12 @@ EXPMatcherImplementationBegin(haveCountOf, (NSUInteger expected)) {
23 }); 24 });
24 25
25 failureMessageForTo(^NSString *{ 26 failureMessageForTo(^NSString *{
26 - if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)]; 27 + if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSAttributedString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)];
27 return [NSString stringWithFormat:@"expected %@ to have a count of %zi but got %zi", EXPDescribeObject(actual), expected, count(actual)]; 28 return [NSString stringWithFormat:@"expected %@ to have a count of %zi but got %zi", EXPDescribeObject(actual), expected, count(actual)];
28 }); 29 });
29 30
30 failureMessageForNotTo(^NSString *{ 31 failureMessageForNotTo(^NSString *{
31 - if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)]; 32 + if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSAttributedString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)];
32 return [NSString stringWithFormat:@"expected %@ not to have a count of %zi", EXPDescribeObject(actual), expected]; 33 return [NSString stringWithFormat:@"expected %@ not to have a count of %zi", EXPDescribeObject(actual), expected];
33 }); 34 });
34 } 35 }
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(notify, (id expectedNotification));
  4 +
  1 +#import "EXPMatchers+notify.h"
  2 +
  3 +EXPMatcherImplementationBegin(notify, (id expected)){
  4 + BOOL actualIsNil = (actual == nil);
  5 + BOOL expectedIsNil = (expected == nil);
  6 + BOOL isNotification = [expected isKindOfClass:[NSNotification class]];
  7 + BOOL isName = [expected isKindOfClass:[NSString class]];
  8 +
  9 + __block NSString *expectedName;
  10 + __block BOOL expectedNotificationOccurred = NO;
  11 + __block id observer;
  12 +
  13 + prerequisite(^BOOL{
  14 + expectedNotificationOccurred = NO;
  15 + if (actualIsNil || expectedIsNil) return NO;
  16 + if (isNotification) {
  17 + expectedName = [expected name];
  18 + }else if(isName) {
  19 + expectedName = expected;
  20 + }else{
  21 + return NO;
  22 + }
  23 +
  24 + observer = [[NSNotificationCenter defaultCenter] addObserverForName:expectedName object:nil queue:nil usingBlock:^(NSNotification *note){
  25 + if (isNotification) {
  26 + expectedNotificationOccurred |= [expected isEqual:note];
  27 + }else{
  28 + expectedNotificationOccurred = YES;
  29 + }
  30 + }];
  31 + ((EXPBasicBlock)actual)();
  32 + return YES;
  33 + });
  34 +
  35 + match(^BOOL{
  36 + if(expectedNotificationOccurred) {
  37 + [[NSNotificationCenter defaultCenter] removeObserver:observer];
  38 + }
  39 + return expectedNotificationOccurred;
  40 + });
  41 +
  42 + failureMessageForTo(^NSString *{
  43 + if (observer) {
  44 + [[NSNotificationCenter defaultCenter] removeObserver:observer];
  45 + }
  46 + if(actualIsNil) return @"the actual value is nil/null";
  47 + if(expectedIsNil) return @"the expected value is nil/null";
  48 + if(!(isNotification || isName)) return @"the actual value is not a notification or string";
  49 + return [NSString stringWithFormat:@"expected: %@, got: none",expectedName];
  50 + });
  51 +
  52 + failureMessageForNotTo(^NSString *{
  53 + if (observer) {
  54 + [[NSNotificationCenter defaultCenter] removeObserver:observer];
  55 + }
  56 + if(actualIsNil) return @"the actual value is nil/null";
  57 + if(expectedIsNil) return @"the expected value is nil/null";
  58 + if(!(isNotification || isName)) return @"the actual value is not a notification or string";
  59 + return [NSString stringWithFormat:@"expected: none, got: %@", expectedName];
  60 + });
  61 +}
  62 +
  63 +EXPMatcherImplementationEnd
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(respondTo, (SEL expected));
  1 +#import "EXPMatchers+respondTo.h"
  2 +#import "EXPMatcherHelpers.h"
  3 +
  4 +EXPMatcherImplementationBegin(respondTo, (SEL expected)) {
  5 + BOOL actualIsNil = (actual == nil);
  6 + BOOL expectedIsNull = (expected == NULL);
  7 +
  8 + prerequisite (^BOOL {
  9 + return !(actualIsNil || expectedIsNull);
  10 + });
  11 +
  12 + match(^BOOL {
  13 + return [actual respondsToSelector:expected];
  14 + });
  15 +
  16 + failureMessageForTo(^NSString *{
  17 + if (actualIsNil) return @"the object is nil/null";
  18 + if (expectedIsNull) return @"the selector is null";
  19 + return [NSString stringWithFormat:@"expected: %@ to respond to %@", EXPDescribeObject(actual), NSStringFromSelector(expected)];
  20 + });
  21 +
  22 + failureMessageForNotTo(^NSString *{
  23 + if (actualIsNil) return @"the object is nil/null";
  24 + if (expectedIsNull) return @"the selector is null";
  25 + return [NSString stringWithFormat:@"expected: %@ not to respond to %@", EXPDescribeObject(actual), NSStringFromSelector(expected)];
  26 + });
  27 +}
  28 +EXPMatcherImplementationEnd
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 #import "EXPMatchers+beTruthy.h" 7 #import "EXPMatchers+beTruthy.h"
8 #import "EXPMatchers+beFalsy.h" 8 #import "EXPMatchers+beFalsy.h"
9 #import "EXPMatchers+contain.h" 9 #import "EXPMatchers+contain.h"
  10 +#import "EXPMatchers+beSupersetOf.h"
10 #import "EXPMatchers+haveCountOf.h" 11 #import "EXPMatchers+haveCountOf.h"
11 #import "EXPMatchers+beIdenticalTo.h" 12 #import "EXPMatchers+beIdenticalTo.h"
12 #import "EXPMatchers+beGreaterThan.h" 13 #import "EXPMatchers+beGreaterThan.h"
@@ -17,3 +18,7 @@ @@ -17,3 +18,7 @@
17 #import "EXPMatchers+beCloseTo.h" 18 #import "EXPMatchers+beCloseTo.h"
18 #import "EXPMatchers+raise.h" 19 #import "EXPMatchers+raise.h"
19 #import "EXPMatchers+raiseWithReason.h" 20 #import "EXPMatchers+raiseWithReason.h"
  21 +#import "EXPMatchers+respondTo.h"
  22 +#import "EXPMatchers+notify.h"
  23 +#import "EXPMatchers+beginWith.h"
  24 +#import "EXPMatchers+endWith.h"
  1 +../../Expecta/src/matchers/EXPMatchers+beSupersetOf.h
  1 +../../Expecta/src/matchers/EXPMatchers+beginWith.h
  1 +../../Expecta/src/matchers/EXPMatchers+endWith.h
  1 +../../Expecta/src/matchers/EXPMatchers+notify.h
  1 +../../Expecta/src/matchers/EXPMatchers+respondTo.h
1 Pod::Spec.new do |s| 1 Pod::Spec.new do |s|
2 s.name = 'Masonry' 2 s.name = 'Masonry'
3 - s.version = '0.4.0' 3 + s.version = '0.5.0'
4 s.license = 'MIT' 4 s.license = 'MIT'
5 s.summary = 'Harness the power of Auto Layout NSLayoutConstraints with a simplified, chainable and expressive syntax.' 5 s.summary = 'Harness the power of Auto Layout NSLayoutConstraints with a simplified, chainable and expressive syntax.'
6 s.homepage = 'https://github.com/cloudkite/Masonry' 6 s.homepage = 'https://github.com/cloudkite/Masonry'
7 s.author = { 'Jonas Budelmann' => 'jonas.budelmann@gmail.com' } 7 s.author = { 'Jonas Budelmann' => 'jonas.budelmann@gmail.com' }
  8 + s.social_media_url = "http://twitter.com/cloudkite"
8 9
9 - s.source = { :git => 'https://github.com/cloudkite/Masonry.git', :tag => 'v0.4.0' } 10 + s.source = { :git => 'https://github.com/cloudkite/Masonry.git', :tag => 'v0.5.0' }
10 11
11 s.description = %{ 12 s.description = %{
12 Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax. 13 Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax.
1 PODS: 1 PODS:
2 - - Expecta (0.2.3)  
3 - - Masonry (0.4.0) 2 + - Expecta (0.3.0)
  3 + - Masonry (0.5.0)
4 4
5 DEPENDENCIES: 5 DEPENDENCIES:
6 - Expecta 6 - Expecta
@@ -11,7 +11,7 @@ EXTERNAL SOURCES: @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
11 :path: ./ 11 :path: ./
12 12
13 SPEC CHECKSUMS: 13 SPEC CHECKSUMS:
14 - Expecta: 2434bb2e2b3b1814280ec5d9a11359433d035975  
15 - Masonry: d673617c9cbc24aaea90fba20b10e47fd9970a39 14 + Expecta: 322f1dc42610106a5ba9871b4924cf1635d80833
  15 + Masonry: bef482b29f00b33a2da916e1011af85f5d371d66
16 16
17 COCOAPODS: 0.32.1 17 COCOAPODS: 0.32.1
@@ -9,6 +9,6 @@ @@ -9,6 +9,6 @@
9 // Masonry 9 // Masonry
10 #define COCOAPODS_POD_AVAILABLE_Masonry 10 #define COCOAPODS_POD_AVAILABLE_Masonry
11 #define COCOAPODS_VERSION_MAJOR_Masonry 0 11 #define COCOAPODS_VERSION_MAJOR_Masonry 0
12 -#define COCOAPODS_VERSION_MINOR_Masonry 4 12 +#define COCOAPODS_VERSION_MINOR_Masonry 5
13 #define COCOAPODS_VERSION_PATCH_Masonry 0 13 #define COCOAPODS_VERSION_PATCH_Masonry 0
14 14
@@ -9,6 +9,6 @@ @@ -9,6 +9,6 @@
9 // Expecta 9 // Expecta
10 #define COCOAPODS_POD_AVAILABLE_Expecta 10 #define COCOAPODS_POD_AVAILABLE_Expecta
11 #define COCOAPODS_VERSION_MAJOR_Expecta 0 11 #define COCOAPODS_VERSION_MAJOR_Expecta 0
12 -#define COCOAPODS_VERSION_MINOR_Expecta 2  
13 -#define COCOAPODS_VERSION_PATCH_Expecta 3 12 +#define COCOAPODS_VERSION_MINOR_Expecta 3
  13 +#define COCOAPODS_VERSION_PATCH_Expecta 0
14 14
@@ -9,6 +9,6 @@ @@ -9,6 +9,6 @@
9 // Masonry 9 // Masonry
10 #define COCOAPODS_POD_AVAILABLE_Masonry 10 #define COCOAPODS_POD_AVAILABLE_Masonry
11 #define COCOAPODS_VERSION_MAJOR_Masonry 0 11 #define COCOAPODS_VERSION_MAJOR_Masonry 0
12 -#define COCOAPODS_VERSION_MINOR_Masonry 4 12 +#define COCOAPODS_VERSION_MINOR_Masonry 5
13 #define COCOAPODS_VERSION_PATCH_Masonry 0 13 #define COCOAPODS_VERSION_PATCH_Masonry 0
14 14
This diff could not be displayed because it is too large.