Skip to content

Commit

Permalink
Fix broken unit tests related to Core Data cache skipping optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewatters committed Apr 4, 2012
1 parent cfd473e commit 6fd7165
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Tests/Logic/CoreData/RKManagedObjectLoaderTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ - (void)testShouldSkipObjectMappingOnRequestCacheHitWhenObjectCachePresent {
[mockLoader send];
[responseLoader waitForResponse];

[mockLoader verify];
STAssertNoThrow([mockLoader verify], nil);
assertThatInteger([RKHuman count:nil], is(equalToInteger(2)));
assertThatBool([responseLoader wasSuccessful], is(equalToBool(YES)));
assertThatBool([responseLoader.response wasLoadedFromCache], is(equalToBool(NO)));
Expand All @@ -192,7 +192,7 @@ - (void)testShouldSkipObjectMappingOnRequestCacheHitWhenObjectCachePresent {
[mockLoader send];
[responseLoader waitForResponse];

[mockLoader verify];
STAssertNoThrow([mockLoader verify], nil);
assertThatInteger([RKHuman count:nil], is(equalToInteger(2)));
assertThatBool([responseLoader wasSuccessful], is(equalToBool(YES)));
assertThatBool([responseLoader.response wasLoadedFromCache], is(equalToBool(YES)));
Expand Down
8 changes: 6 additions & 2 deletions Tests/RunPlatformUnitTests
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ Main() {

if [ "${TEST_HOST}" != "" ]; then

#Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
export OTHER_TEST_FLAGS="-RegisterForSystemEvents"
export CFFIXED_USER_HOME="${BUILT_PRODUCTS_DIR}/UserHome/"
mkdir -p "${CFFIXED_USER_HOME}"
mkdir -p "${CFFIXED_USER_HOME}/Library/Caches"
mkdir "${CFFIXED_USER_HOME}/Library/Preferences"
mkdir "${CFFIXED_USER_HOME}/Documents"
export OTHER_TEST_FLAGS="${OTHER_TEST_FLAGS} -RegisterForSystemEvents"
RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"

else
Expand Down
18 changes: 0 additions & 18 deletions Tests/Server/lib/restkit/coredata/cache.rb

This file was deleted.

25 changes: 18 additions & 7 deletions Tests/Server/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require 'restkit/network/etags'
require 'restkit/network/timeout'
require 'restkit/network/oauth2'
require 'restkit/coredata/cache'

class Person < Struct.new(:name, :age)
def to_json(*args)
Expand All @@ -27,18 +26,18 @@ def to_json(*args)
end

class RestKitTestServer < Sinatra::Base
self.app_file = __FILE__
use RestKit::Network::Authentication
use RestKit::Network::ETags
use RestKit::Network::Timeout
use RestKit::Network::OAuth2
use RestKit::CoreData::Cache
self.app_file = __FILE__

configure do
enable :logging, :dump_errors
set :public_folder, Proc.new { File.expand_path(File.join(root, '../Fixtures')) }
set :uploads_path, Proc.new { File.expand_path(File.join(root, '../Fixtures/Uploads')) }
end

use RestKit::Network::Authentication
use RestKit::Network::ETags
use RestKit::Network::Timeout
use RestKit::Network::OAuth2

def render_fixture(path, options = {})
send_file File.join(settings.public_folder, path), options
Expand Down Expand Up @@ -234,6 +233,18 @@ def render_fixture(path, options = {})
{:per_page => per_page, :total_entries => total_entries,
:current_page => current_page, :entries => entries}.to_json
end

get '/coredata/etag' do
content_type 'application/json'
tag = '2cdd0a2b329541d81e82ab20aff6281b'
if tag == request.env["HTTP_IF_NONE_MATCH"]
status 304
""
else
etag(tag)
render_fixture '/JSON/humans/all.json'
end
end

# start the server if ruby file executed directly
run! if app_file == $0
Expand Down

0 comments on commit 6fd7165

Please sign in to comment.