Inherits from NSObject
Conforms to RKTestFactoryCallbacks
Declared in RKTestFactory.h
RKTestFactory.m

Overview

RKTestFactory provides an interface for initializing RestKit objects within a unit testing environment. The factory is used to ensure isolation between test cases by ensuring that RestKit’s important singleton objects are torn down between tests and that each test is working within a clean Core Data environment. Callback hooks are provided so that application specific set up and tear down logic can be integrated as well.

Tasks

Configuring the Factory

Building Instances

Managing Test State

  • + setUp

    Sets up the RestKit testing environment. Invokes the didSetUp callback for application specific setup.

  • + tearDown

    Tears down the RestKit testing environment by clearing singleton instances, helping to ensure test case isolation. Invokes the didTearDown callback for application specific cleanup.

Other Tasks

  • + clearCacheDirectory

    Clears the contents of the cache directory by removing the directory and recreating it.

Class Methods

baseURL

Returns the base URL with which to initialize RKClient and RKObjectManager instances created via the factory.

+ (RKURL *)baseURL

Return Value

The base URL for the factory.

Declared In

RKTestFactory.h

baseURLString

Returns the base URL as a string value.

+ (NSString *)baseURLString

Return Value

The base URL for the factory, as a string.

Declared In

RKTestFactory.h

clearCacheDirectory

Clears the contents of the cache directory by removing the directory and recreating it.

+ (void)clearCacheDirectory

Declared In

RKTestFactory.h

client

Creates and returns an RKClient instance.

+ (RKClient *)client

Return Value

A new client object.

Declared In

RKTestFactory.h

managedObjectStore

Creates and returns a RKManagedObjectStore instance.

+ (RKManagedObjectStore *)managedObjectStore

Return Value

A new managed object store object.

Discussion

A new managed object store will be configured and returned. If there is an existing persistent store (i.e. from a previous test invocation), then the persistent store is deleted.

Declared In

RKTestFactory.h

objectManager

Creates and returns an RKObjectManager instance.

+ (RKObjectManager *)objectManager

Return Value

A new client object.

Declared In

RKTestFactory.h

setBaseURL:

Sets the base URL for the factory.

+ (void)setBaseURL:(RKURL *)URL

Parameters

URL

The new base URL.

Declared In

RKTestFactory.h

setBaseURLString:

Sets the base URL for the factory to a new value by constructing an RKURL from the given string.

+ (void)setBaseURLString:(NSString *)baseURLString

Parameters

A

string containing the URL to set as the base URL for the factory.

Declared In

RKTestFactory.h

setUp

Sets up the RestKit testing environment. Invokes the didSetUp callback for application specific setup.

+ (void)setUp

Declared In

RKTestFactory.h

tearDown

Tears down the RestKit testing environment by clearing singleton instances, helping to ensure test case isolation. Invokes the didTearDown callback for application specific cleanup.

+ (void)tearDown

Declared In

RKTestFactory.h