Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Skip tests that depend on memcached if not running.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information
dougbarth authored and NZKoz committed Oct 17, 2008
1 parent 4b63c27 commit 47be090
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
12 changes: 11 additions & 1 deletion activesupport/test/abstract_unit.rb
Expand Up @@ -26,6 +26,16 @@ def uses_mocha(test_name, &block)
end
end

unless defined? uses_memcached
def uses_memcached(test_name)
require 'memcache'
MemCache.new('localhost').stats
yield
rescue MemCache::MemCacheError
$stderr.puts "Skipping #{test_name} tests. Start memcached and try again."
end
end

# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true

Expand All @@ -40,4 +50,4 @@ def with_kcode(code)
else
yield
end
end
end
36 changes: 19 additions & 17 deletions activesupport/test/caching_test.rb
Expand Up @@ -146,26 +146,28 @@ def test_store_objects_should_be_immutable
end
end

class MemCacheStoreTest < Test::Unit::TestCase
def setup
@cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
@cache.clear
end
uses_memcached 'memcached backed store' do
class MemCacheStoreTest < Test::Unit::TestCase
def setup
@cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
@cache.clear
end

include CacheStoreBehavior
include CacheStoreBehavior

def test_store_objects_should_be_immutable
@cache.write('foo', 'bar')
@cache.read('foo').gsub!(/.*/, 'baz')
assert_equal 'bar', @cache.read('foo')
def test_store_objects_should_be_immutable
@cache.write('foo', 'bar')
@cache.read('foo').gsub!(/.*/, 'baz')
assert_equal 'bar', @cache.read('foo')
end
end
end

class CompressedMemCacheStore < Test::Unit::TestCase
def setup
@cache = ActiveSupport::Cache.lookup_store(:compressed_mem_cache_store)
@cache.clear
end
class CompressedMemCacheStore < Test::Unit::TestCase
def setup
@cache = ActiveSupport::Cache.lookup_store(:compressed_mem_cache_store)
@cache.clear
end

include CacheStoreBehavior
include CacheStoreBehavior
end
end

0 comments on commit 47be090

Please sign in to comment.