diff --git a/Code/Testing/RKTestFixture.h b/Code/Testing/RKTestFixture.h index 4bc6bb2c..909f8d69 100644 --- a/Code/Testing/RKTestFixture.h +++ b/Code/Testing/RKTestFixture.h @@ -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. diff --git a/Code/Testing/RKTestFixture.m b/Code/Testing/RKTestFixture.m index b86ace98..3f689bac 100644 --- a/Code/Testing/RKTestFixture.m +++ b/Code/Testing/RKTestFixture.m @@ -37,6 +37,10 @@ static NSBundle *fixtureBundle = nil; 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]; diff --git a/Resources/PLISTs/RestKitFrameworkTests-Info.plist b/Resources/PLISTs/RestKitFrameworkTests-Info.plist index ddf878a8..883b278e 100644 --- a/Resources/PLISTs/RestKitFrameworkTests-Info.plist +++ b/Resources/PLISTs/RestKitFrameworkTests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - org.restkit.unit-tests + org.restkit.tests CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/Resources/PLISTs/RestKitTests-Info.plist b/Resources/PLISTs/RestKitTests-Info.plist index ddf878a8..883b278e 100644 --- a/Resources/PLISTs/RestKitTests-Info.plist +++ b/Resources/PLISTs/RestKitTests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - org.restkit.unit-tests + org.restkit.tests CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/Tests/Application/RKApplicationTests/Tests/RKApplicationTestsTests-Info.plist b/Tests/Application/RKApplicationTests/Tests/RKApplicationTestsTests-Info.plist index 95311b96..883b278e 100644 --- a/Tests/Application/RKApplicationTests/Tests/RKApplicationTestsTests-Info.plist +++ b/Tests/Application/RKApplicationTests/Tests/RKApplicationTestsTests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - org.restkit.${PRODUCT_NAME:rfc1034identifier} + org.restkit.tests CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/Tests/Logic/Network/RKParamsAttachmentTest.m b/Tests/Logic/Network/RKParamsAttachmentTest.m index 85c95233..bf325cea 100644 --- a/Tests/Logic/Network/RKParamsAttachmentTest.m +++ b/Tests/Logic/Network/RKParamsAttachmentTest.m @@ -51,8 +51,7 @@ } - (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"))); } diff --git a/Tests/Logic/Network/RKParamsTest.m b/Tests/Logic/Network/RKParamsTest.m index 6d09fc47..d29699c3 100644 --- a/Tests/Logic/Network/RKParamsTest.m +++ b/Tests/Logic/Network/RKParamsTest.m @@ -49,9 +49,7 @@ [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 @@ 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 @@ [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]; diff --git a/Tests/Logic/Network/RKRequestTest.m b/Tests/Logic/Network/RKRequestTest.m index e419fcb4..ea6186aa 100644 --- a/Tests/Logic/Network/RKRequestTest.m +++ b/Tests/Logic/Network/RKRequestTest.m @@ -59,8 +59,7 @@ 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; diff --git a/Tests/RKTestEnvironment.m b/Tests/RKTestEnvironment.m index 0530889a..d1243cdb 100644 --- a/Tests/RKTestEnvironment.m +++ b/Tests/RKTestEnvironment.m @@ -38,8 +38,9 @@ void RKTestClearCacheDirectory(void) { + (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