mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Skip tests that depend on memcached if not running.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
This commit is contained in:
committed by
Michael Koziarski
parent
4b63c2700f
commit
47be090d37
@@ -26,6 +26,16 @@ unless defined? uses_mocha
|
||||
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
|
||||
|
||||
@@ -40,4 +50,4 @@ def with_kcode(code)
|
||||
else
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,26 +146,28 @@ class MemoryStoreTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class MemCacheStoreTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
||||
@cache.clear
|
||||
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
|
||||
|
||||
def test_store_objects_should_be_immutable
|
||||
@cache.write('foo', 'bar')
|
||||
@cache.read('foo').gsub!(/.*/, 'baz')
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
end
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
class CompressedMemCacheStore < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:compressed_mem_cache_store)
|
||||
@cache.clear
|
||||
end
|
||||
|
||||
def test_store_objects_should_be_immutable
|
||||
@cache.write('foo', 'bar')
|
||||
@cache.read('foo').gsub!(/.*/, 'baz')
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
include CacheStoreBehavior
|
||||
end
|
||||
end
|
||||
|
||||
class CompressedMemCacheStore < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:compressed_mem_cache_store)
|
||||
@cache.clear
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user