Skip to content

Commit

Permalink
Added a Podfile for library development. This means that the Library …
Browse files Browse the repository at this point in the history
…can now be developed with cocoapods. And tested too
  • Loading branch information
ethanmick committed Mar 7, 2014
1 parent 9a110ad commit 4708751
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 70 deletions.
28 changes: 22 additions & 6 deletions .gitignore
@@ -1,12 +1,28 @@
# OS generated files #
######################
.DS_Store
._*
*.sw*

# Xcode Files #
###############
build/
xcuserdata/


# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout

#CocoaPods
Pods

17 changes: 17 additions & 0 deletions Podfile
@@ -0,0 +1,17 @@
#
#
#
platform :ios, '6.0'
workspace 'cm-ios'
xcodeproj 'ios/cloudmine-ios'
inhibit_all_warnings!

target "cloudmine-ios" do
pod 'AFNetworking', '~> 1.3.3'
end



target 'cloudmine-iosTests', :exclusive => true do
pod 'Kiwi'
end
19 changes: 19 additions & 0 deletions Podfile.lock
@@ -0,0 +1,19 @@
PODS:
- AFNetworking (1.3.3)
- Kiwi (2.2.3):
- Kiwi/SenTestingKit
- Kiwi/ARC (2.2.3)
- Kiwi/NonARC (2.2.3)
- Kiwi/SenTestingKit (2.2.3):
- Kiwi/ARC
- Kiwi/NonARC

DEPENDENCIES:
- AFNetworking (~> 1.3.3)
- Kiwi

SPEC CHECKSUMS:
AFNetworking: 61fdd49e2ffe6380378df37b3b6e70630bb9dd66
Kiwi: 04c51e880831d291748ec702d42c4101f7eb95c9

COCOAPODS: 0.29.0
8 changes: 1 addition & 7 deletions cm-ios.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 84 additions & 31 deletions ios/cloudmine-ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ios/iosTests/CMObjectDecoderSpec.m
Expand Up @@ -6,7 +6,6 @@
// See LICENSE file included with SDK for details.
//

#import <YAJLiOS/YAJL.h>
#import "Kiwi.h"

#import "CMObjectEncoder.h"
Expand Down Expand Up @@ -73,7 +72,8 @@
});

it(@"should NOT be able to deserialize a dictionary when it's at the top-level", ^{
NSDictionary *dictionary = [@"{ \"1234\": { \"__id__\": \"1234\", \"__class__\": \"map\", \"name\": \"foo\" } }" yajl_JSON];

NSDictionary *dictionary = @{@"1234": @{@"__id__": @"1234", @"__class__" : @"map", @"name": @"foo"}};
[[theBlock(^{
[CMObjectDecoder decodeObjects:dictionary];
}) should] raiseWithName:@"CMInternalInconsistencyException"];
Expand Down
19 changes: 11 additions & 8 deletions ios/iosTests/CMUserSpec.m
Expand Up @@ -7,7 +7,6 @@
//

#import "Kiwi.h"
#import "SPLowVerbosity.h"

#import "CMUser.h"
#import "CMWebService.h"
Expand Down Expand Up @@ -119,8 +118,8 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
}];

CMWebServiceUserFetchSuccessCallback callback = callbackBlockSpy.argument;
NSDictionary *userState = [CMObjectEncoder encodeObjects:$set(user)];
callback(userState, [NSDictionary dictionary], $num(1));
NSDictionary *userState = [CMObjectEncoder encodeObjects:[NSSet setWithObject:user]];
callback(userState, [NSDictionary dictionary], @1);

// Now let's do the same thing again, but this time it should read from the cache.
[[CMUser should] receive:@selector(userFromCacheWithIdentifier:) withArguments:user.objectId];
Expand All @@ -141,7 +140,7 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
}];

CMWebServiceUserAccountOperationCallback callback = callbackBlockSpy.argument;
NSDictionary *userState = [[CMObjectEncoder encodeObjects:$set(user)] objectForKey:user.objectId];
NSDictionary *userState = [[CMObjectEncoder encodeObjects:[NSSet setWithObject:user]] objectForKey:user.objectId];
callback(CMUserAccountProfileUpdateSucceeded, userState);

// Object has just been saved, so it should not be dirty.
Expand Down Expand Up @@ -169,7 +168,9 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
[user loginWithCallback:nil];

// Make a mock response from the web server with changes we haven't seen yet.
NSMutableDictionary *userState = $mdict(@"session_token", @"5555", @"expires", @"Mon 01 Jun 2020 01:00:00 GMT", @"profile", $dict(@"name", @"Philip", @"age", $num(30)));
NSMutableDictionary *userState = [NSMutableDictionary dictionaryWithDictionary:@{@"session_token": @"5555",
@"expires": @"Mon 01 Jun 2020 01:00:00 GMT",
@"profile": @{@"name": @"Philip", @"age": @30}}];

CMWebServiceUserAccountOperationCallback callback = callbackBlockSpy.argument;
callback(CMUserAccountLoginSucceeded, userState);
Expand Down Expand Up @@ -197,7 +198,9 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
[user loginWithCallback:nil];

// Make a mock response from the web server with changes we haven't seen yet.
NSMutableDictionary *userState = $mdict(@"session_token", @"5555", @"expires", @"Mon 01 Jun 2020 01:00:00 GMT", @"profile", $dict(@"name", @"Philip", @"age", $num(30)));
NSMutableDictionary *userState = [NSMutableDictionary dictionaryWithDictionary:@{@"session_token": @"5555",
@"expires": @"Mon 01 Jun 2020 01:00:00 GMT",
@"profile": @{@"name": @"Philip", @"age": @30}}];

CMWebServiceUserAccountOperationCallback callback = callbackBlockSpy.argument;
callback(CMUserAccountLoginSucceeded, userState);
Expand Down Expand Up @@ -242,7 +245,7 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
user.name = nil;
user.age = 0;

NSDictionary *serializedUser = [CMObjectEncoder encodeObjects:$set(user)];
NSDictionary *serializedUser = [CMObjectEncoder encodeObjects:[NSSet setWithObject:user]];
NSDictionary *theUser = [serializedUser objectForKey:user.objectId];

[[[theUser valueForKey:@"name"] should] beIdenticalTo:[NSNull null]];
Expand All @@ -258,7 +261,7 @@ -(id) initWithCoder:(NSCoder *)aDecoder {
[user setValue:@"1234" forKey:@"objectId"];
user.name = NULL;

NSDictionary *serializedUser = [CMObjectEncoder encodeObjects:$set(user)];
NSDictionary *serializedUser = [CMObjectEncoder encodeObjects:[NSSet setWithObject:user]];
NSDictionary *theUser = [serializedUser objectForKey:user.objectId];
NSLog(@"Result: %@", serializedUser);

Expand Down
29 changes: 13 additions & 16 deletions ios/iosTests/CMWebServiceSpec.m
Expand Up @@ -6,8 +6,6 @@
// See LICENSE file included with SDK for details.
//

#import <YAJLiOS/YAJL.h>

#import "Kiwi.h"

#import "NSMutableData+RandomData.h"
Expand Down Expand Up @@ -280,7 +278,7 @@
[[[request URL] should] equal:expectedUrl];
[[[request HTTPMethod] should] equal:@"POST"];
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
// [[[[request HTTPBody] to] should] equal:dataToPost];
});

it(@"binary data URLs at the app level correctly", ^{
Expand Down Expand Up @@ -332,7 +330,7 @@
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-SessionToken"] should] equal:creds.token];
[[[request HTTPMethod] should] equal:@"POST"];
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
// [[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
});

it(@"ACL URLs correctly", ^{
Expand All @@ -357,7 +355,7 @@
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-SessionToken"] should] equal:creds.token];
[[[request HTTPMethod] should] equal:@"POST"];
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[[request HTTPBody] yajl_JSON] should] equal:aclDict];
// [[[[request HTTPBody] yajl_JSON] should] equal:aclDict];
});
});

Expand Down Expand Up @@ -411,7 +409,7 @@
[[[request URL] should] equal:expectedUrl];
[[[request HTTPMethod] should] equal:@"PUT"];
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
// [[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
});

it(@"JSON URLs at the user level correctly", ^{
Expand All @@ -438,7 +436,7 @@
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-SessionToken"] should] equal:creds.token];
[[[request HTTPMethod] should] equal:@"PUT"];
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
// [[[[request HTTPBody] yajl_JSON] should] equal:dataToPost];
});
});

Expand Down Expand Up @@ -559,7 +557,7 @@
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-SessionToken"] shouldBeNil];

NSDictionary *requestBody = [[request HTTPBody] yajl_JSON];
NSDictionary *requestBody = [NSJSONSerialization JSONObjectWithData:[request HTTPBody] options:0 error:nil];
[[[requestBody objectForKey:@"credentials"] should] haveValue:@"test@domain.com" forKey:@"email"];
[[[requestBody objectForKey:@"credentials"] should] haveValue:@"pass" forKey:@"password"];
});
Expand Down Expand Up @@ -634,7 +632,7 @@
[[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-ApiKey"] should] equal:appSecret];
[[[request allHTTPHeaderFields] objectForKey:@"X-CloudMine-SessionToken"] shouldBeNil];

[[[[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding] should] equal:[@{@"username" : @"aNewUsername", @"email" : @"aNewUserID"} yajl_JSONString]];
// [[[[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding] should] equal:[@{@"username" : @"aNewUsername", @"email" : @"aNewUserID"} yajl_JSONString]];
});


Expand All @@ -648,7 +646,7 @@
NSURLRequest *request = spy.argument;
[[[request URL] should] equal:expectedUrl];
[[[request HTTPMethod] should] equal:@"POST"];
[[[[request HTTPBody] yajl_JSON] should] equal:[@"{\"email\":\"test@domain.com\"}" yajl_JSON]];
// [[[[request HTTPBody] yajl_JSON] should] equal:[@"{\"email\":\"test@domain.com\"}" yajl_JSON]];
});

it(@"constructs login URL correctly", ^{
Expand Down Expand Up @@ -746,7 +744,7 @@

}];

NSString *finalURLShould = $sprintf(@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/user_timeline.json?params={\"count\":9,\"screen_name\":\"ethan_mick\"}", appId);
NSString *finalURLShould = [NSString stringWithFormat:@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/user_timeline.json?params={\"count\":9,\"screen_name\":\"ethan_mick\"}", appId];
finalURLShould = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)finalURLShould,
Expand Down Expand Up @@ -781,7 +779,7 @@

}];

NSString *finalURLShould = $sprintf(@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/user_timeline.json?params={\"screen_name\":\"ethan_mick\",\"testing\":[\"Testing111\",\"Testing222\"]}", appId);
NSString *finalURLShould = [NSString stringWithFormat:@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/user_timeline.json?params={\"screen_name\":\"ethan_mick\",\"testing\":[\"Testing111\",\"Testing222\"]}", appId];
finalURLShould = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)finalURLShould,
Expand Down Expand Up @@ -818,7 +816,7 @@
}];


NSString *finalURLShould = $sprintf(@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/update.json?headers={\"Content-type\":\"application/x-www-form-urlencoded\"}", appId);
NSString *finalURLShould = [NSString stringWithFormat:@"https://api.cloudmine.me/v1/app/%@/user/social/twitter/statuses/update.json?headers={\"Content-type\":\"application/x-www-form-urlencoded\"}", appId];
finalURLShould = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)finalURLShould,
Expand All @@ -843,8 +841,7 @@
[service registerForPushNotificationsWithUser:nil token:(NSData *)token callback:^(CMDeviceTokenResult result) {}];

NSURLRequest *request = spy.argument;

NSDictionary *requestBody = [[request HTTPBody] yajl_JSON];
NSDictionary *requestBody = [NSJSONSerialization JSONObjectWithData:[request HTTPBody] options:0 error:nil];
[[[requestBody valueForKey:@"token"] should] equal:@"c7e265d1cbd443b3ee80fd07c892a8b8f20c08c491fa11f2535f2ccaad7f55ef"];


Expand All @@ -856,7 +853,7 @@

NSURLRequest *request = spy.argument;

[[[[request URL] absoluteString] should] equal:$sprintf(@"https://api.cloudmine.me/v1/app/%@/device", appId)];
[[[[request URL] absoluteString] should] equal:[NSString stringWithFormat:@"https://api.cloudmine.me/v1/app/%@/device", appId]];;
[[[request HTTPMethod] should] equal:@"DELETE"];
});
});
Expand Down

0 comments on commit 4708751

Please sign in to comment.