Module: RSpec::RedisHelper
- Defined in:
- lib/rspec-redis_helper.rb,
lib/rspec-redis_helper/version.rb
Constant Summary collapse
- CONFIG =
{ url: "redis://127.0.0.1:6379/1" }
- TEST =
deprecated
CONFIG
- VERSION =
"0.1.2"
Instance Method Summary collapse
- #redis ⇒ Object
- #redis2 ⇒ Object
- #with_clean_redis(&block) ⇒ Object
- #with_watch(redis, *args) ⇒ Object
Instance Method Details
#redis ⇒ Object
9 10 11 |
# File 'lib/rspec-redis_helper.rb', line 9 def redis @redis ||= ::Redis.connect(CONFIG) end |
#redis2 ⇒ Object
13 14 15 |
# File 'lib/rspec-redis_helper.rb', line 13 def redis2 @redis2 ||= ::Redis.connect(CONFIG) end |
#with_clean_redis(&block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rspec-redis_helper.rb', line 26 def with_clean_redis(&block) redis.client.disconnect # auto connect after fork redis2.client.disconnect # auto connect after fork redis.flushall # clean before run begin yield ensure redis.flushall # clean up after run redis.quit # quit (close) connection redis2.quit # quit (close) connection end end |
#with_watch(redis, *args) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rspec-redis_helper.rb', line 17 def with_watch( redis, *args ) redis.watch( *args ) begin yield ensure redis.unwatch end end |