spec/support/redis_stub.rb in redis_failover-0.1.1 vs spec/support/redis_stub.rb in redis_failover-0.2.0
- old
+ new
@@ -3,11 +3,11 @@
module RedisFailover
# Test stub for Redis.
class RedisStub
class Proxy
def initialize(queue, opts = {})
- @info = {:role => 'master'}
+ @info = {'role' => 'master'}
@queue = queue
end
def blpop(*args)
@queue.pop.tap do |value|
@@ -22,23 +22,27 @@
@queue << nil
end
def slaveof(host, port)
if host == 'no' && port == 'one'
- @info[:role] = 'master'
+ @info['role'] = 'master'
else
- @info[:role] = 'slave'
+ @info['role'] = 'slave'
end
end
def info
@info.dup
end
def ping
'pong'
end
+
+ def change_role_to(role)
+ @info['role'] = role
+ end
end
attr_reader :host, :port, :reachable
def initialize(opts = {})
@host = opts[:host]
@@ -52,9 +56,13 @@
if @reachable
@proxy.send(method, *args, &block)
else
raise Errno::ECONNREFUSED
end
+ end
+
+ def change_role_to(role)
+ @proxy.change_role_to(role)
end
def make_reachable!
@reachable = true
end
\ No newline at end of file