moneta 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +4 -0
- data/.travis.yml +83 -32
- data/.yardopts +6 -1
- data/CHANGES +30 -0
- data/CONTRIBUTORS +4 -0
- data/Gemfile +28 -36
- data/LICENSE +1 -1
- data/README.md +136 -67
- data/SPEC.md +70 -0
- data/feature_matrix.yaml +235 -0
- data/lib/active_support/cache/moneta_store.rb +102 -6
- data/lib/moneta.rb +9 -2
- data/lib/moneta/adapters/activerecord.rb +258 -98
- data/lib/moneta/adapters/activesupportcache.rb +133 -0
- data/lib/moneta/adapters/cassandra.rb +290 -44
- data/lib/moneta/adapters/client.rb +11 -2
- data/lib/moneta/adapters/couch.rb +179 -25
- data/lib/moneta/adapters/datamapper.rb +1 -0
- data/lib/moneta/adapters/daybreak.rb +21 -4
- data/lib/moneta/adapters/dbm.rb +7 -7
- data/lib/moneta/adapters/file.rb +11 -1
- data/lib/moneta/adapters/gdbm.rb +7 -7
- data/lib/moneta/adapters/kyotocabinet.rb +66 -1
- data/lib/moneta/adapters/leveldb.rb +27 -1
- data/lib/moneta/adapters/lmdb.rb +29 -1
- data/lib/moneta/adapters/lruhash.rb +30 -0
- data/lib/moneta/adapters/memcached/dalli.rb +50 -5
- data/lib/moneta/adapters/memcached/native.rb +11 -4
- data/lib/moneta/adapters/memory.rb +2 -0
- data/lib/moneta/adapters/mongo/base.rb +32 -7
- data/lib/moneta/adapters/mongo/moped.rb +59 -2
- data/lib/moneta/adapters/mongo/official.rb +40 -0
- data/lib/moneta/adapters/pstore.rb +56 -8
- data/lib/moneta/adapters/redis.rb +79 -19
- data/lib/moneta/adapters/sdbm.rb +7 -7
- data/lib/moneta/adapters/sequel.rb +440 -39
- data/lib/moneta/adapters/sqlite.rb +74 -10
- data/lib/moneta/adapters/tdb.rb +16 -1
- data/lib/moneta/adapters/tokyocabinet.rb +7 -1
- data/lib/moneta/adapters/tokyotyrant.rb +22 -0
- data/lib/moneta/cache.rb +11 -1
- data/lib/moneta/expires.rb +110 -8
- data/lib/moneta/lock.rb +21 -2
- data/lib/moneta/mixins.rb +279 -3
- data/lib/moneta/pool.rb +15 -6
- data/lib/moneta/proxy.rb +46 -2
- data/lib/moneta/server.rb +5 -1
- data/lib/moneta/shared.rb +27 -11
- data/lib/moneta/stack.rb +1 -1
- data/lib/moneta/synchronize.rb +2 -8
- data/lib/moneta/transformer.rb +152 -2
- data/lib/moneta/transformer/config.rb +2 -0
- data/lib/moneta/transformer/helper.rb +2 -2
- data/lib/moneta/version.rb +1 -1
- data/lib/moneta/weak_each_key.rb +74 -0
- data/lib/moneta/wrapper.rb +25 -0
- data/moneta.gemspec +2 -2
- data/script/benchmarks +174 -62
- data/script/parallel-tests +58 -83
- data/script/start-hbase +46 -0
- data/script/start-services +9 -2
- data/script/update-feature-matrix +148 -0
- data/spec/active_support/cache_moneta_store_spec.rb +132 -109
- data/spec/features/concurrent_create.rb +21 -0
- data/spec/features/concurrent_increment.rb +32 -0
- data/spec/features/create.rb +25 -0
- data/spec/features/create_expires.rb +19 -0
- data/spec/features/default_expires.rb +15 -0
- data/spec/features/each_key.rb +119 -0
- data/spec/features/expires.rb +291 -0
- data/spec/features/features.rb +16 -0
- data/spec/features/increment.rb +98 -0
- data/spec/features/marshallable_key.rb +43 -0
- data/spec/features/marshallable_value.rb +7 -0
- data/spec/features/multiprocess.rb +8 -0
- data/spec/features/not_create.rb +7 -0
- data/spec/features/not_each_key.rb +7 -0
- data/spec/features/not_increment.rb +13 -0
- data/spec/features/not_persist.rb +9 -0
- data/spec/features/null.rb +66 -0
- data/spec/features/persist.rb +14 -0
- data/spec/features/returndifferent.rb +9 -0
- data/spec/features/returnsame.rb +9 -0
- data/spec/features/store.rb +261 -0
- data/spec/features/store_large.rb +13 -0
- data/spec/features/transform_value.rb +44 -0
- data/spec/features/transform_value_expires.rb +41 -0
- data/spec/helper.rb +391 -74
- data/spec/moneta/adapters/activerecord/adapter_activerecord_existing_connection_spec.rb +59 -0
- data/spec/moneta/adapters/activerecord/adapter_activerecord_spec.rb +118 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_spec.rb +18 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_with_expires_spec.rb +24 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_spec.rb +51 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_with_default_expires_spec.rb +51 -0
- data/spec/moneta/adapters/cassandra/adapter_cassandra_spec.rb +17 -0
- data/spec/moneta/adapters/cassandra/adapter_cassandra_with_default_expires_spec.rb +18 -0
- data/spec/moneta/adapters/cassandra/helper.rb +18 -0
- data/spec/moneta/adapters/cassandra/standard_cassandra_spec.rb +18 -0
- data/spec/moneta/adapters/client/adapter_client_spec.rb +11 -0
- data/spec/moneta/adapters/client/standard_client_tcp_spec.rb +23 -0
- data/spec/moneta/adapters/client/standard_client_unix_spec.rb +12 -0
- data/spec/moneta/adapters/cookie/adapter_cookie_spec.rb +7 -0
- data/spec/moneta/adapters/couch/adapter_couch_spec.rb +7 -0
- data/spec/moneta/adapters/couch/standard_couch_spec.rb +9 -0
- data/spec/moneta/adapters/couch/standard_couch_with_expires_spec.rb +13 -0
- data/spec/moneta/adapters/datamapper/adapter_datamapper_spec.rb +43 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_spec.rb +21 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_expires_spec.rb +26 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_repository_spec.rb +22 -0
- data/spec/moneta/adapters/daybreak/adapter_daybreak_spec.rb +7 -0
- data/spec/moneta/adapters/daybreak/standard_daybreak_spec.rb +7 -0
- data/spec/moneta/adapters/daybreak/standard_daybreak_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/dbm/adapter_dbm_spec.rb +7 -0
- data/spec/moneta/adapters/dbm/standard_dbm_spec.rb +7 -0
- data/spec/moneta/adapters/dbm/standard_dbm_with_expires_spec.rb +12 -0
- data/spec/moneta/adapters/file/adapter_file_spec.rb +7 -0
- data/spec/moneta/adapters/file/standard_file_spec.rb +7 -0
- data/spec/moneta/adapters/file/standard_file_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/fog/adapter_fog_spec.rb +16 -0
- data/spec/moneta/adapters/fog/standard_fog_spec.rb +15 -0
- data/spec/moneta/adapters/fog/standard_fog_with_expires_spec.rb +20 -0
- data/spec/moneta/adapters/gdbm/adapter_gdbm_spec.rb +7 -0
- data/spec/moneta/adapters/gdbm/standard_gdbm_spec.rb +7 -0
- data/spec/moneta/adapters/gdbm/standard_gdbm_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/hashfile/standard_hashfile_spec.rb +7 -0
- data/spec/moneta/adapters/hashfile/standard_hashfile_with_expires_spec.rb +12 -0
- data/spec/moneta/adapters/hbase/adapter_hbase_spec.rb +7 -0
- data/spec/moneta/adapters/hbase/standard_hbase_spec.rb +4 -0
- data/spec/moneta/adapters/hbase/standard_hbase_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/kyotocabinet/adapter_kyotocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_with_expires_spec.rb +14 -0
- data/spec/moneta/adapters/leveldb/adapter_leveldb_spec.rb +7 -0
- data/spec/moneta/adapters/leveldb/standard_leveldb_spec.rb +7 -0
- data/spec/moneta/adapters/leveldb/standard_leveldb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/lmdb/adapter_lmdb_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/adapter_lmdb_with_db_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/standard_lmdb_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/standard_lmdb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/localmemcache/adapter_localmemcache_spec.rb +7 -0
- data/spec/moneta/adapters/localmemcache/standard_localmemcache_spec.rb +7 -0
- data/spec/moneta/adapters/localmemcache/standard_localmemcache_with_expires_spec.rb +11 -0
- data/spec/moneta/{adapter_lruhash_spec.rb → adapters/lruhash/adapter_lruhash_spec.rb} +3 -25
- data/spec/moneta/adapters/lruhash/standard_lruhash_spec.rb +4 -0
- data/spec/moneta/adapters/lruhash/standard_lruhash_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/memcached/adapter_memcached_spec.rb +13 -0
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_with_default_expires_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/dalli/standard_memcached_dalli_spec.rb +11 -0
- data/spec/moneta/adapters/memcached/helper.rb +20 -0
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_with_default_expires_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/native/standard_memcached_native_spec.rb +11 -0
- data/spec/moneta/adapters/memcached/standard_memcached_spec.rb +17 -0
- data/spec/moneta/adapters/memory/adapter_memory_spec.rb +7 -0
- data/spec/moneta/adapters/memory/standard_memory_spec.rb +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_compress_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_key_serializer_spec.rb +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_serializer_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_value_serializer_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_prefix_spec.rb +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_snappy_compress_spec.rb +9 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_spec.rb +25 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_official_spec.rb +25 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_official_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_spec.rb +11 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/standard_mongo_moped_spec.rb +7 -0
- data/spec/moneta/adapters/mongo/standard_mongo_official_spec.rb +7 -0
- data/spec/moneta/adapters/mongo/standard_mongo_spec.rb +7 -0
- data/spec/moneta/adapters/null/null_adapter_spec.rb +7 -0
- data/spec/moneta/adapters/null/standard_null_spec.rb +4 -0
- data/spec/moneta/adapters/pstore/adapter_pstore_spec.rb +7 -0
- data/spec/moneta/adapters/pstore/standard_pstore_spec.rb +9 -0
- data/spec/moneta/adapters/pstore/standard_pstore_with_expires_spec.rb +13 -0
- data/spec/moneta/adapters/redis/adapter_redis_spec.rb +10 -0
- data/spec/moneta/adapters/redis/adapter_redis_with_default_expires_spec.rb +10 -0
- data/spec/moneta/adapters/redis/standard_redis_spec.rb +7 -0
- data/spec/moneta/adapters/restclient/adapter_restclient_spec.rb +11 -0
- data/spec/moneta/adapters/restclient/standard_restclient_spec.rb +10 -0
- data/spec/moneta/adapters/riak/adapter_riak_spec.rb +14 -0
- data/spec/moneta/adapters/riak/standard_riak_spec.rb +10 -0
- data/spec/moneta/adapters/riak/standard_riak_with_expires_spec.rb +10 -0
- data/spec/moneta/adapters/sdbm/adapter_sdbm_spec.rb +7 -0
- data/spec/moneta/adapters/sdbm/standard_sdbm_spec.rb +7 -0
- data/spec/moneta/adapters/sdbm/standard_sdbm_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/sequel/adapter_sequel_spec.rb +181 -0
- data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +14 -0
- data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +19 -0
- data/spec/moneta/adapters/sqlite/adapter_sqlite_spec.rb +7 -0
- data/spec/moneta/adapters/sqlite/standard_sqlite_spec.rb +7 -0
- data/spec/moneta/adapters/sqlite/standard_sqlite_with_expires_spec.rb +15 -0
- data/spec/moneta/adapters/tdb/adapter_tdb_spec.rb +7 -0
- data/spec/moneta/adapters/tdb/standard_tdb_spec.rb +7 -0
- data/spec/moneta/adapters/tdb/standard_tdb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/tokyocabinet/adapter_tokyocabinet_bdb_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/adapter_tokyocabinet_hdb_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/tokyotyrant/adapter_tokyotyrant_spec.rb +7 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_spec.rb +4 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/yaml/adapter_yaml_spec.rb +7 -0
- data/spec/moneta/adapters/yaml/standard_yaml_spec.rb +9 -0
- data/spec/moneta/adapters/yaml/standard_yaml_with_expires_spec.rb +13 -0
- data/spec/moneta/builder_spec.rb +0 -1
- data/spec/moneta/mutex_spec.rb +6 -23
- data/spec/moneta/proxies/cache/cache_file_memory_spec.rb +24 -0
- data/spec/moneta/proxies/cache/cache_memory_null_spec.rb +12 -0
- data/spec/moneta/proxies/expires/expires_file_spec.rb +28 -0
- data/spec/moneta/proxies/expires/expires_memory_spec.rb +15 -0
- data/spec/moneta/proxies/expires/expires_memory_with_default_expires_spec.rb +16 -0
- data/spec/moneta/proxies/lock/lock_spec.rb +10 -0
- data/spec/moneta/{optionmerger_spec.rb → proxies/optionmerger/optionmerger_spec.rb} +2 -18
- data/spec/moneta/proxies/pool/pool_spec.rb +12 -0
- data/spec/moneta/proxies/proxy/proxy_expires_memory_spec.rb +16 -0
- data/spec/moneta/proxies/proxy/proxy_redis_spec.rb +13 -0
- data/spec/moneta/proxies/shared/shared_tcp_spec.rb +49 -0
- data/spec/moneta/proxies/shared/shared_unix_spec.rb +48 -0
- data/spec/moneta/proxies/transformer/transformer_bencode_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_bert_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_bson_spec.rb +23 -0
- data/spec/moneta/proxies/transformer/transformer_bzip2_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_json_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_key_inspect_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_marshal_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_to_s_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_yaml_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_lz4_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_lzma_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_lzo_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_base64_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city128_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city32_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city64_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_escape_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_hex_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_hmac_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_md5_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_md5_spread_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_prefix_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_qp_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_rmd160_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha1_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha256_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha384_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha512_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_truncate_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_urlsafe_base64_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_uuencode_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_msgpack_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_ox_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_php_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_quicklz_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_snappy_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_tnet_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_value_marshal_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_value_yaml_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_yaml_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_zlib_spec.rb +19 -0
- data/spec/moneta/proxies/weak_create/weak_create_spec.rb +21 -0
- data/spec/moneta/proxies/weak_each_key/weak_each_key_spec.rb +24 -0
- data/spec/moneta/proxies/weak_increment/weak_increment_spec.rb +21 -0
- data/spec/moneta/semaphore_spec.rb +6 -23
- data/spec/moneta/stack_file_memory_spec.rb +5 -29
- data/spec/moneta/stack_memory_file_spec.rb +5 -31
- data/spec/quality_spec.rb +1 -1
- data/{spec → test}/action_dispatch/fixtures/session_autoload_test/foo.rb +0 -0
- data/{spec/action_dispatch/session_moneta_store_spec.rb → test/action_dispatch/session_moneta_store_test.rb} +13 -5
- metadata +415 -355
- data/script/generate-specs +0 -2696
- data/spec/moneta/adapter_activerecord_exisiting_connection_spec.rb +0 -36
- data/spec/moneta/adapter_activerecord_spec.rb +0 -65
- data/spec/moneta/adapter_cassandra_spec.rb +0 -33
- data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +0 -34
- data/spec/moneta/adapter_client_spec.rb +0 -35
- data/spec/moneta/adapter_cookie_spec.rb +0 -30
- data/spec/moneta/adapter_couch_spec.rb +0 -36
- data/spec/moneta/adapter_datamapper_spec.rb +0 -64
- data/spec/moneta/adapter_daybreak_spec.rb +0 -31
- data/spec/moneta/adapter_dbm_spec.rb +0 -31
- data/spec/moneta/adapter_file_spec.rb +0 -34
- data/spec/moneta/adapter_fog_spec.rb +0 -37
- data/spec/moneta/adapter_gdbm_spec.rb +0 -31
- data/spec/moneta/adapter_hbase_spec.rb +0 -33
- data/spec/moneta/adapter_kyotocabinet_spec.rb +0 -31
- data/spec/moneta/adapter_leveldb_spec.rb +0 -31
- data/spec/moneta/adapter_lmdb_spec.rb +0 -32
- data/spec/moneta/adapter_lmdb_with_db_spec.rb +0 -32
- data/spec/moneta/adapter_localmemcache_spec.rb +0 -32
- data/spec/moneta/adapter_memcached_dalli_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memcached_native_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memcached_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memory_spec.rb +0 -184
- data/spec/moneta/adapter_mongo_moped_spec.rb +0 -64
- data/spec/moneta/adapter_mongo_moped_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_mongo_official_spec.rb +0 -64
- data/spec/moneta/adapter_mongo_official_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_mongo_spec.rb +0 -51
- data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_pstore_spec.rb +0 -250
- data/spec/moneta/adapter_redis_spec.rb +0 -36
- data/spec/moneta/adapter_redis_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_restclient_spec.rb +0 -33
- data/spec/moneta/adapter_riak_spec.rb +0 -36
- data/spec/moneta/adapter_sdbm_spec.rb +0 -30
- data/spec/moneta/adapter_sequel_spec.rb +0 -34
- data/spec/moneta/adapter_sqlite_spec.rb +0 -32
- data/spec/moneta/adapter_tdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyotyrant_spec.rb +0 -34
- data/spec/moneta/adapter_yaml_spec.rb +0 -57
- data/spec/moneta/cache_file_memory_spec.rb +0 -50
- data/spec/moneta/cache_memory_null_spec.rb +0 -35
- data/spec/moneta/expires_file_spec.rb +0 -78
- data/spec/moneta/expires_memory_spec.rb +0 -189
- data/spec/moneta/expires_memory_with_default_expires_spec.rb +0 -190
- data/spec/moneta/lock_spec.rb +0 -187
- data/spec/moneta/null_adapter_spec.rb +0 -86
- data/spec/moneta/pool_spec.rb +0 -38
- data/spec/moneta/proxy_expires_memory_spec.rb +0 -191
- data/spec/moneta/proxy_redis_spec.rb +0 -40
- data/spec/moneta/shared_tcp_spec.rb +0 -46
- data/spec/moneta/shared_unix_spec.rb +0 -46
- data/spec/moneta/standard_activerecord_spec.rb +0 -253
- data/spec/moneta/standard_activerecord_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_cassandra_spec.rb +0 -252
- data/spec/moneta/standard_client_tcp_spec.rb +0 -269
- data/spec/moneta/standard_client_unix_spec.rb +0 -254
- data/spec/moneta/standard_couch_spec.rb +0 -252
- data/spec/moneta/standard_couch_with_expires_spec.rb +0 -254
- data/spec/moneta/standard_datamapper_spec.rb +0 -254
- data/spec/moneta/standard_datamapper_with_expires_spec.rb +0 -256
- data/spec/moneta/standard_datamapper_with_repository_spec.rb +0 -254
- data/spec/moneta/standard_daybreak_spec.rb +0 -250
- data/spec/moneta/standard_daybreak_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_dbm_spec.rb +0 -250
- data/spec/moneta/standard_dbm_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_file_spec.rb +0 -253
- data/spec/moneta/standard_file_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_fog_spec.rb +0 -256
- data/spec/moneta/standard_fog_with_expires_spec.rb +0 -258
- data/spec/moneta/standard_gdbm_spec.rb +0 -250
- data/spec/moneta/standard_gdbm_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_hashfile_spec.rb +0 -253
- data/spec/moneta/standard_hashfile_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_hbase_spec.rb +0 -252
- data/spec/moneta/standard_hbase_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_kyotocabinet_spec.rb +0 -250
- data/spec/moneta/standard_kyotocabinet_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_leveldb_spec.rb +0 -250
- data/spec/moneta/standard_leveldb_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_lmdb_spec.rb +0 -251
- data/spec/moneta/standard_lmdb_with_expires_spec.rb +0 -253
- data/spec/moneta/standard_localmemcache_spec.rb +0 -251
- data/spec/moneta/standard_localmemcache_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_lruhash_spec.rb +0 -187
- data/spec/moneta/standard_lruhash_with_expires_spec.rb +0 -189
- data/spec/moneta/standard_memcached_dalli_spec.rb +0 -255
- data/spec/moneta/standard_memcached_native_spec.rb +0 -255
- data/spec/moneta/standard_memcached_spec.rb +0 -255
- data/spec/moneta/standard_memory_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_compress_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_expires_spec.rb +0 -189
- data/spec/moneta/standard_memory_with_json_key_serializer_spec.rb +0 -86
- data/spec/moneta/standard_memory_with_json_serializer_spec.rb +0 -49
- data/spec/moneta/standard_memory_with_json_value_serializer_spec.rb +0 -90
- data/spec/moneta/standard_memory_with_prefix_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_snappy_compress_spec.rb +0 -187
- data/spec/moneta/standard_mongo_moped_spec.rb +0 -255
- data/spec/moneta/standard_mongo_official_spec.rb +0 -255
- data/spec/moneta/standard_mongo_spec.rb +0 -255
- data/spec/moneta/standard_null_spec.rb +0 -120
- data/spec/moneta/standard_pstore_spec.rb +0 -253
- data/spec/moneta/standard_pstore_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_redis_spec.rb +0 -255
- data/spec/moneta/standard_restclient_spec.rb +0 -252
- data/spec/moneta/standard_riak_spec.rb +0 -255
- data/spec/moneta/standard_riak_with_expires_spec.rb +0 -256
- data/spec/moneta/standard_sdbm_spec.rb +0 -249
- data/spec/moneta/standard_sdbm_with_expires_spec.rb +0 -251
- data/spec/moneta/standard_sequel_spec.rb +0 -253
- data/spec/moneta/standard_sequel_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_sqlite_spec.rb +0 -251
- data/spec/moneta/standard_sqlite_with_expires_spec.rb +0 -253
- data/spec/moneta/standard_tdb_spec.rb +0 -250
- data/spec/moneta/standard_tdb_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_tokyocabinet_spec.rb +0 -250
- data/spec/moneta/standard_tokyocabinet_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_tokyotyrant_spec.rb +0 -253
- data/spec/moneta/standard_tokyotyrant_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_yaml_spec.rb +0 -250
- data/spec/moneta/standard_yaml_with_expires_spec.rb +0 -252
- data/spec/moneta/transformer_bencode_spec.rb +0 -55
- data/spec/moneta/transformer_bert_spec.rb +0 -55
- data/spec/moneta/transformer_bson_spec.rb +0 -60
- data/spec/moneta/transformer_bzip2_spec.rb +0 -55
- data/spec/moneta/transformer_json_spec.rb +0 -55
- data/spec/moneta/transformer_key_inspect_spec.rb +0 -91
- data/spec/moneta/transformer_key_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_key_to_s_spec.rb +0 -91
- data/spec/moneta/transformer_key_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_lz4_spec.rb +0 -55
- data/spec/moneta/transformer_lzma_spec.rb +0 -55
- data/spec/moneta/transformer_lzo_spec.rb +0 -55
- data/spec/moneta/transformer_marshal_base64_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city128_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city32_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city64_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_escape_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_hex_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_hmac_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_md5_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_md5_spread_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_prefix_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_qp_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_rmd160_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha1_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha256_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha384_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha512_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_marshal_truncate_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_uuencode_spec.rb +0 -194
- data/spec/moneta/transformer_msgpack_spec.rb +0 -55
- data/spec/moneta/transformer_ox_spec.rb +0 -191
- data/spec/moneta/transformer_php_spec.rb +0 -55
- data/spec/moneta/transformer_quicklz_spec.rb +0 -55
- data/spec/moneta/transformer_snappy_spec.rb +0 -55
- data/spec/moneta/transformer_tnet_spec.rb +0 -55
- data/spec/moneta/transformer_value_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_value_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_zlib_spec.rb +0 -55
- data/spec/moneta/weak_create_spec.rb +0 -41
- data/spec/moneta/weak_increment_spec.rb +0 -41
- data/spec/monetaspecs.rb +0 -51267
data/script/generate-specs
DELETED
@@ -1,2696 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
PATH = File.expand_path(File.join(__FILE__, '..', '..', 'spec'))
|
5
|
-
|
6
|
-
class Specs
|
7
|
-
attr_reader :key, :value, :specs, :features
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@specs = options.delete(:specs).to_a
|
11
|
-
@key = options.delete(:key) || %w(object string binary hash boolean nil integer number)
|
12
|
-
@value = options.delete(:value) || %w(object string binary hash boolean nil integer number)
|
13
|
-
@features = []
|
14
|
-
[:expires, :expires_native, :increment, :create].each do |feature|
|
15
|
-
@features << feature if @specs.include?(feature)
|
16
|
-
end
|
17
|
-
@features.sort_by!(&:to_s)
|
18
|
-
@features.uniq!
|
19
|
-
end
|
20
|
-
|
21
|
-
def new(options)
|
22
|
-
Specs.new({specs: specs, key: key, value: value}.merge(options))
|
23
|
-
end
|
24
|
-
|
25
|
-
def without_path
|
26
|
-
new(key: key - %w(path))
|
27
|
-
end
|
28
|
-
|
29
|
-
def stringvalues_only
|
30
|
-
new(value: %w(string))
|
31
|
-
end
|
32
|
-
|
33
|
-
def simplekeys_only
|
34
|
-
new(key: %w(string hash integer))
|
35
|
-
end
|
36
|
-
|
37
|
-
def simplevalues_only
|
38
|
-
new(value: %w(string hash integer))
|
39
|
-
end
|
40
|
-
|
41
|
-
def without_increment
|
42
|
-
new(specs: specs - [:increment, :concurrent_increment] + [:not_increment])
|
43
|
-
end
|
44
|
-
|
45
|
-
def without_large
|
46
|
-
new(specs: specs - [:store_large])
|
47
|
-
end
|
48
|
-
|
49
|
-
def without_concurrent
|
50
|
-
new(specs: specs - [:concurrent_increment, :concurrent_create])
|
51
|
-
end
|
52
|
-
|
53
|
-
def without_persist
|
54
|
-
new(specs: specs - [:persist, :multiprocess, :concurrent_increment, :concurrent_create] + [:not_persist])
|
55
|
-
end
|
56
|
-
|
57
|
-
def without_multiprocess
|
58
|
-
new(specs: specs - [:multiprocess, :concurrent_increment, :concurrent_create])
|
59
|
-
end
|
60
|
-
|
61
|
-
def with_expires
|
62
|
-
a = specs.dup
|
63
|
-
if a.include?(:transform_value)
|
64
|
-
a.delete(:transform_value)
|
65
|
-
a << :transform_value_expires
|
66
|
-
end
|
67
|
-
a << :create_expires if a.include?(:create)
|
68
|
-
a << :expires
|
69
|
-
new(specs: a)
|
70
|
-
end
|
71
|
-
|
72
|
-
def with_native_expires
|
73
|
-
a = specs.dup
|
74
|
-
a << :create_expires if a.include?(:create)
|
75
|
-
new(specs: a + [:expires])
|
76
|
-
end
|
77
|
-
|
78
|
-
def without_marshallable
|
79
|
-
new(specs: specs - [:marshallable_value, :marshallable_key])
|
80
|
-
end
|
81
|
-
|
82
|
-
def without_transform
|
83
|
-
new(specs: specs - [:marshallable_value, :marshallable_key, :transform_value])
|
84
|
-
end
|
85
|
-
|
86
|
-
def returnsame
|
87
|
-
new(specs: specs - [:returndifferent] + [:returnsame])
|
88
|
-
end
|
89
|
-
|
90
|
-
def without_marshallable_key
|
91
|
-
new(specs: specs - [:marshallable_key])
|
92
|
-
end
|
93
|
-
|
94
|
-
def without_marshallable_value
|
95
|
-
new(specs: specs - [:marshallable_value])
|
96
|
-
end
|
97
|
-
|
98
|
-
def without_store
|
99
|
-
new(specs: specs - [:store, :store_large, :transform_value, :marshallable_value])
|
100
|
-
end
|
101
|
-
|
102
|
-
def with_default_expires
|
103
|
-
new(specs: specs + [:default_expires])
|
104
|
-
end
|
105
|
-
|
106
|
-
def without_create
|
107
|
-
new(specs: specs - [:create, :concurrent_create, :create_expires] + [:not_create])
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
ADAPTER_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :increment, :concurrent_increment, :concurrent_create, :persist, :multiprocess, :create, :features, :store_large], key: %w(string path), value: %w(string path))
|
112
|
-
STANDARD_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :marshallable_key, :marshallable_value, :transform_value, :increment, :concurrent_increment, :concurrent_create, :persist, :multiprocess, :create, :features, :store_large])
|
113
|
-
TRANSFORMER_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :transform_value, :increment, :create, :features, :store_large])
|
114
|
-
|
115
|
-
header = "# coding: binary\n# Generated by #{File.basename(__FILE__)}\n"
|
116
|
-
|
117
|
-
TESTS = {
|
118
|
-
'standard_client_tcp' => {
|
119
|
-
preamble: "start_server(Moneta::Adapters::Memory.new)\n",
|
120
|
-
store: :Client,
|
121
|
-
specs: STANDARD_SPECS,
|
122
|
-
tests: %{
|
123
|
-
it 'supports multiple clients' do
|
124
|
-
client = Moneta.new(:Client)
|
125
|
-
client['shared_key'] = 'shared_val'
|
126
|
-
(1..100).each do |i|
|
127
|
-
Thread.new do
|
128
|
-
client = Moneta.new(:Client)
|
129
|
-
(1.100).each do |j|
|
130
|
-
client['shared_key'].should == 'shared_val'
|
131
|
-
client["key-\#{j}-\#{i}"] = "val-\#{j}-\#{i}"
|
132
|
-
client["key-\#{j}-\#{i}"].should == "val-\#{j}-\#{i}"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
}
|
138
|
-
},
|
139
|
-
'standard_client_unix' => {
|
140
|
-
preamble: "start_server(Moneta::Adapters::Memory.new, socket: File.join(make_tempdir, 'standard_client_unix'))\n",
|
141
|
-
store: :Client,
|
142
|
-
options: "socket: File.join(make_tempdir, 'standard_client_unix')",
|
143
|
-
specs: STANDARD_SPECS
|
144
|
-
},
|
145
|
-
'standard_restclient' => {
|
146
|
-
preamble: "start_restserver\n",
|
147
|
-
store: :RestClient,
|
148
|
-
options: "url: 'http://localhost:8808/moneta/'",
|
149
|
-
specs: STANDARD_SPECS.without_increment.without_create
|
150
|
-
},
|
151
|
-
'standard_memory' => {
|
152
|
-
store: :Memory,
|
153
|
-
specs: STANDARD_SPECS.without_persist
|
154
|
-
},
|
155
|
-
'standard_memory_with_expires' => {
|
156
|
-
store: :Memory,
|
157
|
-
options: 'expires: true',
|
158
|
-
specs: STANDARD_SPECS.with_expires.without_persist
|
159
|
-
},
|
160
|
-
'standard_memory_with_compress' => {
|
161
|
-
store: :Memory,
|
162
|
-
options: 'compress: true',
|
163
|
-
load_value: 'Marshal.load(::Zlib::Inflate.inflate(value))',
|
164
|
-
specs: STANDARD_SPECS.without_persist
|
165
|
-
},
|
166
|
-
'standard_memory_with_prefix' => {
|
167
|
-
store: :Memory,
|
168
|
-
options: 'prefix: "moneta"',
|
169
|
-
specs: STANDARD_SPECS.without_persist
|
170
|
-
},
|
171
|
-
'standard_memory_with_json_serializer' => {
|
172
|
-
store: :Memory,
|
173
|
-
options: 'serializer: :json',
|
174
|
-
load_value: '::MultiJson.load(value)',
|
175
|
-
specs: STANDARD_SPECS.without_marshallable.simplekeys_only.simplevalues_only.without_persist
|
176
|
-
},
|
177
|
-
'standard_memory_with_json_key_serializer' => {
|
178
|
-
store: :Memory,
|
179
|
-
options: 'key_serializer: :json',
|
180
|
-
specs: STANDARD_SPECS.without_marshallable_key.simplekeys_only.without_persist,
|
181
|
-
},
|
182
|
-
'standard_memory_with_json_value_serializer' => {
|
183
|
-
store: :Memory,
|
184
|
-
options: 'value_serializer: :json',
|
185
|
-
specs: STANDARD_SPECS.without_marshallable_value.simplevalues_only.without_persist,
|
186
|
-
load_value: '::MultiJson.load(value)'
|
187
|
-
},
|
188
|
-
'standard_memory_with_snappy_compress' => {
|
189
|
-
store: :Memory,
|
190
|
-
options: 'compress: :snappy',
|
191
|
-
load_value: 'Marshal.load(::Snappy.inflate(value))',
|
192
|
-
specs: STANDARD_SPECS.without_persist
|
193
|
-
},
|
194
|
-
'standard_lruhash' => {
|
195
|
-
store: :LRUHash,
|
196
|
-
specs: STANDARD_SPECS.without_persist
|
197
|
-
},
|
198
|
-
'standard_lruhash_with_expires' => {
|
199
|
-
store: :LRUHash,
|
200
|
-
options: 'expires: true',
|
201
|
-
specs: STANDARD_SPECS.with_expires.without_persist,
|
202
|
-
},
|
203
|
-
'standard_file' => {
|
204
|
-
store: :File,
|
205
|
-
options: 'dir: File.join(make_tempdir, "simple_file")',
|
206
|
-
specs: STANDARD_SPECS
|
207
|
-
},
|
208
|
-
'standard_file_with_expires' => {
|
209
|
-
store: :File,
|
210
|
-
options: 'dir: File.join(make_tempdir, "simple_file_with_expires"), expires: true',
|
211
|
-
specs: STANDARD_SPECS.with_expires
|
212
|
-
},
|
213
|
-
'standard_hashfile' => {
|
214
|
-
store: :HashFile,
|
215
|
-
options: 'dir: File.join(make_tempdir, "simple_hashfile")',
|
216
|
-
specs: STANDARD_SPECS
|
217
|
-
},
|
218
|
-
'standard_hashfile_with_expires' => {
|
219
|
-
store: :HashFile,
|
220
|
-
options: 'dir: File.join(make_tempdir, "simple_hashfile_with_expires"), expires: true',
|
221
|
-
specs: STANDARD_SPECS.with_expires
|
222
|
-
},
|
223
|
-
'standard_cassandra' => {
|
224
|
-
store: :Cassandra,
|
225
|
-
options: 'keyspace: "simple_cassandra"',
|
226
|
-
specs: STANDARD_SPECS.without_increment.without_create.with_native_expires,
|
227
|
-
},
|
228
|
-
'standard_hbase' => {
|
229
|
-
store: :HBase,
|
230
|
-
options: 'table: "simple_hbase"',
|
231
|
-
specs: STANDARD_SPECS.without_create
|
232
|
-
},
|
233
|
-
'standard_hbase_with_expires' => {
|
234
|
-
store: :HBase,
|
235
|
-
options: 'table: "simple_hbase", expires: true',
|
236
|
-
specs: STANDARD_SPECS.with_expires,
|
237
|
-
},
|
238
|
-
'standard_dbm' => {
|
239
|
-
store: :DBM,
|
240
|
-
options: 'file: File.join(make_tempdir, "simple_dbm")',
|
241
|
-
specs: STANDARD_SPECS.without_multiprocess
|
242
|
-
},
|
243
|
-
'standard_dbm_with_expires' => {
|
244
|
-
store: :DBM,
|
245
|
-
options: 'file: File.join(make_tempdir, "simple_dbm_with_expires"), expires: true',
|
246
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
247
|
-
},
|
248
|
-
'standard_tdb' => {
|
249
|
-
store: :TDB,
|
250
|
-
options: 'file: File.join(make_tempdir, "simple_tdb")',
|
251
|
-
specs: STANDARD_SPECS.without_multiprocess
|
252
|
-
},
|
253
|
-
'standard_tdb_with_expires' => {
|
254
|
-
store: :TDB,
|
255
|
-
options: 'file: File.join(make_tempdir, "simple_tdb_with_expires"), expires: true',
|
256
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
257
|
-
},
|
258
|
-
'standard_daybreak' => {
|
259
|
-
store: :Daybreak,
|
260
|
-
options: 'file: File.join(make_tempdir, "simple_daybreak")',
|
261
|
-
specs: STANDARD_SPECS.without_multiprocess
|
262
|
-
},
|
263
|
-
'standard_daybreak_with_expires' => {
|
264
|
-
store: :Daybreak,
|
265
|
-
options: 'file: File.join(make_tempdir, "simple_daybreak_with_expires"), expires: true',
|
266
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
267
|
-
},
|
268
|
-
'standard_gdbm' => {
|
269
|
-
store: :GDBM,
|
270
|
-
options: 'file: File.join(make_tempdir, "simple_gdbm")',
|
271
|
-
specs: STANDARD_SPECS.without_multiprocess
|
272
|
-
},
|
273
|
-
'standard_gdbm_with_expires' => {
|
274
|
-
store: :GDBM,
|
275
|
-
options: 'file: File.join(make_tempdir, "simple_gdbm_with_expires"), expires: true',
|
276
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
277
|
-
},
|
278
|
-
'standard_sdbm' => {
|
279
|
-
store: :SDBM,
|
280
|
-
options: 'file: File.join(make_tempdir, "simple_sdbm")',
|
281
|
-
specs: STANDARD_SPECS.without_multiprocess.without_large
|
282
|
-
},
|
283
|
-
'standard_sdbm_with_expires' => {
|
284
|
-
store: :SDBM,
|
285
|
-
options: 'file: File.join(make_tempdir, "simple_sdbm_with_expires"), expires: true',
|
286
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires.without_large
|
287
|
-
},
|
288
|
-
'standard_leveldb' => {
|
289
|
-
store: :LevelDB,
|
290
|
-
options: 'dir: File.join(make_tempdir, "simple_leveldb")',
|
291
|
-
specs: STANDARD_SPECS.without_multiprocess
|
292
|
-
},
|
293
|
-
'standard_leveldb_with_expires' => {
|
294
|
-
store: :LevelDB,
|
295
|
-
options: 'dir: File.join(make_tempdir, "simple_leveldb_with_expires"), expires: true',
|
296
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
297
|
-
},
|
298
|
-
'standard_lmdb' => {
|
299
|
-
store: :LMDB,
|
300
|
-
options: 'dir: File.join(make_tempdir, "simple_lmdb")',
|
301
|
-
specs: STANDARD_SPECS.without_concurrent
|
302
|
-
},
|
303
|
-
'standard_lmdb_with_expires' => {
|
304
|
-
store: :LMDB,
|
305
|
-
options: 'dir: File.join(make_tempdir, "simple_lmdb_with_expires"), expires: true',
|
306
|
-
specs: STANDARD_SPECS.without_concurrent.with_expires
|
307
|
-
},
|
308
|
-
'standard_pstore' => {
|
309
|
-
store: :PStore,
|
310
|
-
options: 'file: File.join(make_tempdir, "simple_pstore")',
|
311
|
-
load_value: 'value',
|
312
|
-
specs: STANDARD_SPECS
|
313
|
-
},
|
314
|
-
'standard_pstore_with_expires' => {
|
315
|
-
store: :PStore,
|
316
|
-
options: 'file: File.join(make_tempdir, "simple_pstore_with_expires"), expires: true',
|
317
|
-
load_value: 'value',
|
318
|
-
specs: STANDARD_SPECS.with_expires
|
319
|
-
},
|
320
|
-
'standard_yaml' => {
|
321
|
-
store: :YAML,
|
322
|
-
options: 'file: File.join(make_tempdir, "simple_yaml")',
|
323
|
-
specs: STANDARD_SPECS.without_marshallable_value.without_concurrent,
|
324
|
-
load_value: 'value'
|
325
|
-
},
|
326
|
-
'standard_yaml_with_expires' => {
|
327
|
-
store: :YAML,
|
328
|
-
options: 'file: File.join(make_tempdir, "simple_yaml_with_expires"), expires: true',
|
329
|
-
specs: STANDARD_SPECS.without_marshallable_value.with_expires.without_concurrent,
|
330
|
-
load_value: 'value'
|
331
|
-
},
|
332
|
-
'standard_localmemcache' => {
|
333
|
-
store: :LocalMemCache,
|
334
|
-
options: 'file: File.join(make_tempdir, "simple_localmemcache")',
|
335
|
-
specs: STANDARD_SPECS.without_increment.without_create
|
336
|
-
},
|
337
|
-
'standard_localmemcache_with_expires' => {
|
338
|
-
store: :LocalMemCache,
|
339
|
-
options: 'file: File.join(make_tempdir, "simple_localmemcache_with_expires"), expires: true',
|
340
|
-
specs: STANDARD_SPECS.without_increment.without_create.with_expires
|
341
|
-
},
|
342
|
-
'standard_tokyocabinet' => {
|
343
|
-
store: :TokyoCabinet,
|
344
|
-
options: 'file: File.join(make_tempdir, "simple_tokyocabinet")',
|
345
|
-
specs: STANDARD_SPECS.without_multiprocess
|
346
|
-
},
|
347
|
-
'standard_tokyocabinet_with_expires' => {
|
348
|
-
store: :TokyoCabinet,
|
349
|
-
options: 'file: File.join(make_tempdir, "simple_tokyocabinet_with_expires"), expires: true',
|
350
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
351
|
-
},
|
352
|
-
'standard_tokyotyrant' => {
|
353
|
-
store: :TokyoTyrant,
|
354
|
-
specs: STANDARD_SPECS
|
355
|
-
},
|
356
|
-
'standard_tokyotyrant_with_expires' => {
|
357
|
-
store: :TokyoTyrant,
|
358
|
-
options: 'expires: true',
|
359
|
-
specs: STANDARD_SPECS.with_expires
|
360
|
-
},
|
361
|
-
'standard_kyotocabinet' => {
|
362
|
-
store: :KyotoCabinet,
|
363
|
-
options: 'file: File.join(make_tempdir, "simple_kyotocabinet.kch")',
|
364
|
-
specs: STANDARD_SPECS.without_multiprocess
|
365
|
-
},
|
366
|
-
'standard_kyotocabinet_with_expires' => {
|
367
|
-
store: :KyotoCabinet,
|
368
|
-
options: 'file: File.join(make_tempdir, "simple_kyotocabinet_with_expires.kch"), expires: true',
|
369
|
-
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
370
|
-
},
|
371
|
-
'standard_sqlite' => {
|
372
|
-
store: :Sqlite,
|
373
|
-
options: 'file: File.join(make_tempdir, "simple_sqlite")',
|
374
|
-
specs: STANDARD_SPECS.without_concurrent
|
375
|
-
},
|
376
|
-
'standard_sqlite_with_expires' => {
|
377
|
-
store: :Sqlite,
|
378
|
-
options: 'file: File.join(make_tempdir, "simple_sqlite_with_expires"), expires: true',
|
379
|
-
specs: STANDARD_SPECS.with_expires.without_concurrent
|
380
|
-
},
|
381
|
-
'standard_redis' => {
|
382
|
-
store: :Redis,
|
383
|
-
specs: STANDARD_SPECS.with_native_expires,
|
384
|
-
},
|
385
|
-
'standard_memcached' => {
|
386
|
-
store: :Memcached,
|
387
|
-
specs: STANDARD_SPECS.with_native_expires,
|
388
|
-
options: 'namespace: "simple_memcached"'
|
389
|
-
},
|
390
|
-
'standard_memcached_dalli' => {
|
391
|
-
store: :MemcachedDalli,
|
392
|
-
specs: STANDARD_SPECS.with_native_expires,
|
393
|
-
options: 'namespace: "simple_memcached_dalli"'
|
394
|
-
},
|
395
|
-
'standard_memcached_native' => {
|
396
|
-
store: :MemcachedNative,
|
397
|
-
specs: STANDARD_SPECS.with_native_expires,
|
398
|
-
options: 'namespace: "simple_memcached_native"'
|
399
|
-
},
|
400
|
-
'standard_riak' => {
|
401
|
-
store: :Riak,
|
402
|
-
options: "bucket: 'standard_riak'",
|
403
|
-
# We don't want Riak warnings in tests
|
404
|
-
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n",
|
405
|
-
specs: STANDARD_SPECS.without_increment.without_create
|
406
|
-
},
|
407
|
-
'standard_riak_with_expires' => {
|
408
|
-
store: :Riak,
|
409
|
-
options: "bucket: 'standard_riak_with_expires', expires: true",
|
410
|
-
# We don't want Riak warnings in tests
|
411
|
-
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n",
|
412
|
-
specs: STANDARD_SPECS.without_increment.with_expires.without_create
|
413
|
-
},
|
414
|
-
'standard_couch' => {
|
415
|
-
store: :Couch,
|
416
|
-
options: "db: 'standard_couch'",
|
417
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)',
|
418
|
-
specs: STANDARD_SPECS.without_increment
|
419
|
-
},
|
420
|
-
'standard_couch_with_expires' => {
|
421
|
-
store: :Couch,
|
422
|
-
options: "db: 'standard_couch_with_expires', expires: true",
|
423
|
-
specs: STANDARD_SPECS.without_increment.with_expires,
|
424
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
425
|
-
},
|
426
|
-
'standard_mongo' => {
|
427
|
-
store: :Mongo,
|
428
|
-
options: "db: 'standard_mongo', collection: 'default'",
|
429
|
-
specs: STANDARD_SPECS.with_native_expires
|
430
|
-
},
|
431
|
-
'standard_mongo_moped' => {
|
432
|
-
store: :MongoMoped,
|
433
|
-
options: "db: 'standard_mongo', collection: 'moped'",
|
434
|
-
specs: STANDARD_SPECS.with_native_expires
|
435
|
-
},
|
436
|
-
'standard_mongo_official' => {
|
437
|
-
store: :MongoOfficial,
|
438
|
-
options: "db: 'standard_mongo', collection: 'official'",
|
439
|
-
specs: STANDARD_SPECS.with_native_expires
|
440
|
-
},
|
441
|
-
'standard_null' => {
|
442
|
-
store: :Null,
|
443
|
-
specs: STANDARD_SPECS.without_increment.without_create.without_store.without_persist
|
444
|
-
},
|
445
|
-
'null_adapter' => {
|
446
|
-
build: 'Moneta::Adapters::Null.new',
|
447
|
-
specs: Specs.new(specs: [:null, :not_increment, :not_create, :not_persist])
|
448
|
-
},
|
449
|
-
'standard_sequel' => {
|
450
|
-
store: :Sequel,
|
451
|
-
options: 'db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "simple_sequel"',
|
452
|
-
load_value: '::Marshal.load(value)',
|
453
|
-
specs: STANDARD_SPECS
|
454
|
-
},
|
455
|
-
'standard_sequel_with_expires' => {
|
456
|
-
store: :Sequel,
|
457
|
-
options: 'db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "simple_sequel_with_expires", expires: true',
|
458
|
-
specs: STANDARD_SPECS.with_expires,
|
459
|
-
load_value: '::Marshal.load(value)'
|
460
|
-
},
|
461
|
-
'standard_datamapper' => {
|
462
|
-
store: :DataMapper,
|
463
|
-
specs: STANDARD_SPECS.without_increment,
|
464
|
-
options: 'setup: "mysql://root:@localhost/moneta", table: "simple_datamapper"',
|
465
|
-
# DataMapper needs default repository to be setup
|
466
|
-
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
467
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
468
|
-
},
|
469
|
-
'standard_datamapper_with_expires' => {
|
470
|
-
store: :DataMapper,
|
471
|
-
options: 'setup: "mysql://root:@localhost/moneta", table: "simple_datamapper_with_expires", expires: true',
|
472
|
-
# DataMapper needs default repository to be setup
|
473
|
-
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
474
|
-
specs: STANDARD_SPECS.without_increment.with_expires,
|
475
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
476
|
-
},
|
477
|
-
'standard_datamapper_with_repository' => {
|
478
|
-
store: :DataMapper,
|
479
|
-
specs: STANDARD_SPECS.without_increment,
|
480
|
-
options: 'repository: :repo, setup: "mysql://root:@localhost/moneta", table: "simple_datamapper_with_repository"',
|
481
|
-
# DataMapper needs default repository to be setup
|
482
|
-
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
483
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
484
|
-
},
|
485
|
-
'standard_activerecord' => {
|
486
|
-
store: :ActiveRecord,
|
487
|
-
specs: STANDARD_SPECS,
|
488
|
-
options: "table: 'standard_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' }",
|
489
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
490
|
-
},
|
491
|
-
'standard_activerecord_with_expires' => {
|
492
|
-
store: :ActiveRecord,
|
493
|
-
options: "table: 'standard_activerecord_with_expires', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' }, expires: true",
|
494
|
-
specs: STANDARD_SPECS.with_expires,
|
495
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
496
|
-
},
|
497
|
-
'standard_fog' => {
|
498
|
-
store: :Fog,
|
499
|
-
specs: STANDARD_SPECS.without_increment.without_create,
|
500
|
-
options: "aws_access_key_id: 'fake_access_key_id',
|
501
|
-
aws_secret_access_key: 'fake_secret_access_key',
|
502
|
-
provider: 'AWS',
|
503
|
-
dir: 'standard_fog'",
|
504
|
-
# Put Fog into testing mode
|
505
|
-
preamble: "require 'fog'\nFog.mock!\n"
|
506
|
-
},
|
507
|
-
'standard_fog_with_expires' => {
|
508
|
-
store: :Fog,
|
509
|
-
options: "aws_access_key_id: 'fake_access_key_id',
|
510
|
-
aws_secret_access_key: 'fake_secret_access_key',
|
511
|
-
provider: 'AWS',
|
512
|
-
dir: 'standard_fog_with_expires',
|
513
|
-
expires: true",
|
514
|
-
# Put Fog into testing mode
|
515
|
-
preamble: "require 'fog'\nFog.mock!\n",
|
516
|
-
specs: STANDARD_SPECS.without_increment.without_create.with_expires
|
517
|
-
},
|
518
|
-
'weak_create' => {
|
519
|
-
# Put Fog into testing mode
|
520
|
-
preamble: "require 'fog'\nFog.mock!\n",
|
521
|
-
build: %{Moneta.build do
|
522
|
-
use :WeakCreate
|
523
|
-
adapter :Fog,
|
524
|
-
aws_access_key_id: 'fake_access_key_id',
|
525
|
-
aws_secret_access_key: 'fake_secret_access_key',
|
526
|
-
provider: 'AWS',
|
527
|
-
dir: 'weak_create'
|
528
|
-
end},
|
529
|
-
specs: ADAPTER_SPECS.without_increment.without_concurrent.returnsame
|
530
|
-
},
|
531
|
-
'weak_increment' => {
|
532
|
-
# Put Fog into testing mode
|
533
|
-
preamble: "require 'fog'\nFog.mock!\n",
|
534
|
-
build: %{Moneta.build do
|
535
|
-
use :WeakIncrement
|
536
|
-
adapter :Fog,
|
537
|
-
aws_access_key_id: 'fake_access_key_id',
|
538
|
-
aws_secret_access_key: 'fake_secret_access_key',
|
539
|
-
provider: 'AWS',
|
540
|
-
dir: 'weak_increment'
|
541
|
-
end},
|
542
|
-
specs: ADAPTER_SPECS.without_create.without_concurrent.returnsame
|
543
|
-
},
|
544
|
-
'expires_memory' => {
|
545
|
-
build: %{Moneta.build do
|
546
|
-
use :Expires
|
547
|
-
adapter :Memory
|
548
|
-
end},
|
549
|
-
specs: STANDARD_SPECS.without_transform.with_expires.without_persist.returnsame
|
550
|
-
},
|
551
|
-
'expires_memory_with_default_expires' => {
|
552
|
-
build: %{Moneta.build do
|
553
|
-
use :Expires, expires: 1
|
554
|
-
adapter :Memory
|
555
|
-
end},
|
556
|
-
specs: STANDARD_SPECS.without_transform.with_expires.with_default_expires.without_persist.returnsame
|
557
|
-
},
|
558
|
-
'expires_file' => {
|
559
|
-
build: %{Moneta.build do
|
560
|
-
use :Expires
|
561
|
-
use :Transformer, key: [:marshal, :escape], value: :marshal
|
562
|
-
adapter :File, dir: File.join(make_tempdir, "expires-file")
|
563
|
-
end},
|
564
|
-
specs: STANDARD_SPECS.with_expires.stringvalues_only,
|
565
|
-
tests: %{
|
566
|
-
it 'deletes expired value in underlying file storage' do
|
567
|
-
store.store('foo', 'bar', expires: 2)
|
568
|
-
store['foo'].should == 'bar'
|
569
|
-
sleep 1
|
570
|
-
store['foo'].should == 'bar'
|
571
|
-
sleep 2
|
572
|
-
store['foo'].should be_nil
|
573
|
-
store.adapter['foo'].should be_nil
|
574
|
-
store.adapter.adapter['foo'].should be_nil
|
575
|
-
end
|
576
|
-
}
|
577
|
-
},
|
578
|
-
'proxy_redis' => {
|
579
|
-
build: %{Moneta.build do
|
580
|
-
use :Proxy
|
581
|
-
use :Proxy
|
582
|
-
adapter :Redis
|
583
|
-
end},
|
584
|
-
specs: ADAPTER_SPECS.with_expires
|
585
|
-
},
|
586
|
-
'proxy_expires_memory' => {
|
587
|
-
build: %{Moneta.build do
|
588
|
-
use :Proxy
|
589
|
-
use :Expires
|
590
|
-
use :Proxy
|
591
|
-
adapter :Memory
|
592
|
-
end},
|
593
|
-
specs: STANDARD_SPECS.without_transform.with_expires.returnsame.without_persist
|
594
|
-
},
|
595
|
-
'cache_file_memory' => {
|
596
|
-
build: %{Moneta.build do
|
597
|
-
use(:Cache) do
|
598
|
-
adapter { adapter :File, dir: File.join(make_tempdir, "cache_file_memory") }
|
599
|
-
cache { adapter :Memory }
|
600
|
-
end
|
601
|
-
end},
|
602
|
-
specs: ADAPTER_SPECS.returnsame,
|
603
|
-
tests: %{
|
604
|
-
it 'stores loaded values in cache' do
|
605
|
-
store.adapter['foo'] = 'bar'
|
606
|
-
store.cache['foo'].should be_nil
|
607
|
-
store['foo'].should == 'bar'
|
608
|
-
store.cache['foo'].should == 'bar'
|
609
|
-
store.adapter.delete('foo')
|
610
|
-
store['foo'].should == 'bar'
|
611
|
-
store.delete('foo')
|
612
|
-
store['foo'].should be_nil
|
613
|
-
end
|
614
|
-
}
|
615
|
-
},
|
616
|
-
'cache_memory_null' => {
|
617
|
-
build: %{Moneta.build do
|
618
|
-
use(:Cache) do
|
619
|
-
adapter(Moneta::Adapters::Memory.new)
|
620
|
-
cache(Moneta::Adapters::Null.new)
|
621
|
-
end
|
622
|
-
end},
|
623
|
-
specs: ADAPTER_SPECS.without_persist.returnsame
|
624
|
-
},
|
625
|
-
'shared_tcp' => {
|
626
|
-
build: %{Moneta.build do
|
627
|
-
use(:Shared, port: 9001) do
|
628
|
-
adapter :PStore, file: File.join(make_tempdir, 'shared_tcp')
|
629
|
-
end
|
630
|
-
end},
|
631
|
-
specs: ADAPTER_SPECS,
|
632
|
-
tests: %{
|
633
|
-
it 'shares values' do
|
634
|
-
store['shared_key'] = 'shared_value'
|
635
|
-
second = new_store
|
636
|
-
second.key?('shared_key').should be true
|
637
|
-
second['shared_key'].should == 'shared_value'
|
638
|
-
second.close
|
639
|
-
end
|
640
|
-
}
|
641
|
-
},
|
642
|
-
'shared_unix' => {
|
643
|
-
build: %{Moneta.build do
|
644
|
-
use(:Shared, socket: File.join(make_tempdir, 'shared_unix.socket')) do
|
645
|
-
adapter :PStore, file: File.join(make_tempdir, 'shared_unix')
|
646
|
-
end
|
647
|
-
end},
|
648
|
-
specs: ADAPTER_SPECS,
|
649
|
-
tests: %{
|
650
|
-
it 'shares values' do
|
651
|
-
store['shared_key'] = 'shared_value'
|
652
|
-
second = new_store
|
653
|
-
second.key?('shared_key').should be true
|
654
|
-
second['shared_key'].should == 'shared_value'
|
655
|
-
second.close
|
656
|
-
end
|
657
|
-
}
|
658
|
-
},
|
659
|
-
'stack_file_memory' => {
|
660
|
-
build: %{Moneta.build do
|
661
|
-
use(:Stack) do
|
662
|
-
add(Moneta.new(:Null))
|
663
|
-
add(Moneta::Adapters::Null.new)
|
664
|
-
add { adapter :File, dir: File.join(make_tempdir, "stack_file_memory") }
|
665
|
-
add { adapter :Memory }
|
666
|
-
end
|
667
|
-
end},
|
668
|
-
specs: ADAPTER_SPECS.without_increment.without_create
|
669
|
-
},
|
670
|
-
'stack_memory_file' => {
|
671
|
-
build: %{Moneta.build do
|
672
|
-
use(:Stack) do
|
673
|
-
add { adapter :Memory }
|
674
|
-
add { adapter :File, dir: File.join(make_tempdir, "stack_memory_file") }
|
675
|
-
end
|
676
|
-
end},
|
677
|
-
specs: ADAPTER_SPECS.returnsame
|
678
|
-
},
|
679
|
-
'lock' => {
|
680
|
-
build: %{Moneta.build do
|
681
|
-
use :Lock
|
682
|
-
adapter :Memory
|
683
|
-
end},
|
684
|
-
specs: STANDARD_SPECS.without_transform.returnsame.without_persist
|
685
|
-
},
|
686
|
-
'pool' => {
|
687
|
-
build: %{Moneta.build do
|
688
|
-
use :Pool do
|
689
|
-
adapter :File, dir: File.join(make_tempdir, "pool")
|
690
|
-
end
|
691
|
-
end},
|
692
|
-
specs: ADAPTER_SPECS
|
693
|
-
},
|
694
|
-
'transformer_zlib' => {
|
695
|
-
build: %{Moneta.build do
|
696
|
-
use :Transformer, value: :zlib
|
697
|
-
adapter :Memory
|
698
|
-
end},
|
699
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
700
|
-
load_value: '::Zlib::Inflate.inflate(value)',
|
701
|
-
tests: %{
|
702
|
-
it 'compile transformer class' do
|
703
|
-
store.should_not be_nil
|
704
|
-
Moneta::Transformer::ZlibValue.should_not be_nil
|
705
|
-
end}
|
706
|
-
},
|
707
|
-
'transformer_bzip2' => {
|
708
|
-
build: %{Moneta.build do
|
709
|
-
use :Transformer, value: :bzip2
|
710
|
-
adapter :Memory
|
711
|
-
end},
|
712
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
713
|
-
load_value: '::RBzip2::Decompressor.new(::StringIO.new(value)).read',
|
714
|
-
tests: %{
|
715
|
-
it 'compile transformer class' do
|
716
|
-
store.should_not be_nil
|
717
|
-
Moneta::Transformer::Bzip2Value.should_not be_nil
|
718
|
-
end}
|
719
|
-
},
|
720
|
-
'transformer_lzo' => {
|
721
|
-
build: %{Moneta.build do
|
722
|
-
use :Transformer, value: :lzo
|
723
|
-
adapter :Memory
|
724
|
-
end},
|
725
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
726
|
-
load_value: '::LZO.decompress(value)',
|
727
|
-
tests: %{
|
728
|
-
it 'compile transformer class' do
|
729
|
-
store.should_not be_nil
|
730
|
-
Moneta::Transformer::LzoValue.should_not be_nil
|
731
|
-
end}
|
732
|
-
},
|
733
|
-
'transformer_lz4' => {
|
734
|
-
build: %{Moneta.build do
|
735
|
-
use :Transformer, value: :lz4
|
736
|
-
adapter :Memory
|
737
|
-
end},
|
738
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
739
|
-
load_value: '::LZ4.uncompress(value)',
|
740
|
-
tests: %{
|
741
|
-
it 'compile transformer class' do
|
742
|
-
store.should_not be_nil
|
743
|
-
Moneta::Transformer::Lz4Value.should_not be_nil
|
744
|
-
end}
|
745
|
-
},
|
746
|
-
'transformer_lzma' => {
|
747
|
-
build: %{Moneta.build do
|
748
|
-
use :Transformer, value: :lzma
|
749
|
-
adapter :Memory
|
750
|
-
end},
|
751
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
752
|
-
load_value: '::LZMA.decompress(value)',
|
753
|
-
tests: %{
|
754
|
-
it 'compile transformer class' do
|
755
|
-
store.should_not be_nil
|
756
|
-
Moneta::Transformer::LzmaValue.should_not be_nil
|
757
|
-
end}
|
758
|
-
},
|
759
|
-
'transformer_snappy' => {
|
760
|
-
build: %{Moneta.build do
|
761
|
-
use :Transformer, value: :snappy
|
762
|
-
adapter :Memory
|
763
|
-
end},
|
764
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
765
|
-
load_value: '::Snappy.inflate(value)',
|
766
|
-
tests: %{
|
767
|
-
it 'compile transformer class' do
|
768
|
-
store.should_not be_nil
|
769
|
-
Moneta::Transformer::SnappyValue.should_not be_nil
|
770
|
-
end}
|
771
|
-
},
|
772
|
-
'transformer_quicklz' => {
|
773
|
-
build: %{Moneta.build do
|
774
|
-
use :Transformer, value: :quicklz
|
775
|
-
adapter :Memory
|
776
|
-
end},
|
777
|
-
specs: TRANSFORMER_SPECS.stringvalues_only,
|
778
|
-
load_value: '::QuickLZ.decompress(value)',
|
779
|
-
tests: %{
|
780
|
-
it 'compile transformer class' do
|
781
|
-
store.should_not be_nil
|
782
|
-
Moneta::Transformer::QuicklzValue.should_not be_nil
|
783
|
-
end}
|
784
|
-
},
|
785
|
-
'transformer_json' => {
|
786
|
-
build: %{Moneta.build do
|
787
|
-
use :Transformer, key: :json, value: :json
|
788
|
-
adapter :Memory
|
789
|
-
end},
|
790
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
791
|
-
load_value: '::MultiJson.load(value)',
|
792
|
-
tests: %{
|
793
|
-
it 'compile transformer class' do
|
794
|
-
store.should_not be_nil
|
795
|
-
Moneta::Transformer::JsonKeyJsonValue.should_not be_nil
|
796
|
-
end}
|
797
|
-
},
|
798
|
-
'transformer_bert' => {
|
799
|
-
build: %{Moneta.build do
|
800
|
-
use :Transformer, key: :bert, value: :bert
|
801
|
-
adapter :Memory
|
802
|
-
end},
|
803
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
804
|
-
load_value: '::BERT.decode(value)',
|
805
|
-
tests: %{
|
806
|
-
it 'compile transformer class' do
|
807
|
-
store.should_not be_nil
|
808
|
-
Moneta::Transformer::BertKeyBertValue.should_not be_nil
|
809
|
-
end}
|
810
|
-
},
|
811
|
-
'transformer_bencode' => {
|
812
|
-
build: %{Moneta.build do
|
813
|
-
use :Transformer, key: :bencode, value: :bencode
|
814
|
-
adapter :Memory
|
815
|
-
end},
|
816
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
817
|
-
load_value: '::BEncode.load(value)',
|
818
|
-
tests: %{
|
819
|
-
it 'compile transformer class' do
|
820
|
-
store.should_not be_nil
|
821
|
-
Moneta::Transformer::BencodeKeyBencodeValue.should_not be_nil
|
822
|
-
end}
|
823
|
-
|
824
|
-
},
|
825
|
-
'transformer_bson' => {
|
826
|
-
build: %{Moneta.build do
|
827
|
-
use :Transformer, key: :bson, value: :bson
|
828
|
-
adapter :Memory
|
829
|
-
end},
|
830
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
831
|
-
load_value: %{
|
832
|
-
if ::BSON::VERSION >= '4.0.0'
|
833
|
-
::BSON::Document.from_bson(::BSON::ByteBuffer.new(value))['v']
|
834
|
-
else
|
835
|
-
::BSON::Document.from_bson(::StringIO.new(value))['v']
|
836
|
-
end},
|
837
|
-
tests: %{
|
838
|
-
it 'compile transformer class' do
|
839
|
-
store.should_not be_nil
|
840
|
-
Moneta::Transformer::BsonKeyBsonValue.should_not be_nil
|
841
|
-
end}
|
842
|
-
},
|
843
|
-
'transformer_ox' => {
|
844
|
-
build: %{Moneta.build do
|
845
|
-
use :Transformer, key: :ox, value: :ox
|
846
|
-
adapter :Memory
|
847
|
-
end},
|
848
|
-
specs: TRANSFORMER_SPECS,
|
849
|
-
load_value: '::Ox.parse_obj(value)',
|
850
|
-
tests: %{
|
851
|
-
it 'compile transformer class' do
|
852
|
-
store.should_not be_nil
|
853
|
-
Moneta::Transformer::OxKeyOxValue.should_not be_nil
|
854
|
-
end}
|
855
|
-
},
|
856
|
-
'transformer_php' => {
|
857
|
-
build: %{Moneta.build do
|
858
|
-
use :Transformer, key: :php, value: :php
|
859
|
-
adapter :Memory
|
860
|
-
end},
|
861
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
862
|
-
load_value: '::PHP.unserialize(value)',
|
863
|
-
tests: %{
|
864
|
-
it 'compile transformer class' do
|
865
|
-
store.should_not be_nil
|
866
|
-
Moneta::Transformer::PhpKeyPhpValue.should_not be_nil
|
867
|
-
end}
|
868
|
-
},
|
869
|
-
'transformer_tnet' => {
|
870
|
-
build: %{Moneta.build do
|
871
|
-
use :Transformer, key: :tnet, value: :tnet
|
872
|
-
adapter :Memory
|
873
|
-
end},
|
874
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
875
|
-
load_value: '::TNetstring.parse(value).first',
|
876
|
-
tests: %{
|
877
|
-
it 'compile transformer class' do
|
878
|
-
store.should_not be_nil
|
879
|
-
Moneta::Transformer::TnetKeyTnetValue.should_not be_nil
|
880
|
-
end}
|
881
|
-
},
|
882
|
-
'transformer_msgpack' => {
|
883
|
-
build: %{Moneta.build do
|
884
|
-
use :Transformer, key: :msgpack, value: :msgpack
|
885
|
-
adapter :Memory
|
886
|
-
end},
|
887
|
-
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
888
|
-
load_value: '::MessagePack.unpack(value)',
|
889
|
-
tests: %{
|
890
|
-
it 'compile transformer class' do
|
891
|
-
store.should_not be_nil
|
892
|
-
Moneta::Transformer::MsgpackKeyMsgpackValue.should_not be_nil
|
893
|
-
end}
|
894
|
-
},
|
895
|
-
'transformer_marshal' => {
|
896
|
-
build: %{Moneta.build do
|
897
|
-
use :Transformer, key: :marshal, value: :marshal
|
898
|
-
adapter :Memory
|
899
|
-
end},
|
900
|
-
specs: TRANSFORMER_SPECS,
|
901
|
-
load_value: '::Marshal.load(value)',
|
902
|
-
tests: %{
|
903
|
-
it 'compile transformer class' do
|
904
|
-
store.should_not be_nil
|
905
|
-
Moneta::Transformer::MarshalKeyMarshalValue.should_not be_nil
|
906
|
-
end}
|
907
|
-
},
|
908
|
-
'transformer_key_marshal' => {
|
909
|
-
build: %{Moneta.build do
|
910
|
-
use :Transformer, key: :marshal
|
911
|
-
adapter :Memory
|
912
|
-
end},
|
913
|
-
specs: TRANSFORMER_SPECS.returnsame,
|
914
|
-
load_value: 'value',
|
915
|
-
tests: %{
|
916
|
-
it 'compile transformer class' do
|
917
|
-
store.should_not be_nil
|
918
|
-
Moneta::Transformer::MarshalKey.should_not be_nil
|
919
|
-
end}
|
920
|
-
},
|
921
|
-
'transformer_key_to_s' => {
|
922
|
-
build: %{Moneta.build do
|
923
|
-
use :Transformer, key: :to_s
|
924
|
-
adapter :Memory
|
925
|
-
end},
|
926
|
-
specs: TRANSFORMER_SPECS.returnsame.simplekeys_only,
|
927
|
-
load_value: 'value',
|
928
|
-
tests: %{
|
929
|
-
it 'compile transformer class' do
|
930
|
-
store.should_not be_nil
|
931
|
-
Moneta::Transformer::To_sKey.should_not be_nil
|
932
|
-
end}
|
933
|
-
},
|
934
|
-
'transformer_key_inspect' => {
|
935
|
-
build: %{Moneta.build do
|
936
|
-
use :Transformer, key: :inspect
|
937
|
-
adapter :Memory
|
938
|
-
end},
|
939
|
-
specs: TRANSFORMER_SPECS.returnsame.simplekeys_only,
|
940
|
-
load_value: 'value',
|
941
|
-
tests: %{
|
942
|
-
it 'compile transformer class' do
|
943
|
-
store.should_not be_nil
|
944
|
-
Moneta::Transformer::InspectKey.should_not be_nil
|
945
|
-
end}
|
946
|
-
},
|
947
|
-
'transformer_value_marshal' => {
|
948
|
-
build: %{Moneta.build do
|
949
|
-
use :Transformer, value: :marshal
|
950
|
-
adapter :Memory
|
951
|
-
end},
|
952
|
-
specs: TRANSFORMER_SPECS,
|
953
|
-
load_value: '::Marshal.load(value)',
|
954
|
-
tests: %{
|
955
|
-
it 'compile transformer class' do
|
956
|
-
store.should_not be_nil
|
957
|
-
Moneta::Transformer::MarshalValue.should_not be_nil
|
958
|
-
end}
|
959
|
-
},
|
960
|
-
'transformer_yaml' => {
|
961
|
-
build: %{Moneta.build do
|
962
|
-
use :Transformer, key: :yaml, value: :yaml
|
963
|
-
adapter :Memory
|
964
|
-
end},
|
965
|
-
specs: TRANSFORMER_SPECS,
|
966
|
-
load_value: '::YAML.load(value)',
|
967
|
-
tests: %{
|
968
|
-
it 'compile transformer class' do
|
969
|
-
store.should_not be_nil
|
970
|
-
Moneta::Transformer::YamlKeyYamlValue.should_not be_nil
|
971
|
-
end}
|
972
|
-
},
|
973
|
-
'transformer_key_yaml' => {
|
974
|
-
build: %{Moneta.build do
|
975
|
-
use :Transformer, key: :yaml
|
976
|
-
adapter :Memory
|
977
|
-
end},
|
978
|
-
specs: TRANSFORMER_SPECS.returnsame,
|
979
|
-
load_value: 'value',
|
980
|
-
tests: %{
|
981
|
-
it 'compile transformer class' do
|
982
|
-
store.should_not be_nil
|
983
|
-
Moneta::Transformer::YamlKey.should_not be_nil
|
984
|
-
end}
|
985
|
-
},
|
986
|
-
'transformer_value_yaml' => {
|
987
|
-
build: %{Moneta.build do
|
988
|
-
use :Transformer, value: :yaml
|
989
|
-
adapter :Memory
|
990
|
-
end},
|
991
|
-
specs: TRANSFORMER_SPECS,
|
992
|
-
load_value: '::YAML.load(value)',
|
993
|
-
tests: %{
|
994
|
-
it 'compile transformer class' do
|
995
|
-
store.should_not be_nil
|
996
|
-
Moneta::Transformer::YamlValue.should_not be_nil
|
997
|
-
end}
|
998
|
-
},
|
999
|
-
'transformer_marshal_hmac' => {
|
1000
|
-
build: %{Moneta.build do
|
1001
|
-
use :Transformer, key: :marshal, value: [:marshal, :hmac], secret: 'secret'
|
1002
|
-
adapter :Memory
|
1003
|
-
end},
|
1004
|
-
specs: STANDARD_SPECS.without_persist,
|
1005
|
-
load_value: '::Marshal.load(::Moneta::Transformer::Helper.hmacverify(value, \'secret\'))',
|
1006
|
-
tests: %{
|
1007
|
-
it 'compile transformer class' do
|
1008
|
-
store.should_not be_nil
|
1009
|
-
Moneta::Transformer::MarshalKeyMarshalHmacValue.should_not be_nil
|
1010
|
-
end}
|
1011
|
-
},
|
1012
|
-
'transformer_marshal_base64' => {
|
1013
|
-
build: %{Moneta.build do
|
1014
|
-
use :Transformer, key: [:marshal, :base64], value: [:marshal, :base64]
|
1015
|
-
adapter :Memory
|
1016
|
-
end},
|
1017
|
-
specs: STANDARD_SPECS.without_persist,
|
1018
|
-
load_value: '::Marshal.load(value.unpack(\'m\').first)',
|
1019
|
-
tests: %{
|
1020
|
-
it 'compile transformer class' do
|
1021
|
-
store.should_not be_nil
|
1022
|
-
Moneta::Transformer::MarshalBase64KeyMarshalBase64Value.should_not be_nil
|
1023
|
-
end}
|
1024
|
-
},
|
1025
|
-
'transformer_marshal_hex' => {
|
1026
|
-
build: %{Moneta.build do
|
1027
|
-
use :Transformer, key: [:marshal, :hex], value: [:marshal, :hex]
|
1028
|
-
adapter :Memory
|
1029
|
-
end},
|
1030
|
-
specs: STANDARD_SPECS.without_persist,
|
1031
|
-
load_value: '::Marshal.load([value].pack(\'H*\'))',
|
1032
|
-
tests: %{
|
1033
|
-
it 'compile transformer class' do
|
1034
|
-
store.should_not be_nil
|
1035
|
-
Moneta::Transformer::MarshalHexKeyMarshalHexValue.should_not be_nil
|
1036
|
-
end}
|
1037
|
-
},
|
1038
|
-
'transformer_marshal_prefix' => {
|
1039
|
-
build: %{Moneta.build do
|
1040
|
-
use :Transformer, key: [:marshal, :prefix], value: :marshal, prefix: 'moneta'
|
1041
|
-
adapter :Memory
|
1042
|
-
end},
|
1043
|
-
specs: STANDARD_SPECS.without_persist,
|
1044
|
-
tests: %{
|
1045
|
-
it 'compile transformer class' do
|
1046
|
-
store.should_not be_nil
|
1047
|
-
Moneta::Transformer::MarshalPrefixKeyMarshalValue.should_not be_nil
|
1048
|
-
end}
|
1049
|
-
},
|
1050
|
-
'transformer_marshal_uuencode' => {
|
1051
|
-
build: %{Moneta.build do
|
1052
|
-
use :Transformer, key: [:marshal, :uuencode], value: [:marshal, :uuencode]
|
1053
|
-
adapter :Memory
|
1054
|
-
end},
|
1055
|
-
specs: STANDARD_SPECS.without_persist,
|
1056
|
-
load_value: '::Marshal.load(value.unpack(\'u\').first)',
|
1057
|
-
tests: %{
|
1058
|
-
it 'compile transformer class' do
|
1059
|
-
store.should_not be_nil
|
1060
|
-
Moneta::Transformer::MarshalUuencodeKeyMarshalUuencodeValue.should_not be_nil
|
1061
|
-
end}
|
1062
|
-
},
|
1063
|
-
'transformer_marshal_qp' => {
|
1064
|
-
build: %{Moneta.build do
|
1065
|
-
use :Transformer, key: [:marshal, :qp], value: [:marshal, :qp]
|
1066
|
-
adapter :Memory
|
1067
|
-
end},
|
1068
|
-
specs: STANDARD_SPECS.without_persist,
|
1069
|
-
load_value: '::Marshal.load(value.unpack(\'M\').first)',
|
1070
|
-
tests: %{
|
1071
|
-
it 'compile transformer class' do
|
1072
|
-
store.should_not be_nil
|
1073
|
-
Moneta::Transformer::MarshalQpKeyMarshalQpValue.should_not be_nil
|
1074
|
-
end}
|
1075
|
-
},
|
1076
|
-
'transformer_marshal_escape' => {
|
1077
|
-
build: %{Moneta.build do
|
1078
|
-
use :Transformer, key: [:marshal, :escape], value: :marshal
|
1079
|
-
adapter :Memory
|
1080
|
-
end},
|
1081
|
-
specs: STANDARD_SPECS.without_persist,
|
1082
|
-
tests: %{
|
1083
|
-
it 'compile transformer class' do
|
1084
|
-
store.should_not be_nil
|
1085
|
-
Moneta::Transformer::MarshalEscapeKeyMarshalValue.should_not be_nil
|
1086
|
-
end}
|
1087
|
-
},
|
1088
|
-
'transformer_marshal_md5' => {
|
1089
|
-
build: %{Moneta.build do
|
1090
|
-
use :Transformer, key: [:marshal, :md5], value: :marshal
|
1091
|
-
adapter :Memory
|
1092
|
-
end},
|
1093
|
-
specs: STANDARD_SPECS.without_persist,
|
1094
|
-
tests: %{
|
1095
|
-
it 'compile transformer class' do
|
1096
|
-
store.should_not be_nil
|
1097
|
-
Moneta::Transformer::MarshalMd5KeyMarshalValue.should_not be_nil
|
1098
|
-
end}
|
1099
|
-
},
|
1100
|
-
'transformer_marshal_sha1' => {
|
1101
|
-
build: %{Moneta.build do
|
1102
|
-
use :Transformer, key: [:marshal, :sha1], value: :marshal
|
1103
|
-
adapter :Memory
|
1104
|
-
end},
|
1105
|
-
specs: STANDARD_SPECS.without_persist,
|
1106
|
-
tests: %{
|
1107
|
-
it 'compile transformer class' do
|
1108
|
-
store.should_not be_nil
|
1109
|
-
Moneta::Transformer::MarshalSha1KeyMarshalValue.should_not be_nil
|
1110
|
-
end}
|
1111
|
-
},
|
1112
|
-
'transformer_marshal_sha256' => {
|
1113
|
-
build: %{Moneta.build do
|
1114
|
-
use :Transformer, key: [:marshal, :sha256], value: :marshal
|
1115
|
-
adapter :Memory
|
1116
|
-
end},
|
1117
|
-
specs: STANDARD_SPECS.without_persist,
|
1118
|
-
tests: %{
|
1119
|
-
it 'compile transformer class' do
|
1120
|
-
store.should_not be_nil
|
1121
|
-
Moneta::Transformer::MarshalSha256KeyMarshalValue.should_not be_nil
|
1122
|
-
end}
|
1123
|
-
},
|
1124
|
-
'transformer_marshal_sha384' => {
|
1125
|
-
build: %{Moneta.build do
|
1126
|
-
use :Transformer, key: [:marshal, :sha384], value: :marshal
|
1127
|
-
adapter :Memory
|
1128
|
-
end},
|
1129
|
-
specs: STANDARD_SPECS.without_persist,
|
1130
|
-
tests: %{
|
1131
|
-
it 'compile transformer class' do
|
1132
|
-
store.should_not be_nil
|
1133
|
-
Moneta::Transformer::MarshalSha384KeyMarshalValue.should_not be_nil
|
1134
|
-
end}
|
1135
|
-
},
|
1136
|
-
'transformer_marshal_sha512' => {
|
1137
|
-
build: %{Moneta.build do
|
1138
|
-
use :Transformer, key: [:marshal, :sha512], value: :marshal
|
1139
|
-
adapter :Memory
|
1140
|
-
end},
|
1141
|
-
specs: STANDARD_SPECS.without_persist,
|
1142
|
-
tests: %{
|
1143
|
-
it 'compile transformer class' do
|
1144
|
-
store.should_not be_nil
|
1145
|
-
Moneta::Transformer::MarshalSha512KeyMarshalValue.should_not be_nil
|
1146
|
-
end}
|
1147
|
-
},
|
1148
|
-
'transformer_marshal_rmd160' => {
|
1149
|
-
build: %{Moneta.build do
|
1150
|
-
use :Transformer, key: [:marshal, :rmd160], value: :marshal
|
1151
|
-
adapter :Memory
|
1152
|
-
end},
|
1153
|
-
specs: STANDARD_SPECS.without_persist,
|
1154
|
-
tests: %{
|
1155
|
-
it 'compile transformer class' do
|
1156
|
-
store.should_not be_nil
|
1157
|
-
Moneta::Transformer::MarshalRmd160KeyMarshalValue.should_not be_nil
|
1158
|
-
end}
|
1159
|
-
},
|
1160
|
-
'transformer_marshal_md5_spread' => {
|
1161
|
-
build: %{Moneta.build do
|
1162
|
-
use :Transformer, key: [:marshal, :md5, :spread], value: :marshal
|
1163
|
-
adapter :Memory
|
1164
|
-
end},
|
1165
|
-
specs: STANDARD_SPECS.without_persist,
|
1166
|
-
tests: %{
|
1167
|
-
it 'compile transformer class' do
|
1168
|
-
store.should_not be_nil
|
1169
|
-
Moneta::Transformer::MarshalMd5SpreadKeyMarshalValue.should_not be_nil
|
1170
|
-
end}
|
1171
|
-
},
|
1172
|
-
'transformer_marshal_city32' => {
|
1173
|
-
build: %{Moneta.build do
|
1174
|
-
use :Transformer, key: [:marshal, :city32], value: :marshal
|
1175
|
-
adapter :Memory
|
1176
|
-
end},
|
1177
|
-
specs: STANDARD_SPECS.without_persist,
|
1178
|
-
tests: %{
|
1179
|
-
it 'compile transformer class' do
|
1180
|
-
store.should_not be_nil
|
1181
|
-
Moneta::Transformer::MarshalCity32KeyMarshalValue.should_not be_nil
|
1182
|
-
end}
|
1183
|
-
},
|
1184
|
-
'transformer_marshal_city64' => {
|
1185
|
-
build: %{Moneta.build do
|
1186
|
-
use :Transformer, key: [:marshal, :city64], value: :marshal
|
1187
|
-
adapter :Memory
|
1188
|
-
end},
|
1189
|
-
specs: STANDARD_SPECS.without_persist,
|
1190
|
-
tests: %{
|
1191
|
-
it 'compile transformer class' do
|
1192
|
-
store.should_not be_nil
|
1193
|
-
Moneta::Transformer::MarshalCity64KeyMarshalValue.should_not be_nil
|
1194
|
-
end}
|
1195
|
-
},
|
1196
|
-
'transformer_marshal_city128' => {
|
1197
|
-
build: %{Moneta.build do
|
1198
|
-
use :Transformer, key: [:marshal, :city128], value: :marshal
|
1199
|
-
adapter :Memory
|
1200
|
-
end},
|
1201
|
-
specs: STANDARD_SPECS.without_persist,
|
1202
|
-
tests: %{
|
1203
|
-
it 'compile transformer class' do
|
1204
|
-
store.should_not be_nil
|
1205
|
-
Moneta::Transformer::MarshalCity128KeyMarshalValue.should_not be_nil
|
1206
|
-
end}
|
1207
|
-
},
|
1208
|
-
'transformer_marshal_truncate' => {
|
1209
|
-
build: %{Moneta.build do
|
1210
|
-
use :Transformer, key: [:marshal, :truncate], value: :marshal, maxlen: 64
|
1211
|
-
adapter :Memory
|
1212
|
-
end},
|
1213
|
-
specs: STANDARD_SPECS.without_persist,
|
1214
|
-
tests: %{
|
1215
|
-
it 'compile transformer class' do
|
1216
|
-
store.should_not be_nil
|
1217
|
-
Moneta::Transformer::MarshalTruncateKeyMarshalValue.should_not be_nil
|
1218
|
-
end}
|
1219
|
-
},
|
1220
|
-
'adapter_activerecord' => {
|
1221
|
-
build: "Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })",
|
1222
|
-
specs: ADAPTER_SPECS,
|
1223
|
-
tests: %{
|
1224
|
-
it 'updates an existing key/value' do
|
1225
|
-
store['foo/bar'] = '1'
|
1226
|
-
store['foo/bar'] = '2'
|
1227
|
-
store.table.where(k: 'foo/bar').count.should == 1
|
1228
|
-
end
|
1229
|
-
|
1230
|
-
it 'supports different tables same database' do
|
1231
|
-
store1 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord1', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })
|
1232
|
-
store2 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord2', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })
|
1233
|
-
|
1234
|
-
store1['key'] = 'value1'
|
1235
|
-
store2['key'] = 'value2'
|
1236
|
-
store1['key'].should == 'value1'
|
1237
|
-
store2['key'].should == 'value2'
|
1238
|
-
|
1239
|
-
store1.close
|
1240
|
-
store2.close
|
1241
|
-
end
|
1242
|
-
|
1243
|
-
it 'supports different databases same table' do
|
1244
|
-
store1 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta_activerecord1', username: 'root' })
|
1245
|
-
store2 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta_activerecord2', username: 'root' })
|
1246
|
-
|
1247
|
-
store1['key'] = 'value1'
|
1248
|
-
store2['key'] = 'value2'
|
1249
|
-
store1['key'].should == 'value1'
|
1250
|
-
store2['key'].should == 'value2'
|
1251
|
-
|
1252
|
-
store1.close
|
1253
|
-
store2.close
|
1254
|
-
end}
|
1255
|
-
},
|
1256
|
-
'adapter_activerecord_exisiting_connection' => {
|
1257
|
-
preamble: "require 'active_record'\nActiveRecord::Base.establish_connection adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root'\n",
|
1258
|
-
build: "Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord_existing_connection')",
|
1259
|
-
specs: ADAPTER_SPECS
|
1260
|
-
},
|
1261
|
-
'adapter_client' => {
|
1262
|
-
preamble: "start_server(Moneta::Adapters::Memory.new)\n",
|
1263
|
-
build: "Moneta::Adapters::Client.new",
|
1264
|
-
specs: ADAPTER_SPECS
|
1265
|
-
},
|
1266
|
-
'adapter_restclient' => {
|
1267
|
-
preamble: "start_restserver\n",
|
1268
|
-
build: "Moneta::Adapters::RestClient.new(url: 'http://localhost:8808/moneta/')",
|
1269
|
-
specs: ADAPTER_SPECS.without_increment.without_create
|
1270
|
-
},
|
1271
|
-
'adapter_cassandra' => {
|
1272
|
-
build: "Moneta::Adapters::Cassandra.new(keyspace: 'adapter_cassandra')",
|
1273
|
-
specs: ADAPTER_SPECS.without_increment.without_create.with_native_expires
|
1274
|
-
},
|
1275
|
-
'adapter_cassandra_with_default_expires' => {
|
1276
|
-
build: %{Moneta::Adapters::Cassandra.new(keyspace: 'adapter_cassandra_with_default_expires', expires: 1)},
|
1277
|
-
specs: ADAPTER_SPECS.without_increment.without_create.with_native_expires.with_default_expires
|
1278
|
-
},
|
1279
|
-
'adapter_hbase' => {
|
1280
|
-
build: "Moneta::Adapters::HBase.new(table: 'adapter_hbase')",
|
1281
|
-
specs: ADAPTER_SPECS.without_create
|
1282
|
-
},
|
1283
|
-
'adapter_cookie' => {
|
1284
|
-
build: 'Moneta::Adapters::Cookie.new',
|
1285
|
-
specs: ADAPTER_SPECS.without_persist.returnsame
|
1286
|
-
},
|
1287
|
-
'adapter_couch' => {
|
1288
|
-
build: "Moneta::Adapters::Couch.new(db: 'adapter_couch')",
|
1289
|
-
specs: ADAPTER_SPECS.without_increment.simplevalues_only.without_path
|
1290
|
-
},
|
1291
|
-
'adapter_datamapper' => {
|
1292
|
-
build: 'Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "adapter_datamapper")',
|
1293
|
-
# DataMapper needs default repository to be setup
|
1294
|
-
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
1295
|
-
specs: ADAPTER_SPECS.without_increment,
|
1296
|
-
tests: %q{
|
1297
|
-
it 'does not cross contaminate when storing' do
|
1298
|
-
first = Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "datamapper_first")
|
1299
|
-
first.clear
|
1300
|
-
|
1301
|
-
second = Moneta::Adapters::DataMapper.new(repository: :sample, setup: "mysql://root:@localhost/moneta", table: "datamapper_second")
|
1302
|
-
second.clear
|
1303
|
-
|
1304
|
-
first['key'] = 'value'
|
1305
|
-
second['key'] = 'value2'
|
1306
|
-
|
1307
|
-
first['key'].should == 'value'
|
1308
|
-
second['key'].should == 'value2'
|
1309
|
-
end
|
1310
|
-
|
1311
|
-
it 'does not cross contaminate when deleting' do
|
1312
|
-
first = Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "datamapper_first")
|
1313
|
-
first.clear
|
1314
|
-
|
1315
|
-
second = Moneta::Adapters::DataMapper.new(repository: :sample, setup: "mysql://root:@localhost/moneta", table: "datamapper_second")
|
1316
|
-
second.clear
|
1317
|
-
|
1318
|
-
first['key'] = 'value'
|
1319
|
-
second['key'] = 'value2'
|
1320
|
-
|
1321
|
-
first.delete('key').should == 'value'
|
1322
|
-
first.key?('key').should be false
|
1323
|
-
second['key'].should == 'value2'
|
1324
|
-
end
|
1325
|
-
}
|
1326
|
-
},
|
1327
|
-
'adapter_dbm' => {
|
1328
|
-
build: 'Moneta::Adapters::DBM.new(file: File.join(make_tempdir, "adapter_dbm"))',
|
1329
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1330
|
-
},
|
1331
|
-
'adapter_tdb' => {
|
1332
|
-
build: 'Moneta::Adapters::TDB.new(file: File.join(make_tempdir, "adapter_tdb"))',
|
1333
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1334
|
-
},
|
1335
|
-
'adapter_daybreak' => {
|
1336
|
-
build: 'Moneta::Adapters::Daybreak.new(file: File.join(make_tempdir, "adapter_daybreak"))',
|
1337
|
-
specs: ADAPTER_SPECS.without_multiprocess.returnsame
|
1338
|
-
},
|
1339
|
-
'adapter_file' => {
|
1340
|
-
build: 'Moneta::Adapters::File.new(dir: File.join(make_tempdir, "adapter_file"))',
|
1341
|
-
specs: ADAPTER_SPECS
|
1342
|
-
},
|
1343
|
-
'adapter_fog' => {
|
1344
|
-
build: "Moneta::Adapters::Fog.new(aws_access_key_id: 'fake_access_key_id',
|
1345
|
-
aws_secret_access_key: 'fake_secret_access_key',
|
1346
|
-
provider: 'AWS',
|
1347
|
-
dir: 'adapter_fog')",
|
1348
|
-
# Put Fog into testing mode
|
1349
|
-
preamble: "require 'fog'\nFog.mock!\n",
|
1350
|
-
# Fog returns same object in mocking mode (in-memory store)
|
1351
|
-
specs: ADAPTER_SPECS.without_increment.without_create.returnsame
|
1352
|
-
},
|
1353
|
-
'adapter_gdbm' => {
|
1354
|
-
build: 'Moneta::Adapters::GDBM.new(file: File.join(make_tempdir, "adapter_gdbm"))',
|
1355
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1356
|
-
},
|
1357
|
-
'adapter_localmemcache' => {
|
1358
|
-
build: 'Moneta::Adapters::LocalMemCache.new(file: File.join(make_tempdir, "adapter_localmemcache"))',
|
1359
|
-
specs: ADAPTER_SPECS.without_increment.without_create
|
1360
|
-
},
|
1361
|
-
'adapter_memcached_dalli' => {
|
1362
|
-
build: 'Moneta::Adapters::MemcachedDalli.new(namespace: "adapter_memcached_dalli")',
|
1363
|
-
specs: ADAPTER_SPECS.with_native_expires
|
1364
|
-
},
|
1365
|
-
'adapter_memcached_dalli_with_default_expires' => {
|
1366
|
-
build: %{Moneta::Adapters::MemcachedDalli.new(expires: 1)},
|
1367
|
-
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
1368
|
-
},
|
1369
|
-
'adapter_memcached_native' => {
|
1370
|
-
build: 'Moneta::Adapters::MemcachedNative.new(namespace: "adapter_memcached_native")',
|
1371
|
-
specs: ADAPTER_SPECS.with_native_expires
|
1372
|
-
},
|
1373
|
-
'adapter_memcached_native_with_default_expires' => {
|
1374
|
-
build: %{Moneta::Adapters::MemcachedNative.new(expires: 1)},
|
1375
|
-
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
1376
|
-
},
|
1377
|
-
'adapter_memcached' => {
|
1378
|
-
build: 'Moneta::Adapters::Memcached.new(namespace: "adapter_memcached")',
|
1379
|
-
specs: ADAPTER_SPECS.with_native_expires
|
1380
|
-
},
|
1381
|
-
'adapter_memcached_with_default_expires' => {
|
1382
|
-
build: %{Moneta::Adapters::Memcached.new(expires: 1)},
|
1383
|
-
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
1384
|
-
},
|
1385
|
-
'adapter_memory' => {
|
1386
|
-
build: 'Moneta::Adapters::Memory.new',
|
1387
|
-
specs: STANDARD_SPECS.without_transform.returnsame.without_persist
|
1388
|
-
},
|
1389
|
-
'adapter_lruhash' => {
|
1390
|
-
build: 'Moneta::Adapters::LRUHash.new',
|
1391
|
-
specs: ADAPTER_SPECS.without_persist.returnsame,
|
1392
|
-
tests: %{
|
1393
|
-
it 'deletes oldest' do
|
1394
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 10)
|
1395
|
-
store[0] = 'y'
|
1396
|
-
(1..1000).each do |i|
|
1397
|
-
store[i] = 'x'
|
1398
|
-
store[0].should == 'y'
|
1399
|
-
store.instance_variable_get(:@entry).size.should == [10, i+1].min
|
1400
|
-
(0...[9, i-1].min).each do |j|
|
1401
|
-
store.instance_variable_get(:@entry)[i-j].should_not be_nil
|
1402
|
-
end
|
1403
|
-
store.key?(i-9).should be false if i > 9
|
1404
|
-
end
|
1405
|
-
end
|
1406
|
-
|
1407
|
-
it 'adds a value that is the same as max_size' do
|
1408
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 21)
|
1409
|
-
store[:a_key] = 'This is 21 bytes long'
|
1410
|
-
store[:a_key].should eq('This is 21 bytes long')
|
1411
|
-
end
|
1412
|
-
|
1413
|
-
it 'does not add a value that is larger than max_size' do
|
1414
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 20)
|
1415
|
-
store[:too_long] = 'This is 21 bytes long'
|
1416
|
-
store[:too_long].should be_nil
|
1417
|
-
end
|
1418
|
-
|
1419
|
-
it 'removes an existing key that is replaced by an item that is larger than max_size' do
|
1420
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 20)
|
1421
|
-
store[:a_key] = 'This will fit'
|
1422
|
-
store[:a_key] = 'This is 21 bytes long'
|
1423
|
-
store[:a_key].should be_nil
|
1424
|
-
end
|
1425
|
-
|
1426
|
-
it 'does not add a value that is larger than max_size, when max_value is explicitly missing' do
|
1427
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 20, max_value: nil)
|
1428
|
-
store[:too_long] = 'This is 21 bytes long'
|
1429
|
-
store[:too_long].should be_nil
|
1430
|
-
end
|
1431
|
-
|
1432
|
-
it 'does not add a value that is larger than max_size, even if max_value is larger than max_size' do
|
1433
|
-
store = Moneta::Adapters::LRUHash.new(max_size: 20, max_value: 25)
|
1434
|
-
store[:too_long] = 'This is 21 bytes long'
|
1435
|
-
store[:too_long].should be_nil
|
1436
|
-
end
|
1437
|
-
|
1438
|
-
it 'adds a value that is as large as the default max_size when max_size is missing' do
|
1439
|
-
store = Moneta::Adapters::LRUHash.new
|
1440
|
-
large_item = 'Really big'
|
1441
|
-
allow(large_item).to receive(:bytesize).and_return(Moneta::Adapters::LRUHash::DEFAULT_MAX_SIZE)
|
1442
|
-
store[:really_big] = large_item
|
1443
|
-
store[:really_big].should eq(large_item)
|
1444
|
-
end
|
1445
|
-
|
1446
|
-
it 'does not add values that are larger than the default max_size when max_size is missing' do
|
1447
|
-
store = Moneta::Adapters::LRUHash.new
|
1448
|
-
large_item = 'Really big'
|
1449
|
-
allow(large_item).to receive(:bytesize).and_return(Moneta::Adapters::LRUHash::DEFAULT_MAX_SIZE + 1)
|
1450
|
-
store[:really_big] = large_item
|
1451
|
-
store[:really_big].should be_nil
|
1452
|
-
end
|
1453
|
-
|
1454
|
-
it 'adds values that are larger than the default max_size when max_size is nil' do
|
1455
|
-
store = Moneta::Adapters::LRUHash.new(max_size: nil)
|
1456
|
-
large_item = 'Really big'
|
1457
|
-
allow(large_item).to receive(:bytesize).and_return(Moneta::Adapters::LRUHash::DEFAULT_MAX_SIZE + 1)
|
1458
|
-
store[:really_big] = large_item
|
1459
|
-
store[:really_big].should eq(large_item)
|
1460
|
-
end
|
1461
|
-
|
1462
|
-
it 'adds an individual value that is equal to max_value' do
|
1463
|
-
store = Moneta::Adapters::LRUHash.new(max_value: 13)
|
1464
|
-
store[:a_key] = '13 bytes long'
|
1465
|
-
store[:a_key].should eq('13 bytes long')
|
1466
|
-
end
|
1467
|
-
|
1468
|
-
it 'does not add a value that is larger than max_value' do
|
1469
|
-
store = Moneta::Adapters::LRUHash.new(max_value: 20)
|
1470
|
-
store[:too_long] = 'This is 21 bytes long'
|
1471
|
-
store[:too_long].should be_nil
|
1472
|
-
end
|
1473
|
-
|
1474
|
-
it 'removes keys that are replaced by values larger than max_value' do
|
1475
|
-
store = Moneta::Adapters::LRUHash.new(max_value: 20)
|
1476
|
-
store[:too_long] = 'This will fit'
|
1477
|
-
store[:too_long] = 'This is 21 bytes long'
|
1478
|
-
store[:too_long].should be_nil
|
1479
|
-
end
|
1480
|
-
|
1481
|
-
it 'only allows the default number of items when max_count is missing' do
|
1482
|
-
stub_const('Moneta::Adapters::LRUHash::DEFAULT_MAX_COUNT', 5)
|
1483
|
-
store = Moneta::Adapters::LRUHash.new(max_value: nil, max_size: nil)
|
1484
|
-
(1..6).each { |n| store[n] = n }
|
1485
|
-
store.key?(1).should be false
|
1486
|
-
store[1].should be_nil
|
1487
|
-
store[2].should eq(2)
|
1488
|
-
store[6].should eq(6)
|
1489
|
-
end
|
1490
|
-
|
1491
|
-
it 'adds more values than DEFAULT_MAX_COUNT allows when max_count is nil' do
|
1492
|
-
stub_const('Moneta::Adapters::LRUHash::DEFAULT_MAX_COUNT', 5)
|
1493
|
-
store = Moneta::Adapters::LRUHash.new(max_count: nil, max_value: nil, max_size: nil)
|
1494
|
-
(1..6).each { |n| store[n] = n }
|
1495
|
-
store[1].should eq(1)
|
1496
|
-
store[2].should eq(2)
|
1497
|
-
store[6].should eq(6)
|
1498
|
-
end}
|
1499
|
-
},
|
1500
|
-
'adapter_mongo' => {
|
1501
|
-
build: %{\
|
1502
|
-
Moneta::Adapters::Mongo.new(db: "adapter_mongo",
|
1503
|
-
collection: 'default')},
|
1504
|
-
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only
|
1505
|
-
},
|
1506
|
-
'adapter_mongo_with_default_expires' => {
|
1507
|
-
build: %{\
|
1508
|
-
Moneta::Adapters::Mongo.new(db: "adapter_mongo",
|
1509
|
-
collection: 'with_default_expires',
|
1510
|
-
expires: 1)},
|
1511
|
-
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
1512
|
-
},
|
1513
|
-
'adapter_mongo_moped' => {
|
1514
|
-
build: %{\
|
1515
|
-
Moneta::Adapters::MongoMoped.new(db: "adapter_mongo",
|
1516
|
-
collection: 'moped')},
|
1517
|
-
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only,
|
1518
|
-
tests: %{
|
1519
|
-
it 'automatically deletes expired document' do
|
1520
|
-
store.store('key', 'val', expires: 5)
|
1521
|
-
|
1522
|
-
i = 0
|
1523
|
-
query = store.instance_variable_get(:@collection).find(_id: ::BSON::Binary.new('key'))
|
1524
|
-
while i < 70 && query.first
|
1525
|
-
i += 1
|
1526
|
-
sleep 1 # Mongo needs up to 60 seconds
|
1527
|
-
end
|
1528
|
-
|
1529
|
-
i.should be > 0 # Indicates that it took at least one sleep to expire
|
1530
|
-
query.count.should == 0
|
1531
|
-
end}
|
1532
|
-
},
|
1533
|
-
'adapter_mongo_moped_with_default_expires' => {
|
1534
|
-
build: %{\
|
1535
|
-
Moneta::Adapters::MongoMoped.new(db: "adapter_mongo",
|
1536
|
-
collection: 'moped_with_default_expires',
|
1537
|
-
expires: 1)},
|
1538
|
-
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
1539
|
-
},
|
1540
|
-
'adapter_mongo_official' => {
|
1541
|
-
build: %{\
|
1542
|
-
Moneta::Adapters::MongoOfficial.new(db: "adapter_mongo",
|
1543
|
-
collection: 'official')},
|
1544
|
-
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only,
|
1545
|
-
tests: %{
|
1546
|
-
it 'automatically deletes expired document' do
|
1547
|
-
store.store('key', 'val', expires: 5)
|
1548
|
-
|
1549
|
-
i = 0
|
1550
|
-
query = store.instance_variable_get(:@collection).find(_id: ::BSON::Binary.new('key'))
|
1551
|
-
while i < 70 && query.first
|
1552
|
-
i += 1
|
1553
|
-
sleep 1 # Mongo needs up to 60 seconds
|
1554
|
-
end
|
1555
|
-
|
1556
|
-
i.should be > 0 # Indicates that it took at least one sleep to expire
|
1557
|
-
query.count.should == 0
|
1558
|
-
end}
|
1559
|
-
},
|
1560
|
-
'adapter_mongo_official_with_default_expires' => {
|
1561
|
-
build: %{\
|
1562
|
-
Moneta::Adapters::MongoOfficial.new(db: "adapter_mongo",
|
1563
|
-
collection: 'official_with_default_expires',
|
1564
|
-
expires: 1)},
|
1565
|
-
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
1566
|
-
},
|
1567
|
-
'adapter_pstore' => {
|
1568
|
-
build: 'Moneta::Adapters::PStore.new(file: File.join(make_tempdir, "adapter_pstore"))',
|
1569
|
-
specs: STANDARD_SPECS.without_transform
|
1570
|
-
},
|
1571
|
-
'adapter_redis' => {
|
1572
|
-
build: 'Moneta::Adapters::Redis.new',
|
1573
|
-
specs: ADAPTER_SPECS.with_native_expires
|
1574
|
-
},
|
1575
|
-
'adapter_redis_with_default_expires' => {
|
1576
|
-
build: %{Moneta::Adapters::Redis.new(expires: 1)},
|
1577
|
-
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
1578
|
-
},
|
1579
|
-
'adapter_riak' => {
|
1580
|
-
build: 'Moneta::Adapters::Riak.new',
|
1581
|
-
options: ":bucket => 'adapter_riak'",
|
1582
|
-
specs: ADAPTER_SPECS.without_increment.without_create,
|
1583
|
-
# We don't want Riak warnings in tests
|
1584
|
-
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n"
|
1585
|
-
},
|
1586
|
-
'adapter_sdbm' => {
|
1587
|
-
build: 'Moneta::Adapters::SDBM.new(file: File.join(make_tempdir, "adapter_sdbm"))',
|
1588
|
-
specs: ADAPTER_SPECS.without_multiprocess.without_large
|
1589
|
-
},
|
1590
|
-
'adapter_lmdb' => {
|
1591
|
-
build: 'Moneta::Adapters::LMDB.new(dir: File.join(make_tempdir, "adapter_lmdb"))',
|
1592
|
-
specs: ADAPTER_SPECS.without_concurrent
|
1593
|
-
},
|
1594
|
-
'adapter_lmdb_with_db' => {
|
1595
|
-
build: 'Moneta::Adapters::LMDB.new(dir: File.join(make_tempdir, "adapter_lmdb"), db: "adapter_lmdb_with_db")',
|
1596
|
-
specs: ADAPTER_SPECS.without_concurrent
|
1597
|
-
},
|
1598
|
-
'adapter_leveldb' => {
|
1599
|
-
build: 'Moneta::Adapters::LevelDB.new(dir: File.join(make_tempdir, "adapter_leveldb"))',
|
1600
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1601
|
-
},
|
1602
|
-
'adapter_sequel' => {
|
1603
|
-
build: 'Moneta::Adapters::Sequel.new(db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "adapter_sequel")',
|
1604
|
-
specs: ADAPTER_SPECS
|
1605
|
-
},
|
1606
|
-
'adapter_sqlite' => {
|
1607
|
-
build: 'Moneta::Adapters::Sqlite.new(file: File.join(make_tempdir, "adapter_sqlite"))',
|
1608
|
-
specs: ADAPTER_SPECS.without_concurrent
|
1609
|
-
},
|
1610
|
-
'adapter_kyotocabinet' => {
|
1611
|
-
build: 'Moneta::Adapters::KyotoCabinet.new(file: File.join(make_tempdir, "adapter_kyotocabinet.kch"))',
|
1612
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1613
|
-
},
|
1614
|
-
'adapter_tokyocabinet_bdb' => {
|
1615
|
-
build: 'Moneta::Adapters::TokyoCabinet.new(file: File.join(make_tempdir, "adapter_tokyocabinet_bdb"), type: :bdb)',
|
1616
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1617
|
-
},
|
1618
|
-
'adapter_tokyocabinet_hdb' => {
|
1619
|
-
build: 'Moneta::Adapters::TokyoCabinet.new(file: File.join(make_tempdir, "adapter_tokyocabinet_hdb"), type: :hdb)',
|
1620
|
-
specs: ADAPTER_SPECS.without_multiprocess
|
1621
|
-
},
|
1622
|
-
'adapter_tokyotyrant' => {
|
1623
|
-
build: 'Moneta::Adapters::TokyoTyrant.new',
|
1624
|
-
specs: ADAPTER_SPECS
|
1625
|
-
},
|
1626
|
-
'adapter_yaml' => {
|
1627
|
-
build: 'Moneta::Adapters::YAML.new(file: File.join(make_tempdir, "adapter_yaml"))',
|
1628
|
-
specs: STANDARD_SPECS.simplevalues_only.simplekeys_only.without_transform.without_concurrent
|
1629
|
-
},
|
1630
|
-
'mutex' => {
|
1631
|
-
store: :Memory,
|
1632
|
-
specs: Specs.new,
|
1633
|
-
tests: %{
|
1634
|
-
it 'should have #lock' do
|
1635
|
-
mutex = Moneta::Mutex.new(store, 'mutex')
|
1636
|
-
mutex.lock.should be true
|
1637
|
-
mutex.locked?.should be true
|
1638
|
-
expect do
|
1639
|
-
mutex.lock
|
1640
|
-
end.to raise_error(RuntimeError)
|
1641
|
-
expect do
|
1642
|
-
mutex.try_lock
|
1643
|
-
end.to raise_error(RuntimeError)
|
1644
|
-
mutex.unlock.should be_nil
|
1645
|
-
mutex.locked?.should be false
|
1646
|
-
end
|
1647
|
-
|
1648
|
-
it 'should have #enter' do
|
1649
|
-
mutex = Moneta::Mutex.new(store, 'mutex')
|
1650
|
-
mutex.enter.should be true
|
1651
|
-
mutex.locked?.should be true
|
1652
|
-
expect do
|
1653
|
-
mutex.enter
|
1654
|
-
end.to raise_error(RuntimeError)
|
1655
|
-
expect do
|
1656
|
-
mutex.try_enter
|
1657
|
-
end.to raise_error(RuntimeError)
|
1658
|
-
mutex.leave.should be_nil
|
1659
|
-
mutex.locked?.should be false
|
1660
|
-
end
|
1661
|
-
|
1662
|
-
it 'should lock with #lock' do
|
1663
|
-
a = Moneta::Mutex.new(store, 'mutex')
|
1664
|
-
b = Moneta::Mutex.new(store, 'mutex')
|
1665
|
-
a.lock.should be true
|
1666
|
-
b.try_lock.should be false
|
1667
|
-
a.unlock.should be_nil
|
1668
|
-
end
|
1669
|
-
|
1670
|
-
it 'should have lock timeout' do
|
1671
|
-
a = Moneta::Mutex.new(store, 'mutex')
|
1672
|
-
b = Moneta::Mutex.new(store, 'mutex')
|
1673
|
-
a.lock.should be true
|
1674
|
-
b.lock(1).should be false
|
1675
|
-
a.unlock.should be_nil
|
1676
|
-
end
|
1677
|
-
|
1678
|
-
it 'should have #synchronize' do
|
1679
|
-
mutex = Moneta::Mutex.new(store, 'mutex')
|
1680
|
-
mutex.synchronize do
|
1681
|
-
mutex.locked?.should be true
|
1682
|
-
end
|
1683
|
-
mutex.locked?.should be false
|
1684
|
-
end
|
1685
|
-
}
|
1686
|
-
},
|
1687
|
-
'semaphore' => {
|
1688
|
-
store: :Memory,
|
1689
|
-
specs: Specs.new,
|
1690
|
-
tests: %{
|
1691
|
-
it 'should have #lock' do
|
1692
|
-
mutex = Moneta::Semaphore.new(store, 'semaphore')
|
1693
|
-
mutex.lock.should be true
|
1694
|
-
mutex.locked?.should be true
|
1695
|
-
expect do
|
1696
|
-
mutex.lock
|
1697
|
-
end.to raise_error(RuntimeError)
|
1698
|
-
expect do
|
1699
|
-
mutex.try_lock
|
1700
|
-
end.to raise_error(RuntimeError)
|
1701
|
-
mutex.unlock.should be_nil
|
1702
|
-
mutex.locked?.should be false
|
1703
|
-
end
|
1704
|
-
|
1705
|
-
it 'should have #enter' do
|
1706
|
-
mutex = Moneta::Semaphore.new(store, 'semaphore')
|
1707
|
-
mutex.enter.should be true
|
1708
|
-
mutex.locked?.should be true
|
1709
|
-
expect do
|
1710
|
-
mutex.enter
|
1711
|
-
end.to raise_error(RuntimeError)
|
1712
|
-
expect do
|
1713
|
-
mutex.try_enter
|
1714
|
-
end.to raise_error(RuntimeError)
|
1715
|
-
mutex.leave.should be_nil
|
1716
|
-
mutex.locked?.should be false
|
1717
|
-
end
|
1718
|
-
|
1719
|
-
it 'should lock with #lock' do
|
1720
|
-
a = Moneta::Semaphore.new(store, 'semaphore')
|
1721
|
-
b = Moneta::Semaphore.new(store, 'semaphore')
|
1722
|
-
a.lock.should be true
|
1723
|
-
b.try_lock.should be false
|
1724
|
-
a.unlock.should be_nil
|
1725
|
-
end
|
1726
|
-
|
1727
|
-
it 'should have lock timeout' do
|
1728
|
-
a = Moneta::Semaphore.new(store, 'semaphore')
|
1729
|
-
b = Moneta::Semaphore.new(store, 'semaphore')
|
1730
|
-
a.lock.should be true
|
1731
|
-
b.lock(1).should be false
|
1732
|
-
a.unlock.should be_nil
|
1733
|
-
end
|
1734
|
-
|
1735
|
-
it 'should count concurrent accesses' do
|
1736
|
-
a = Moneta::Semaphore.new(store, 'semaphore', 2)
|
1737
|
-
b = Moneta::Semaphore.new(store, 'semaphore', 2)
|
1738
|
-
c = Moneta::Semaphore.new(store, 'semaphore', 2)
|
1739
|
-
a.synchronize do
|
1740
|
-
a.locked?.should be true
|
1741
|
-
b.synchronize do
|
1742
|
-
b.locked?.should be true
|
1743
|
-
c.try_lock.should be false
|
1744
|
-
end
|
1745
|
-
end
|
1746
|
-
end
|
1747
|
-
|
1748
|
-
it 'should have #synchronize' do
|
1749
|
-
semaphore = Moneta::Semaphore.new(store, 'semaphore')
|
1750
|
-
semaphore.synchronize do
|
1751
|
-
semaphore.locked?.should be true
|
1752
|
-
end
|
1753
|
-
semaphore.locked?.should be false
|
1754
|
-
end
|
1755
|
-
}
|
1756
|
-
},
|
1757
|
-
'optionmerger' => {
|
1758
|
-
store: :Memory,
|
1759
|
-
specs: Specs.new,
|
1760
|
-
tests: %{
|
1761
|
-
it '#with should return OptionMerger' do
|
1762
|
-
options = {optionname: :optionvalue}
|
1763
|
-
merger = store.with(options)
|
1764
|
-
merger.should be_instance_of(Moneta::OptionMerger)
|
1765
|
-
end
|
1766
|
-
|
1767
|
-
it 'saves default options' do
|
1768
|
-
options = {optionname: :optionvalue}
|
1769
|
-
merger = store.with(options)
|
1770
|
-
Moneta::OptionMerger::METHODS.each do |method|
|
1771
|
-
merger.default_options[method].should equal(options)
|
1772
|
-
end
|
1773
|
-
end
|
1774
|
-
|
1775
|
-
PREFIX = [['alpha', nil], ['beta', nil], ['alpha', 'beta']]
|
1776
|
-
|
1777
|
-
it 'merges options' do
|
1778
|
-
merger = store.with(opt1: :val1, opt2: :val2).with(opt2: :overwrite, opt3: :val3)
|
1779
|
-
Moneta::OptionMerger::METHODS.each do |method|
|
1780
|
-
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3}
|
1781
|
-
end
|
1782
|
-
end
|
1783
|
-
|
1784
|
-
it 'merges options only for some methods' do
|
1785
|
-
PREFIX.each do |(alpha,beta)|
|
1786
|
-
options = {opt1: :val1, opt2: :val2, prefix: alpha}
|
1787
|
-
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, only: :clear)
|
1788
|
-
(Moneta::OptionMerger::METHODS - [:clear]).each do |method|
|
1789
|
-
merger.default_options[method].should equal(options)
|
1790
|
-
end
|
1791
|
-
merger.default_options[:clear].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
1792
|
-
|
1793
|
-
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, only: [:load, :store])
|
1794
|
-
(Moneta::OptionMerger::METHODS - [:load, :store]).each do |method|
|
1795
|
-
merger.default_options[method].should equal(options)
|
1796
|
-
end
|
1797
|
-
merger.default_options[:load].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
1798
|
-
merger.default_options[:store].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
1799
|
-
end
|
1800
|
-
end
|
1801
|
-
|
1802
|
-
it 'merges options except for some methods' do
|
1803
|
-
PREFIX.each do |(alpha,beta)|
|
1804
|
-
options = {opt1: :val1, opt2: :val2, prefix: alpha}
|
1805
|
-
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, except: :clear, prefix: beta)
|
1806
|
-
(Moneta::OptionMerger::METHODS - [:clear]).each do |method|
|
1807
|
-
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
1808
|
-
end
|
1809
|
-
merger.default_options[:clear].should equal(options)
|
1810
|
-
|
1811
|
-
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, except: [:load, :store])
|
1812
|
-
(Moneta::OptionMerger::METHODS - [:load, :store]).each do |method|
|
1813
|
-
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
1814
|
-
end
|
1815
|
-
merger.default_options[:load].should equal(options)
|
1816
|
-
merger.default_options[:store].should equal(options)
|
1817
|
-
end
|
1818
|
-
end
|
1819
|
-
|
1820
|
-
it 'has method #raw' do
|
1821
|
-
store.raw.default_options.should == {store:{raw:true},create:{raw:true},load:{raw:true},delete:{raw:true}}
|
1822
|
-
store.raw.should equal(store.raw.raw)
|
1823
|
-
end
|
1824
|
-
|
1825
|
-
it 'has method #expires' do
|
1826
|
-
store.expires(10).default_options.should == {store:{expires:10},create:{expires:10},increment:{expires:10}}
|
1827
|
-
end
|
1828
|
-
|
1829
|
-
it 'has method #prefix' do
|
1830
|
-
store.prefix('a').default_options.should == {store:{prefix:'a'},load:{prefix:'a'},create:{prefix:'a'},
|
1831
|
-
delete:{prefix:'a'},key?: {prefix:'a'},increment:{prefix:'a'}}
|
1832
|
-
|
1833
|
-
store.prefix('a').prefix('b').default_options.should == {store:{prefix:'ab'},load:{prefix:'ab'},create:{prefix:'ab'},
|
1834
|
-
delete:{prefix:'ab'},key?: {prefix:'ab'},increment:{prefix:'ab'}}
|
1835
|
-
|
1836
|
-
store.raw.prefix('b').default_options.should == {store:{raw:true,prefix:'b'},load:{raw:true,prefix:'b'},create:{raw:true,prefix:'b'},delete:{raw:true,prefix:'b'},key?: {prefix:'b'},increment:{prefix:'b'}}
|
1837
|
-
|
1838
|
-
store.prefix('a').raw.default_options.should == {store:{raw:true,prefix:'a'},load:{raw:true,prefix:'a'},create:{raw:true,prefix:'a'},delete:{raw:true,prefix:'a'},key?: {prefix:'a'},increment:{prefix:'a'}}
|
1839
|
-
end
|
1840
|
-
|
1841
|
-
it 'supports adding proxis using #with' do
|
1842
|
-
compressed_store = store.with(prefix: 'compressed') do
|
1843
|
-
use :Transformer, value: :zlib
|
1844
|
-
end
|
1845
|
-
store['key'] = 'uncompressed value'
|
1846
|
-
compressed_store['key'] = 'compressed value'
|
1847
|
-
store['key'].should == 'uncompressed value'
|
1848
|
-
compressed_store['key'].should == 'compressed value'
|
1849
|
-
store.key?('compressedkey').should be true
|
1850
|
-
# Check if value is compressed
|
1851
|
-
compressed_store['key'].should_not == store['compressedkey']
|
1852
|
-
end}
|
1853
|
-
},
|
1854
|
-
}
|
1855
|
-
|
1856
|
-
SPECS = {}
|
1857
|
-
|
1858
|
-
KEYS = {
|
1859
|
-
'nil' => ['nil', 0],
|
1860
|
-
'integer' => [-10, 42],
|
1861
|
-
'number' => [0.5, -0.3, 1<<127, 99],
|
1862
|
-
'boolean' => [true, false],
|
1863
|
-
'string' => %w(strkey1 strkey2).map(&:inspect),
|
1864
|
-
'path' => %w(bar/foo/baz foo/bar).map(&:inspect),
|
1865
|
-
'binary' => ["\xC3\xBCber", "\xAA\xBB\xCC"].map(&:inspect),
|
1866
|
-
'object' => ['Value.new(:objkey1)', 'Value.new(:objkey2)'],
|
1867
|
-
'hash' => [{'hashkey1' => 'hashkey2'}, {'hashkey3' => 'hashkey4'}].map(&:inspect)
|
1868
|
-
}
|
1869
|
-
|
1870
|
-
VALUES = {
|
1871
|
-
'nil' => ["''", 'nil', 0, false],
|
1872
|
-
'integer' => [41, -12],
|
1873
|
-
'number' => [123.456, -98.7, 1<<128, 33],
|
1874
|
-
'boolean' => [true, false],
|
1875
|
-
'string' => %w(strval1 strval2).map(&:inspect),
|
1876
|
-
'binary' => ["\xC3\xBCber", "\xAA\xBB\xCC"].map(&:inspect),
|
1877
|
-
'hash' => [{'hashval1' => ['array1', 1]}, {'hashval3' => ['array2', {'hashval4' => 42}]}].map(&:inspect),
|
1878
|
-
'object' => ['Value.new(:objval1)', 'Value.new(:objval2)'],
|
1879
|
-
}
|
1880
|
-
|
1881
|
-
KEYS.each do |key_type, keys|
|
1882
|
-
VALUES.each do |val_type, vals|
|
1883
|
-
(keys.size/2).times do |k|
|
1884
|
-
keypair = keys[2*k,2]
|
1885
|
-
(vals.size/2).times do |v|
|
1886
|
-
valpair = vals[2*v,2]
|
1887
|
-
4.times do |i|
|
1888
|
-
key1, key2 = i % 2 == 0 ? keypair : keypair.reverse
|
1889
|
-
val1, val2 = i < 2 ? valpair : valpair.reverse
|
1890
|
-
|
1891
|
-
code = %{it 'reads from keys like a Hash' do
|
1892
|
-
store[#{key1}].should be_nil
|
1893
|
-
store.load(#{key1}).should be_nil
|
1894
|
-
end
|
1895
|
-
|
1896
|
-
it 'guarantees that the same value is returned when setting a key' do
|
1897
|
-
value = #{val1}
|
1898
|
-
(store[#{key1}] = value).should equal(value)
|
1899
|
-
end
|
1900
|
-
|
1901
|
-
it 'returns false from #key? if a key is not available' do
|
1902
|
-
store.key?(#{key1}).should be false
|
1903
|
-
end
|
1904
|
-
|
1905
|
-
it 'returns nil from delete if a value for a key does not exist' do
|
1906
|
-
store.delete(#{key1}).should be_nil
|
1907
|
-
end
|
1908
|
-
|
1909
|
-
it 'removes all keys from the store with clear' do
|
1910
|
-
store[#{key1}] = #{val1}
|
1911
|
-
store[#{key2}] = #{val2}
|
1912
|
-
store.clear.should equal(store)
|
1913
|
-
store.key?(#{key1}).should be false
|
1914
|
-
store.key?(#{key2}).should be false
|
1915
|
-
end
|
1916
|
-
|
1917
|
-
it 'fetches a key with a default value with fetch, if the key is not available' do
|
1918
|
-
store.fetch(#{key1}, #{val1}).should == #{val1}
|
1919
|
-
end
|
1920
|
-
|
1921
|
-
it 'fetches a key with a block with fetch, if the key is not available' do
|
1922
|
-
key = #{key1}
|
1923
|
-
value = #{val1}
|
1924
|
-
store.fetch(key) do |k|
|
1925
|
-
k.should equal(key)
|
1926
|
-
value
|
1927
|
-
end.should equal(value)
|
1928
|
-
end
|
1929
|
-
|
1930
|
-
it 'accepts frozen options' do
|
1931
|
-
options = {option1: 1, options2: 2}
|
1932
|
-
options.freeze
|
1933
|
-
store.key?(#{key1}, options).should be false
|
1934
|
-
store.load(#{key1}, options).should be_nil
|
1935
|
-
store.fetch(#{key1}, 42, options).should == 42
|
1936
|
-
store.fetch(#{key1}, options) { 42 }.should == 42
|
1937
|
-
store.delete(#{key1}, options).should be_nil
|
1938
|
-
store.clear(options).should equal(store)
|
1939
|
-
store.store(#{key1}, #{val1}, options).should == #{val1}
|
1940
|
-
end}
|
1941
|
-
(SPECS["null_#{key_type}key_#{val_type}value"] ||= []) << code
|
1942
|
-
|
1943
|
-
code = %{it 'writes values to keys that like a Hash' do
|
1944
|
-
store[#{key1}] = #{val1}
|
1945
|
-
store[#{key1}].should == #{val1}
|
1946
|
-
store.load(#{key1}).should == #{val1}
|
1947
|
-
end
|
1948
|
-
|
1949
|
-
it 'returns true from #key? if a key is available' do
|
1950
|
-
store[#{key1}] = #{val1}
|
1951
|
-
store.key?(#{key1}).should be true
|
1952
|
-
end
|
1953
|
-
|
1954
|
-
it 'stores values with #store' do
|
1955
|
-
value = #{val1}
|
1956
|
-
store.store(#{key1}, value).should equal(value)
|
1957
|
-
store[#{key1}].should == #{val1}
|
1958
|
-
store.load(#{key1}).should == #{val1}
|
1959
|
-
end
|
1960
|
-
|
1961
|
-
it 'stores values after clear' do
|
1962
|
-
store[#{key1}] = #{val1}
|
1963
|
-
store[#{key2}] = #{val2}
|
1964
|
-
store.clear.should equal(store)
|
1965
|
-
store[#{key1}] = #{val1}
|
1966
|
-
store[#{key1}].should == #{val1}
|
1967
|
-
store[#{key2}].should be_nil
|
1968
|
-
end
|
1969
|
-
|
1970
|
-
it 'removes and returns a value from the backing store via delete if it exists' do
|
1971
|
-
store[#{key1}] = #{val1}
|
1972
|
-
store.delete(#{key1}).should == #{val1}
|
1973
|
-
store.key?(#{key1}).should be false
|
1974
|
-
end
|
1975
|
-
|
1976
|
-
it 'overwrites existing values' do
|
1977
|
-
store[#{key1}] = #{val1}
|
1978
|
-
store[#{key1}].should == #{val1}
|
1979
|
-
store[#{key1}] = #{val2}
|
1980
|
-
store[#{key1}].should == #{val2}
|
1981
|
-
end
|
1982
|
-
|
1983
|
-
it 'stores frozen values' do
|
1984
|
-
value = #{val1}.freeze
|
1985
|
-
(store[#{key1}] = value).should equal(value)
|
1986
|
-
store[#{key1}].should == #{val1}
|
1987
|
-
end
|
1988
|
-
|
1989
|
-
it 'stores frozen keys' do
|
1990
|
-
key = #{key1}.freeze
|
1991
|
-
store[key] = #{val1}
|
1992
|
-
store[#{key1}].should == #{val1}
|
1993
|
-
end}
|
1994
|
-
|
1995
|
-
if val_type != 'nil'
|
1996
|
-
code << %{
|
1997
|
-
it 'fetches a key with a default value with fetch, if the key is available' do
|
1998
|
-
store[#{key1}] = #{val1}
|
1999
|
-
store.fetch(#{key1}, #{val2}).should == #{val1}
|
2000
|
-
end
|
2001
|
-
|
2002
|
-
it 'does not run the block in fetch if the key is available' do
|
2003
|
-
store[#{key1}] = #{val1}
|
2004
|
-
unaltered = 'unaltered'
|
2005
|
-
store.fetch(#{key1}) { unaltered = 'altered' }
|
2006
|
-
unaltered.should == 'unaltered'
|
2007
|
-
end}
|
2008
|
-
end
|
2009
|
-
|
2010
|
-
(SPECS["store_#{key_type}key_#{val_type}value"] ||= []) << code
|
2011
|
-
|
2012
|
-
if val_type != 'boolean' && val_type != 'nil' && val_type != 'integer' && val_type != 'number'
|
2013
|
-
(SPECS["returndifferent_#{key_type}key_#{val_type}value"] ||= []) << %{it 'guarantees that a different value is retrieved' do
|
2014
|
-
value = #{val1}
|
2015
|
-
store[#{key1}] = value
|
2016
|
-
store[#{key1}].should_not be_equal(value)
|
2017
|
-
end}
|
2018
|
-
(SPECS["returnsame_#{key_type}key_#{val_type}value"] ||= []) << %{it 'guarantees that the same value is retrieved' do
|
2019
|
-
value = #{val1}
|
2020
|
-
store[#{key1}] = value
|
2021
|
-
store[#{key1}].should be_equal(value)
|
2022
|
-
end}
|
2023
|
-
end
|
2024
|
-
|
2025
|
-
code = %{it 'persists values' do
|
2026
|
-
store[#{key1}] = #{val1}
|
2027
|
-
store.close
|
2028
|
-
@store = nil
|
2029
|
-
store[#{key1}].should == #{val1}
|
2030
|
-
end}
|
2031
|
-
(SPECS["persist_#{key_type}key_#{val_type}value"] ||= []) << code
|
2032
|
-
end
|
2033
|
-
end
|
2034
|
-
end
|
2035
|
-
end
|
2036
|
-
end
|
2037
|
-
|
2038
|
-
SPECS['store_large'] = %{it 'should store values up to 32k' do
|
2039
|
-
value = 'x' * (32 * 1024)
|
2040
|
-
store['large'] = value
|
2041
|
-
store['large'].should == value
|
2042
|
-
end
|
2043
|
-
|
2044
|
-
it 'should store keys up to 128 bytes' do
|
2045
|
-
key = 'x' * 128
|
2046
|
-
store[key] = 'value'
|
2047
|
-
store[key].should == 'value'
|
2048
|
-
end}
|
2049
|
-
|
2050
|
-
SPECS['not_persist'] = %{it 'does not persist values' do
|
2051
|
-
store['key'] = 'val'
|
2052
|
-
store.close
|
2053
|
-
@store = nil
|
2054
|
-
|
2055
|
-
store['key'].should be_nil
|
2056
|
-
end}
|
2057
|
-
|
2058
|
-
SPECS['multiprocess'] = %{it 'supports access by multiple instances/processes' do
|
2059
|
-
store['key'] = 'val'
|
2060
|
-
store2 = new_store
|
2061
|
-
store2['key'].should == 'val'
|
2062
|
-
store2.close
|
2063
|
-
end}
|
2064
|
-
|
2065
|
-
SPECS['expires'] = %{it 'supports expires on store and []', retry: 3 do
|
2066
|
-
store.store('key1', 'val1', expires: 3)
|
2067
|
-
store['key1'].should == 'val1'
|
2068
|
-
sleep 1
|
2069
|
-
store['key1'].should == 'val1'
|
2070
|
-
sleep 3
|
2071
|
-
store['key1'].should be_nil
|
2072
|
-
end
|
2073
|
-
|
2074
|
-
it 'supports strict expires on store and []' do
|
2075
|
-
store.store('key1', 'val1', expires: 2)
|
2076
|
-
store['key1'].should == 'val1'
|
2077
|
-
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
2078
|
-
store['key1'].should be_nil
|
2079
|
-
end
|
2080
|
-
|
2081
|
-
it 'supports expires on store and fetch', retry: 3 do
|
2082
|
-
store.store('key1', 'val1', expires: 3)
|
2083
|
-
store.fetch('key1').should == 'val1'
|
2084
|
-
sleep 1
|
2085
|
-
store.fetch('key1').should == 'val1'
|
2086
|
-
sleep 3
|
2087
|
-
store.fetch('key1').should be_nil
|
2088
|
-
end
|
2089
|
-
|
2090
|
-
it 'supports strict expires on store and fetch' do
|
2091
|
-
store.store('key1', 'val1', expires: 2)
|
2092
|
-
store.fetch('key1').should == 'val1'
|
2093
|
-
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
2094
|
-
store.fetch('key1').should be_nil
|
2095
|
-
end
|
2096
|
-
|
2097
|
-
it 'supports 0 as no-expires on store and []' do
|
2098
|
-
store.store('key1', 'val1', expires: 0)
|
2099
|
-
store['key1'].should == 'val1'
|
2100
|
-
sleep 2
|
2101
|
-
store['key1'].should == 'val1'
|
2102
|
-
end
|
2103
|
-
|
2104
|
-
it 'supports false as no-expires on store and []' do
|
2105
|
-
store.store('key1', 'val1', expires: false)
|
2106
|
-
store['key1'].should == 'val1'
|
2107
|
-
sleep 2
|
2108
|
-
store['key1'].should == 'val1'
|
2109
|
-
end
|
2110
|
-
|
2111
|
-
it 'supports expires on store and load', retry: 3 do
|
2112
|
-
store.store('key1', 'val1', expires: 3)
|
2113
|
-
store.load('key1').should == 'val1'
|
2114
|
-
sleep 1
|
2115
|
-
store.load('key1').should == 'val1'
|
2116
|
-
sleep 3
|
2117
|
-
store.load('key1').should be_nil
|
2118
|
-
end
|
2119
|
-
|
2120
|
-
it 'supports strict expires on store and load' do
|
2121
|
-
store.store('key1', 'val1', expires: 2)
|
2122
|
-
store.load('key1').should == 'val1'
|
2123
|
-
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
2124
|
-
store.load('key1').should be_nil
|
2125
|
-
end
|
2126
|
-
|
2127
|
-
it 'supports expires on store and #key?', retry: 3 do
|
2128
|
-
store.store('key1', 'val1', expires: 3)
|
2129
|
-
store.key?('key1').should be true
|
2130
|
-
sleep 1
|
2131
|
-
store.key?('key1').should be true
|
2132
|
-
sleep 3
|
2133
|
-
store.key?('key1').should be false
|
2134
|
-
end
|
2135
|
-
|
2136
|
-
it 'supports strict expires on store and #key?' do
|
2137
|
-
store.store('key1', 'val1', expires: 2)
|
2138
|
-
store.key?('key1').should be true
|
2139
|
-
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
2140
|
-
store.key?('key1').should be false
|
2141
|
-
end
|
2142
|
-
|
2143
|
-
it 'supports updating the expiration time in load', retry: 3 do
|
2144
|
-
store.store('key2', 'val2', expires: 3)
|
2145
|
-
store['key2'].should == 'val2'
|
2146
|
-
sleep 1
|
2147
|
-
store.load('key2', expires: 5).should == 'val2'
|
2148
|
-
store['key2'].should == 'val2'
|
2149
|
-
sleep 3
|
2150
|
-
store['key2'].should == 'val2'
|
2151
|
-
sleep 3
|
2152
|
-
store['key2'].should be_nil
|
2153
|
-
end
|
2154
|
-
|
2155
|
-
it 'supports 0 as no-expires in load' do
|
2156
|
-
store.store('key1', 'val1', expires: 2)
|
2157
|
-
store.load('key1', expires: 0).should == 'val1'
|
2158
|
-
sleep 3
|
2159
|
-
store.load('key1').should == 'val1'
|
2160
|
-
end
|
2161
|
-
|
2162
|
-
it 'supports false as no-expires in load' do
|
2163
|
-
store.store('key1', 'val1', expires: 2)
|
2164
|
-
store.load('key1', expires: false).should == 'val1'
|
2165
|
-
sleep 3
|
2166
|
-
store.load('key1').should == 'val1'
|
2167
|
-
end
|
2168
|
-
|
2169
|
-
it 'supports updating the expiration time in #key?', retry: 3 do
|
2170
|
-
store.store('key2', 'val2', expires: 3)
|
2171
|
-
store['key2'].should == 'val2'
|
2172
|
-
sleep 1
|
2173
|
-
store.key?('key2', expires: 5).should be true
|
2174
|
-
store['key2'].should == 'val2'
|
2175
|
-
sleep 3
|
2176
|
-
store['key2'].should == 'val2'
|
2177
|
-
sleep 3
|
2178
|
-
store['key2'].should be_nil
|
2179
|
-
end
|
2180
|
-
|
2181
|
-
it 'supports 0 as no-expires in #key?' do
|
2182
|
-
store.store('key1', 'val1', expires: 2)
|
2183
|
-
store.key?('key1', expires: 0).should be true
|
2184
|
-
sleep 3
|
2185
|
-
store['key1'].should == 'val1'
|
2186
|
-
end
|
2187
|
-
|
2188
|
-
it 'supports false as no-expires in #key?' do
|
2189
|
-
store.store('key1', 'val1', expires: 2)
|
2190
|
-
store.key?('key1', expires: false ).should be true
|
2191
|
-
sleep 3
|
2192
|
-
store['key1'].should == 'val1'
|
2193
|
-
end
|
2194
|
-
|
2195
|
-
it 'supports updating the expiration time in fetch', retry: 3 do
|
2196
|
-
store.store('key1', 'val1', expires: 3)
|
2197
|
-
store['key1'].should == 'val1'
|
2198
|
-
sleep 1
|
2199
|
-
store.fetch('key1', nil, expires: 5).should == 'val1'
|
2200
|
-
store['key1'].should == 'val1'
|
2201
|
-
sleep 3
|
2202
|
-
store['key1'].should == 'val1'
|
2203
|
-
sleep 3
|
2204
|
-
store['key1'].should be_nil
|
2205
|
-
end
|
2206
|
-
|
2207
|
-
it 'supports 0 as no-expires in fetch' do
|
2208
|
-
store.store('key1', 'val1', expires: 2)
|
2209
|
-
store.fetch('key1', nil, expires: 0).should == 'val1'
|
2210
|
-
sleep 3
|
2211
|
-
store.load('key1').should == 'val1'
|
2212
|
-
end
|
2213
|
-
|
2214
|
-
it 'supports false as no-expires in fetch' do
|
2215
|
-
store.store('key1', 'val1', expires: 2)
|
2216
|
-
store.fetch('key1', nil, expires: false).should == 'val1'
|
2217
|
-
sleep 3
|
2218
|
-
store.load('key1').should == 'val1'
|
2219
|
-
end
|
2220
|
-
|
2221
|
-
it 'strictly respects expires in delete' do
|
2222
|
-
store.store('key2', 'val2', expires: 2)
|
2223
|
-
store['key2'].should == 'val2'
|
2224
|
-
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
2225
|
-
store.delete('key2').should be_nil
|
2226
|
-
end
|
2227
|
-
|
2228
|
-
it 'respects expires in delete', retry: 3 do
|
2229
|
-
store.store('key2', 'val2', expires: 3)
|
2230
|
-
store['key2'].should == 'val2'
|
2231
|
-
sleep 1
|
2232
|
-
store['key2'].should == 'val2'
|
2233
|
-
sleep 3
|
2234
|
-
store.delete('key2').should be_nil
|
2235
|
-
end
|
2236
|
-
|
2237
|
-
it 'supports the #expires syntactic sugar', retry: 3 do
|
2238
|
-
store.store('persistent_key', 'persistent_value', expires: 0)
|
2239
|
-
store.expires(1).store('key2', 'val2')
|
2240
|
-
store['key2'].should == 'val2'
|
2241
|
-
sleep 2
|
2242
|
-
store.delete('key2').should be_nil
|
2243
|
-
store['persistent_key'].should == 'persistent_value'
|
2244
|
-
end
|
2245
|
-
|
2246
|
-
it 'supports false as no-expires on store and []' do
|
2247
|
-
store.store('key1', 'val1', expires: false)
|
2248
|
-
store['key1'].should == 'val1'
|
2249
|
-
sleep 2
|
2250
|
-
store['key1'].should == 'val1'
|
2251
|
-
end
|
2252
|
-
|
2253
|
-
it 'does not update the expiration time in #key? when not asked to do so', retry: 3 do
|
2254
|
-
store.store('key1', 'val1', expires: 1)
|
2255
|
-
store.key?('key1').should be true
|
2256
|
-
store.key?('key1', expires: nil).should be true
|
2257
|
-
sleep 2
|
2258
|
-
store.key?('key1').should be false
|
2259
|
-
end
|
2260
|
-
|
2261
|
-
it 'does not update the expiration time in fetch when not asked to do so', retry: 3 do
|
2262
|
-
store.store('key1', 'val1', expires: 1)
|
2263
|
-
store.fetch('key1').should == 'val1'
|
2264
|
-
store.fetch('key1', expires: nil).should == 'val1'
|
2265
|
-
sleep 2
|
2266
|
-
store.fetch('key1').should be_nil
|
2267
|
-
end
|
2268
|
-
|
2269
|
-
it 'does not update the expiration time in load when not asked to do so', retry: 3 do
|
2270
|
-
store.store('key1', 'val1', expires: 1)
|
2271
|
-
store.load('key1').should == 'val1'
|
2272
|
-
store.load('key1', expires: nil).should == 'val1'
|
2273
|
-
sleep 2
|
2274
|
-
store.load('key1').should be_nil
|
2275
|
-
end}
|
2276
|
-
|
2277
|
-
SPECS['default_expires'] = %{it 'does set default expiration time' do
|
2278
|
-
store['key1'] = 'val1'
|
2279
|
-
store.key?('key1').should be true
|
2280
|
-
store.fetch('key1').should == 'val1'
|
2281
|
-
store.load('key1').should == 'val1'
|
2282
|
-
sleep 2
|
2283
|
-
store.key?('key1').should be false
|
2284
|
-
store.fetch('key1').should be_nil
|
2285
|
-
store.load('key1').should be_nil
|
2286
|
-
end}
|
2287
|
-
|
2288
|
-
SPECS['not_increment'] = %{it 'does not support #increment' do
|
2289
|
-
expect do
|
2290
|
-
store.increment('inckey')
|
2291
|
-
end.to raise_error(NotImplementedError)
|
2292
|
-
end
|
2293
|
-
|
2294
|
-
it 'does not support #decrement' do
|
2295
|
-
expect do
|
2296
|
-
store.increment('inckey')
|
2297
|
-
end.to raise_error(NotImplementedError)
|
2298
|
-
end}
|
2299
|
-
|
2300
|
-
SPECS['concurrent_increment'] = %{def increment_thread(name)
|
2301
|
-
Thread.new do
|
2302
|
-
s = new_store
|
2303
|
-
100.times do |i|
|
2304
|
-
100.times do |j|
|
2305
|
-
s.increment("counter\#{j}", 1, expires: false)
|
2306
|
-
Thread.pass if rand(1000) >= 995
|
2307
|
-
end
|
2308
|
-
s.store("\#{name}\#{i}", i.to_s, expires: false)
|
2309
|
-
end
|
2310
|
-
s.close
|
2311
|
-
end
|
2312
|
-
end
|
2313
|
-
|
2314
|
-
it 'have atomic increment across multiple processes' do
|
2315
|
-
a = increment_thread('a')
|
2316
|
-
b = increment_thread('b')
|
2317
|
-
c = increment_thread('c')
|
2318
|
-
a.join
|
2319
|
-
b.join
|
2320
|
-
c.join
|
2321
|
-
100.times do |i|
|
2322
|
-
store["a\#{i}"].should == i.to_s
|
2323
|
-
store["b\#{i}"].should == i.to_s
|
2324
|
-
store["c\#{i}"].should == i.to_s
|
2325
|
-
end
|
2326
|
-
100.times do |j|
|
2327
|
-
store.raw["counter\#{j}"].should == 300.to_s
|
2328
|
-
end
|
2329
|
-
end}
|
2330
|
-
|
2331
|
-
SPECS['concurrent_create'] = %{def create_thread(name)
|
2332
|
-
Thread.new do
|
2333
|
-
s = new_store
|
2334
|
-
1000.times do |i|
|
2335
|
-
s[i.to_s].should == name if s.create(i.to_s, name, expires: false)
|
2336
|
-
Thread.pass if rand(100) >= 99
|
2337
|
-
end
|
2338
|
-
s.close
|
2339
|
-
end
|
2340
|
-
end
|
2341
|
-
|
2342
|
-
it 'have atomic create across multiple processes' do
|
2343
|
-
a = create_thread('a')
|
2344
|
-
b = create_thread('b')
|
2345
|
-
c = create_thread('c')
|
2346
|
-
a.join
|
2347
|
-
b.join
|
2348
|
-
c.join
|
2349
|
-
end}
|
2350
|
-
|
2351
|
-
SPECS['increment'] = %{it 'initializes in #increment with 1' do
|
2352
|
-
store.key?('inckey').should be false
|
2353
|
-
store.increment('inckey').should == 1
|
2354
|
-
store.key?('inckey').should be true
|
2355
|
-
store.raw['inckey'].should == '1'
|
2356
|
-
store.raw.load('inckey').should == '1'
|
2357
|
-
store.load('inckey', raw: true).should == '1'
|
2358
|
-
|
2359
|
-
store.delete('inckey', raw: true).should == '1'
|
2360
|
-
store.key?('inckey').should be false
|
2361
|
-
end
|
2362
|
-
|
2363
|
-
it 'initializes in #increment with higher value' do
|
2364
|
-
store.increment('inckey', 42).should == 42
|
2365
|
-
store.key?('inckey').should be true
|
2366
|
-
store.raw['inckey'].should == '42'
|
2367
|
-
store.delete('inckey', raw: true).should == '42'
|
2368
|
-
end
|
2369
|
-
|
2370
|
-
it 'initializes in #increment with 0' do
|
2371
|
-
store.increment('inckey', 0).should == 0
|
2372
|
-
store.key?('inckey').should be true
|
2373
|
-
store.raw['inckey'].should == '0'
|
2374
|
-
store.delete('inckey', raw: true).should == '0'
|
2375
|
-
end
|
2376
|
-
|
2377
|
-
it 'initializes in #decrement with 0' do
|
2378
|
-
store.decrement('inckey', 0).should == 0
|
2379
|
-
store.raw['inckey'].should == '0'
|
2380
|
-
end
|
2381
|
-
|
2382
|
-
it 'initializes in #decrement with negative value' do
|
2383
|
-
store.decrement('inckey', -42).should == 42
|
2384
|
-
store.raw['inckey'].should == '42'
|
2385
|
-
end
|
2386
|
-
|
2387
|
-
it 'supports incrementing existing value by value' do
|
2388
|
-
store.increment('inckey').should == 1
|
2389
|
-
store.increment('inckey', 42).should == 43
|
2390
|
-
store.raw['inckey'].should == '43'
|
2391
|
-
end
|
2392
|
-
|
2393
|
-
it 'supports decrementing existing value by value' do
|
2394
|
-
store.increment('inckey').should == 1
|
2395
|
-
store.decrement('inckey').should == 0
|
2396
|
-
store.increment('inckey', 42).should == 42
|
2397
|
-
store.decrement('inckey', 2).should == 40
|
2398
|
-
store.raw['inckey'].should == '40'
|
2399
|
-
end
|
2400
|
-
|
2401
|
-
it 'supports incrementing existing value by 0' do
|
2402
|
-
store.increment('inckey').should == 1
|
2403
|
-
store.increment('inckey', 0).should == 1
|
2404
|
-
store.raw['inckey'].should == '1'
|
2405
|
-
end
|
2406
|
-
|
2407
|
-
it 'supports decrementing existing value' do
|
2408
|
-
store.increment('inckey', 10).should == 10
|
2409
|
-
store.increment('inckey', -5).should == 5
|
2410
|
-
store.raw['inckey'].should == '5'
|
2411
|
-
store.increment('inckey', -5).should == 0
|
2412
|
-
store.raw['inckey'].should == '0'
|
2413
|
-
end
|
2414
|
-
|
2415
|
-
it 'interprets raw value as integer' do
|
2416
|
-
store.store('inckey', '42', raw: true)
|
2417
|
-
store.increment('inckey').should == 43
|
2418
|
-
store.raw['inckey'].should == '43'
|
2419
|
-
end
|
2420
|
-
|
2421
|
-
it 'raises error in #increment on non integer value' do
|
2422
|
-
store['strkey'] = 'value'
|
2423
|
-
expect do
|
2424
|
-
store.increment('strkey')
|
2425
|
-
end.to raise_error
|
2426
|
-
end
|
2427
|
-
|
2428
|
-
it 'raises error in #decrement on non integer value' do
|
2429
|
-
store['strkey'] = 'value'
|
2430
|
-
expect do
|
2431
|
-
store.decrement('strkey')
|
2432
|
-
end.to raise_error
|
2433
|
-
end
|
2434
|
-
|
2435
|
-
it 'supports Semaphore' do
|
2436
|
-
a = Moneta::Semaphore.new(store, 'semaphore', 2)
|
2437
|
-
b = Moneta::Semaphore.new(store, 'semaphore', 2)
|
2438
|
-
c = Moneta::Semaphore.new(store, 'semaphore', 2)
|
2439
|
-
a.synchronize do
|
2440
|
-
a.locked?.should be true
|
2441
|
-
b.synchronize do
|
2442
|
-
b.locked?.should be true
|
2443
|
-
c.try_lock.should be false
|
2444
|
-
end
|
2445
|
-
end
|
2446
|
-
end
|
2447
|
-
}
|
2448
|
-
|
2449
|
-
SPECS['create'] = %{it 'creates the given key' do
|
2450
|
-
store.create('key','value').should be true
|
2451
|
-
store['key'].should == 'value'
|
2452
|
-
end
|
2453
|
-
|
2454
|
-
it 'creates raw value with the given key' do
|
2455
|
-
store.raw.create('key','value').should be true
|
2456
|
-
store.raw['key'].should == 'value'
|
2457
|
-
end
|
2458
|
-
|
2459
|
-
it 'does not create a key if it exists' do
|
2460
|
-
store['key'] = 'value'
|
2461
|
-
store.create('key','another value').should be false
|
2462
|
-
store['key'].should == 'value'
|
2463
|
-
end
|
2464
|
-
|
2465
|
-
it 'supports Mutex' do
|
2466
|
-
a = Moneta::Mutex.new(store, 'mutex')
|
2467
|
-
b = Moneta::Mutex.new(store, 'mutex')
|
2468
|
-
a.lock.should be true
|
2469
|
-
b.try_lock.should be false
|
2470
|
-
a.unlock.should be_nil
|
2471
|
-
end
|
2472
|
-
}
|
2473
|
-
|
2474
|
-
SPECS['not_create'] = %{it 'does not support #create' do
|
2475
|
-
expect do
|
2476
|
-
store.create('key','value')
|
2477
|
-
end.to raise_error(NotImplementedError)
|
2478
|
-
end}
|
2479
|
-
|
2480
|
-
SPECS['create_expires'] = %{it 'creates the given key and expires it' do
|
2481
|
-
store.create('key','value', expires: 1).should be true
|
2482
|
-
store['key'].should == 'value'
|
2483
|
-
sleep 2
|
2484
|
-
store.key?('key').should be false
|
2485
|
-
end
|
2486
|
-
|
2487
|
-
it 'does not change expires if the key exists' do
|
2488
|
-
store.store('key', 'value', expires: false).should == 'value'
|
2489
|
-
store.create('key','another value', expires: 1).should be false
|
2490
|
-
store['key'].should == 'value'
|
2491
|
-
sleep 2
|
2492
|
-
store['key'].should == 'value'
|
2493
|
-
store.key?('key').should be true
|
2494
|
-
end}
|
2495
|
-
|
2496
|
-
SPECS['marshallable_key'] = %{it 'refuses to #[] from keys that cannot be marshalled' do
|
2497
|
-
expect do
|
2498
|
-
store[Struct.new(:foo).new(:bar)]
|
2499
|
-
end.to raise_error(marshal_error)
|
2500
|
-
end
|
2501
|
-
|
2502
|
-
it 'refuses to load from keys that cannot be marshalled' do
|
2503
|
-
expect do
|
2504
|
-
store.load(Struct.new(:foo).new(:bar))
|
2505
|
-
end.to raise_error(marshal_error)
|
2506
|
-
end
|
2507
|
-
|
2508
|
-
it 'refuses to fetch from keys that cannot be marshalled' do
|
2509
|
-
expect do
|
2510
|
-
store.fetch(Struct.new(:foo).new(:bar), true)
|
2511
|
-
end.to raise_error(marshal_error)
|
2512
|
-
end
|
2513
|
-
|
2514
|
-
it 'refuses to #[]= to keys that cannot be marshalled' do
|
2515
|
-
expect do
|
2516
|
-
store[Struct.new(:foo).new(:bar)] = 'value'
|
2517
|
-
end.to raise_error(marshal_error)
|
2518
|
-
end
|
2519
|
-
|
2520
|
-
it 'refuses to store to keys that cannot be marshalled' do
|
2521
|
-
expect do
|
2522
|
-
store.store Struct.new(:foo).new(:bar), 'value'
|
2523
|
-
end.to raise_error(marshal_error)
|
2524
|
-
end
|
2525
|
-
|
2526
|
-
it 'refuses to check for #key? if the key cannot be marshalled' do
|
2527
|
-
expect do
|
2528
|
-
store.key? Struct.new(:foo).new(:bar)
|
2529
|
-
end.to raise_error(marshal_error)
|
2530
|
-
end
|
2531
|
-
|
2532
|
-
it 'refuses to delete a key if the key cannot be marshalled' do
|
2533
|
-
expect do
|
2534
|
-
store.delete Struct.new(:foo).new(:bar)
|
2535
|
-
end.to raise_error(marshal_error)
|
2536
|
-
end}
|
2537
|
-
|
2538
|
-
SPECS['marshallable_value'] = %{it 'refuses to store values that cannot be marshalled' do
|
2539
|
-
expect do
|
2540
|
-
store.store 'key', Struct.new(:foo).new(:bar)
|
2541
|
-
end.to raise_error(marshal_error)
|
2542
|
-
end}
|
2543
|
-
|
2544
|
-
SPECS['transform_value'] = %{it 'allows to bypass transformer with :raw' do
|
2545
|
-
store['key'] = 'value'
|
2546
|
-
load_value(store.load('key', raw: true)).should == 'value'
|
2547
|
-
|
2548
|
-
store.store('key', 'value', raw: true)
|
2549
|
-
store.load('key', raw: true).should == 'value'
|
2550
|
-
store.delete('key', raw: true).should == 'value'
|
2551
|
-
end
|
2552
|
-
|
2553
|
-
it 'allows to bypass transformer with raw syntactic sugar' do
|
2554
|
-
store['key'] = 'value'
|
2555
|
-
load_value(store.raw.load('key')).should == 'value'
|
2556
|
-
|
2557
|
-
store.raw.store('key', 'value')
|
2558
|
-
store.raw['key'].should == 'value'
|
2559
|
-
store.raw.load('key').should == 'value'
|
2560
|
-
store.raw.delete('key').should == 'value'
|
2561
|
-
|
2562
|
-
store.raw['key'] = 'value2'
|
2563
|
-
store.raw['key'].should == 'value2'
|
2564
|
-
end
|
2565
|
-
|
2566
|
-
it 'returns unmarshalled value' do
|
2567
|
-
store.store('key', 'unmarshalled value', raw: true)
|
2568
|
-
store.load('key', raw: true).should == 'unmarshalled value'
|
2569
|
-
end
|
2570
|
-
|
2571
|
-
it 'might raise exception on invalid value' do
|
2572
|
-
store.store('key', 'unmarshalled value', raw: true)
|
2573
|
-
|
2574
|
-
begin
|
2575
|
-
store['key'].should == load_value('unmarshalled value')
|
2576
|
-
store.delete('key').should == load_value('unmarshalled value')
|
2577
|
-
rescue Exception => ex
|
2578
|
-
expect do
|
2579
|
-
store['key']
|
2580
|
-
end.to raise_error
|
2581
|
-
expect do
|
2582
|
-
store.delete('key')
|
2583
|
-
end.to raise_error
|
2584
|
-
end
|
2585
|
-
end}
|
2586
|
-
|
2587
|
-
SPECS['transform_value_expires'] = %{it 'allows to bypass transformer with :raw' do
|
2588
|
-
store['key'] = 'value'
|
2589
|
-
load_value(store.load('key', raw: true)).should == 'value'
|
2590
|
-
store['key'] = [1,2,3]
|
2591
|
-
load_value(store.load('key', raw: true)).should == [[1,2,3]]
|
2592
|
-
store['key'] = nil
|
2593
|
-
load_value(store.load('key', raw: true)).should == [nil]
|
2594
|
-
store['key'] = false
|
2595
|
-
load_value(store.load('key', raw: true)).should be false
|
2596
|
-
|
2597
|
-
store.store('key', 'value', expires: 10)
|
2598
|
-
load_value(store.load('key', raw: true)).first.should == 'value'
|
2599
|
-
load_value(store.load('key', raw: true)).last.should respond_to(:to_int)
|
2600
|
-
|
2601
|
-
store.store('key', 'value', raw: true)
|
2602
|
-
store.load('key', raw: true).should == 'value'
|
2603
|
-
store.delete('key', raw: true).should == 'value'
|
2604
|
-
end
|
2605
|
-
|
2606
|
-
it 'returns unmarshalled value' do
|
2607
|
-
store.store('key', 'unmarshalled value', raw: true)
|
2608
|
-
store.load('key', raw: true).should == 'unmarshalled value'
|
2609
|
-
end
|
2610
|
-
|
2611
|
-
it 'might raise exception on invalid value' do
|
2612
|
-
store.store('key', 'unmarshalled value', raw: true)
|
2613
|
-
|
2614
|
-
begin
|
2615
|
-
store['key'].should == load_value('unmarshalled value')
|
2616
|
-
store.delete('key').should == load_value('unmarshalled value')
|
2617
|
-
rescue Exception => ex
|
2618
|
-
expect do
|
2619
|
-
store['key']
|
2620
|
-
end.to raise_error
|
2621
|
-
expect do
|
2622
|
-
store.delete('key')
|
2623
|
-
end.to raise_error
|
2624
|
-
end
|
2625
|
-
end}
|
2626
|
-
|
2627
|
-
SPECS['features'] = %{it 'should report correct features' do
|
2628
|
-
store.features.sort_by(&:to_s).should == features
|
2629
|
-
end
|
2630
|
-
|
2631
|
-
it 'should have frozen features' do
|
2632
|
-
store.features.frozen?.should be true
|
2633
|
-
end
|
2634
|
-
|
2635
|
-
it 'should have #supports?' do
|
2636
|
-
features.each do |f|
|
2637
|
-
store.supports?(f).should be true
|
2638
|
-
end
|
2639
|
-
store.supports?(:unknown).should be false
|
2640
|
-
end}
|
2641
|
-
|
2642
|
-
specs_code = "#{header}\n"
|
2643
|
-
SPECS.each do |key, code|
|
2644
|
-
specs_code << "#################### #{key} ####################\n\n" <<
|
2645
|
-
"shared_examples_for '#{key}' do\n " << [code].flatten.join("\n\n").gsub("\n", "\n ") << "\nend\n\n"
|
2646
|
-
end
|
2647
|
-
specs_code.gsub!(/\n +\n/, "\n\n")
|
2648
|
-
File.open(File.join(PATH, 'monetaspecs.rb'), 'w') {|out| out << specs_code }
|
2649
|
-
|
2650
|
-
TESTS.each do |name, options|
|
2651
|
-
build = options.delete(:build)
|
2652
|
-
store = options.delete(:store)
|
2653
|
-
|
2654
|
-
load_value = options.delete(:load_value) || 'Marshal.load(value)'
|
2655
|
-
|
2656
|
-
specs_code = []
|
2657
|
-
specs = options.delete(:specs)
|
2658
|
-
specs.specs.sort.each do |s|
|
2659
|
-
specs_code << " it_should_behave_like '#{s}'" if SPECS[s.to_s]
|
2660
|
-
specs.key.each do |k|
|
2661
|
-
specs.value.each do |v|
|
2662
|
-
x = "#{s}_#{k}key_#{v}value"
|
2663
|
-
specs_code << " it_should_behave_like '#{x}'" if SPECS[x]
|
2664
|
-
end
|
2665
|
-
end
|
2666
|
-
end
|
2667
|
-
|
2668
|
-
preamble = options.delete(:preamble).to_s.gsub("\n", "\n ")
|
2669
|
-
opts = options.delete(:options)
|
2670
|
-
opts = ', ' << opts if opts
|
2671
|
-
|
2672
|
-
build ||= "Moneta.new(#{store.inspect}#{opts}, logger: {file: File.join(make_tempdir, '#{name}.log')})"
|
2673
|
-
|
2674
|
-
code = %{#{header}require 'helper'
|
2675
|
-
|
2676
|
-
describe_moneta #{name.inspect} do
|
2677
|
-
#{preamble}def features
|
2678
|
-
#{specs.features.to_a.inspect}
|
2679
|
-
end
|
2680
|
-
|
2681
|
-
def new_store
|
2682
|
-
#{build.gsub("\n", "\n ")}
|
2683
|
-
end
|
2684
|
-
|
2685
|
-
def load_value(value)
|
2686
|
-
#{load_value}
|
2687
|
-
end
|
2688
|
-
|
2689
|
-
include_context 'setup_store'
|
2690
|
-
#{specs_code.join("\n")}#{options[:tests].to_s.gsub("\n", "\n ")}
|
2691
|
-
end
|
2692
|
-
}
|
2693
|
-
|
2694
|
-
code.gsub!(/\n +\n/, "\n\n")
|
2695
|
-
File.open(File.join(PATH, 'moneta', "#{name}_spec.rb"), 'w') {|out| out << code }
|
2696
|
-
end
|