Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Skip tests that depend on memcached if not running.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit 47be090d37e803af502dc4cf97930184007c660d 1 parent 4b63c27
@dougbarth dougbarth authored NZKoz committed
View
12 activesupport/test/abstract_unit.rb
@@ -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
@@ -40,4 +50,4 @@ def with_kcode(code)
else
yield
end
-end
+end
View
36 activesupport/test/caching_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.