Permalink
Browse files

Normalized the bundle identifier for Logic and Application Tests to '…

…org.restkit.tests'
  • Loading branch information...
1 parent b18abc0 commit 515a8dfcfbc46412628b7239032dedbdc9ebf856 @blakewatters blakewatters committed Apr 6, 2012
@@ -45,6 +45,14 @@
*/
+ (void)setFixtureBundle:(NSBundle *)bundle;
+/**
+ Returns the full path to the specified fixture file on within the fixture bundle.
+
+ @param fixtureName The name of the fixture file.
+ @return The full path to the specified fixture file or nil if it cannot be located.
+ */
++ (NSString *)pathForFixture:(NSString *)fixtureName;
+
#if TARGET_OS_IPHONE
/**
Creates and returns an image object by loading the image data from the fixture identified by the specified file name.
@@ -37,6 +37,10 @@ + (void)setFixtureBundle:(NSBundle *)bundle {
fixtureBundle = bundle;
}
++ (NSString *)pathForFixture:(NSString *)fixtureName {
+ return [[self fixtureBundle] pathForResource:fixtureName ofType:nil];
+}
+
#if TARGET_OS_IPHONE
+ (UIImage *)imageWithContentsOfFixture:(NSString *)fixtureName {
return [[self fixtureBundle] imageWithContentsOfResource:fixtureName withExtension:nil];
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
- <string>org.restkit.unit-tests</string>
+ <string>org.restkit.tests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
- <string>org.restkit.unit-tests</string>
+ <string>org.restkit.tests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
- <string>org.restkit.${PRODUCT_NAME:rfc1034identifier}</string>
+ <string>org.restkit.tests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
@@ -51,8 +51,7 @@ - (void)testShouldReturnAnMD5ForNSData {
}
- (void)testShouldReturnAnMD5ForFiles {
- NSBundle *testBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
- NSString *filePath = [testBundle pathForResource:@"blake" ofType:@"png"];
+ NSString *filePath = [RKTestFixture pathForFixture:@"blake.png"];
RKParamsAttachment *attachment = [[[RKParamsAttachment alloc] initWithName:@"foo" file:filePath] autorelease];
assertThat([attachment MD5], is(equalTo(@"db6cb9d879b58e7e15a595632af345cd")));
}
@@ -49,9 +49,7 @@ - (void)testShouldUploadFilesViaRKParams {
[params setValue:@"two" forParam:@"value"];
[params setValue:@"three" forParam:@"value"];
[params setValue:@"four" forParam:@"value"];
- NSBundle *testBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
- NSString *imagePath = [testBundle pathForResource:@"blake" ofType:@"png"];
- NSData *data = [NSData dataWithContentsOfFile:imagePath];
+ NSData *data = [RKTestFixture dataWithContentsOfFixture:@"blake.png"];
[params setData:data MIMEType:@"image/png" forParam:@"file"];
RKTestResponseLoader* responseLoader = [RKTestResponseLoader responseLoader];
[client post:@"/upload" params:params delegate:responseLoader];
@@ -65,9 +63,7 @@ - (void)testShouldUploadFilesViaRKParamsWithMixedTypes {
NSNumber* idTema = [NSNumber numberWithInt:1234];
NSString* titulo = @"whatever";
NSString* texto = @"more text";
- NSBundle *testBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
- NSString *imagePath = [testBundle pathForResource:@"blake" ofType:@"png"];
- NSData *data = [NSData dataWithContentsOfFile:imagePath];
+ NSData *data = [RKTestFixture dataWithContentsOfFixture:@"blake.png"];
NSNumber* cel = [NSNumber numberWithFloat:1.232442];
NSNumber* lon = [NSNumber numberWithFloat:18231.232442];;
NSNumber* lat = [NSNumber numberWithFloat:13213123.232442];;
@@ -108,9 +104,7 @@ - (void)testShouldProperlyCalculateContentLengthForFileUploads {
[params setValue:@"two" forParam:@"value"];
[params setValue:@"three" forParam:@"value"];
[params setValue:@"four" forParam:@"value"];
- NSBundle *testBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
- NSString *imagePath = [testBundle pathForResource:@"blake" ofType:@"png"];
- NSData *data = [NSData dataWithContentsOfFile:imagePath];
+ NSData *data = [RKTestFixture dataWithContentsOfFixture:@"blake.png"];
[params setData:data MIMEType:@"image/png" forParam:@"file"];
RKRequest *request = [client requestWithResourcePath:@"/upload"];
[request setMethod:RKRequestMethodPOST];
@@ -59,8 +59,7 @@ - (void)testShouldSendMultiPartRequests {
NSURL* URL = [NSURL URLWithString:URLString];
RKRequest* request = [[RKRequest alloc] initWithURL:URL];
RKParams* params = [[RKParams params] retain];
- NSBundle *testBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
- NSString* filePath = [testBundle pathForResource:@"blake" ofType:@"png"];
+ NSString* filePath = [RKTestFixture pathForFixture:@"blake.png"];
[params setFile:filePath forParam:@"file"];
[params setValue:@"this is the value" forParam:@"test"];
request.method = RKRequestMethodPOST;
@@ -38,8 +38,9 @@ @implementation RKTestCase
+ (void)initialize
{
- // Configure fixture bundle
- NSBundle *fixtureBundle = [NSBundle bundleWithIdentifier:@"org.restkit.unit-tests"];
+ // Configure fixture bundle. The 'org.restkit.tests' identifier is shared between
+ // the logic and application test bundles
+ NSBundle *fixtureBundle = [NSBundle bundleWithIdentifier:@"org.restkit.tests"];
[RKTestFixture setFixtureBundle:fixtureBundle];
// Ensure the required directories exist

0 comments on commit 515a8df

Please sign in to comment.