Skip to content

Commit f00a760

Browse files
committed
fixed issue with removeAllCachedResponse being slow on the simulator
since xcode8 clean action is not supported
1 parent a89c033 commit f00a760

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ rvm: 2.4.1
44
cache:
55
- bundler
66
- cocoapods
7-
install:
8-
- bundle install
9-
- travis_wait 30 bundle exec pod repo update --silent
10-
- travis_wait 30 bundle exec pod install
7+
before_install:
8+
- brew outdated xctool || brew upgrade xctool
119
script:
1210
- bundle exec rake ci
1311
branches:

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ namespace :test do
3333
# Provides validation that RestKit continues to build without Core Data. This requires conditional compilation that is error prone
3434
task :building_without_core_data do
3535
title 'Testing without Core Data'
36-
run('cd Examples/RKTwitter && pod install')
37-
run('xctool -workspace Examples/RKTwitter/RKTwitter.xcworkspace -scheme RKTwitter -sdk iphonesimulator clean build ONLY_ACTIVE_ARCH=NO')
36+
run('cd Examples/RKTwitter && bundle exec pod install')
37+
run('xctool -workspace Examples/RKTwitter/RKTwitter.xcworkspace -scheme RKTwitter -sdk iphonesimulator build ONLY_ACTIVE_ARCH=NO')
3838
end
3939
end
4040

@@ -155,7 +155,7 @@ namespace :build do
155155
puts "Building '#{example_project}' with SDK #{sdk}..."
156156
scheme = project_name
157157
run("cd #{project_path} && pod install")
158-
run("xctool -workspace #{project_workspace} -scheme #{scheme} -sdk #{sdk} clean build")
158+
run("xctool -workspace #{project_workspace} -scheme #{scheme} -sdk #{sdk} build")
159159
end
160160
end
161161
end

Tests/Logic/Network/RKObjectRequestOperationTest.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,17 @@ - (void)testCopyingOperationWithFaiureBlock
796796

797797
- (void)testThatCacheEntryIsFlaggedWhenMappingCompletes
798798
{
799+
[[NSURLCache sharedURLCache] removeAllCachedResponses];
800+
799801
RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[RKTestComplexUser class]];
800802
[userMapping addAttributeMappingsFromDictionary:@{ @"name": @"email" }];
801803
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:userMapping method:RKRequestMethodAny pathPattern:nil keyPath:@"human" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
802804

803805
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/coredata/etag" relativeToURL:[RKTestFactory baseURL]]];
806+
807+
// Make sure the shared cache doesn't contain any response from previous tests
808+
while ([[NSURLCache sharedURLCache] cachedResponseForRequest:request]) { }
809+
804810
RKObjectRequestOperation *requestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[ responseDescriptor ]];
805811
[requestOperation start];
806812
expect([requestOperation isFinished]).will.beTruthy();
@@ -814,11 +820,15 @@ - (void)testThatCacheEntryIsFlaggedWhenMappingCompletes
814820
- (void)testThatCacheEntryIsNotFlaggedWhenMappingFails
815821
{
816822
[[NSURLCache sharedURLCache] removeAllCachedResponses];
817-
823+
818824
RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[RKTestComplexUser class]];
819825
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:userMapping method:RKRequestMethodAny pathPattern:@"/mismatch" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
820826

821827
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/coredata/etag" relativeToURL:[RKTestFactory baseURL]]];
828+
829+
// Make sure the shared cache doesn't contain any response from previous tests
830+
while ([[NSURLCache sharedURLCache] cachedResponseForRequest:request]) { }
831+
822832
RKObjectRequestOperation *requestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[ responseDescriptor ]];
823833
[requestOperation start];
824834
expect([requestOperation isFinished]).will.beTruthy();

0 commit comments

Comments
 (0)