Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move -debugDescription implementation to -description method for improved debugability #107

Merged
merged 2 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SPTDataLoader/SPTDataLoaderRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ + (NSString *)generateLanguageHeaderValue
return [languageHeaderValues componentsJoinedByString:SPTDataLoaderRequestLanguageHeaderValuesJoiner];
}

- (NSString *)debugDescription
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ { URL: %@ }", [super debugDescription], self.URL];
return [NSString stringWithFormat:@"<%@: %p URL = \"%@\">", self.class, (void *)self, self.URL];
}

#pragma mark NSCopying
Expand Down
4 changes: 2 additions & 2 deletions SPTDataLoader/SPTDataLoaderResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ - (nullable NSDate *)retryAfterForHeaders:(NSDictionary<NSString *, NSString *>
return [httpDateFormatter dateFromString:retryAfterValue];
}

- (NSString *)debugDescription
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ { URL: %@ } { status code: %ld, headers: %@ }", [super debugDescription], self.response.URL, (long)self.statusCode, self.responseHeaders];
return [NSString stringWithFormat:@"<%@: %p URL = \"%@\"; status-code = %ld; headers = %@>", self.class, (void *)self, self.response.URL, (long)self.statusCode, self.responseHeaders];
}


Expand Down
12 changes: 6 additions & 6 deletions SPTDataLoaderTests/SPTDataLoaderRequestTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ - (void)testAcceptLanguageWithNoEnglishLanguages
XCTAssertEqualObjects(@"fr-CA, pt-PT;q=0.50, en;q=0.01", languageValues);
}

- (void)testDebugDescription
- (void)testDescription
{
XCTAssertNotNil(self.request.debugDescription,
@"The debugDescription shouldn't be nil.");
XCTAssertNotNil(self.request.description,
@"The description shouldn't be nil.");

NSString *URLString = [NSString stringWithFormat:@"URL: %@", self.URL.absoluteString];
XCTAssertTrue([self.request.debugDescription containsString:URLString],
@"The debugDescription should contain the URL of the request.");
NSString *URLString = [NSString stringWithFormat:@"URL = \"%@\"", self.URL.absoluteString];
XCTAssertTrue([self.request.description containsString:URLString],
@"The description should contain the URL of the request.");
}

- (void)testAcceptLanguageWithMultipleLanguagesContainingEnglish
Expand Down
24 changes: 12 additions & 12 deletions SPTDataLoaderTests/SPTDataLoaderResponseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,22 @@ - (void)testShouldNotRetryForCancelled
XCTAssertFalse(shouldRetry, @"The response should not retry when the connection was cancelled");
}

- (void)testDebugDescription
- (void)testDescription
{
XCTAssertNotNil(self.response.debugDescription,
@"The debugDescription shouldn't be nil.");
XCTAssertNotNil(self.response.description,
@"The description shouldn't be nil.");

NSString *URLString = [NSString stringWithFormat:@"URL: %@", self.urlResponse.URL];
XCTAssertTrue([self.response.debugDescription containsString:URLString],
@"The debugDescription should contain the URL of the response");
NSString *URLString = [NSString stringWithFormat:@"URL = \"%@\"", self.urlResponse.URL];
XCTAssertTrue([self.response.description containsString:URLString],
@"The description should contain the URL of the response");

NSString *statusCodeString = [NSString stringWithFormat:@"status code: %ld", (long)self.response.statusCode];
XCTAssertTrue([self.response.debugDescription containsString:statusCodeString],
@"The debugDescription should contain the status code of the response");
NSString *statusCodeString = [NSString stringWithFormat:@"status-code = %ld", (long)self.response.statusCode];
XCTAssertTrue([self.response.description containsString:statusCodeString],
@"The description should contain the status code of the response");

NSString *headersString = [NSString stringWithFormat:@"headers: %@", self.response.responseHeaders];
XCTAssertTrue([self.response.debugDescription containsString:headersString],
@"The debugDescription should contain the headers code of the response");
NSString *headersString = [NSString stringWithFormat:@"headers = %@", self.response.responseHeaders];
XCTAssertTrue([self.response.description containsString:headersString],
@"The description should contain the headers code of the response");
}


Expand Down