mock_redis 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.6.3
2
+ * Treat symbols as strings for keys
3
+ * Add #reconnect method (no-op)
4
+
1
5
  ### 0.6.2
2
6
  * Support for `connected?`, `disconnect` (no-op)
3
7
  * Fix `*` in `keys` to support 0 or more
data/lib/mock_redis.rb CHANGED
@@ -71,6 +71,10 @@ class MockRedis
71
71
  self
72
72
  end
73
73
 
74
+ def reconnect
75
+ self
76
+ end
77
+
74
78
  def respond_to?(method, include_private=false)
75
79
  super || @db.respond_to?(method, include_private)
76
80
  end
@@ -6,6 +6,7 @@ require 'mock_redis/set_methods'
6
6
  require 'mock_redis/string_methods'
7
7
  require 'mock_redis/zset_methods'
8
8
  require 'mock_redis/sort_method'
9
+ require 'mock_redis/indifferent_hash'
9
10
 
10
11
  class MockRedis
11
12
  class Database
@@ -20,7 +21,7 @@ class MockRedis
20
21
 
21
22
  def initialize(base, *args)
22
23
  @base = base
23
- @data = {}
24
+ @data = MockRedis::IndifferentHash.new
24
25
  @expire_times = []
25
26
  end
26
27
 
@@ -0,0 +1,11 @@
1
+ class MockRedis
2
+ class IndifferentHash < Hash
3
+ def [](key)
4
+ super(key.to_s)
5
+ end
6
+
7
+ def []=(key, value)
8
+ super(key.to_s, value)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  class MockRedis
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'client' do
4
+ context '#reconnect' do
5
+ it 'reconnects' do
6
+ redis = MockRedis.new
7
+ redis.reconnect.should == redis
8
+ end
9
+ end
10
+ end
@@ -19,5 +19,12 @@ describe "#get(key)" do
19
19
  @redises.get(@key).should == "100"
20
20
  end
21
21
 
22
+ it "stringifies key" do
23
+ key = :a_symbol
24
+
25
+ @redises.set(key, 'hello')
26
+ @redises.get(key.to_s).should == 'hello'
27
+ end
28
+
22
29
  it_should_behave_like "a string-only command"
23
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-11 00:00:00.000000000 Z
13
+ date: 2013-01-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -82,6 +82,7 @@ files:
82
82
  - lib/mock_redis/exceptions.rb
83
83
  - lib/mock_redis/expire_wrapper.rb
84
84
  - lib/mock_redis/hash_methods.rb
85
+ - lib/mock_redis/indifferent_hash.rb
85
86
  - lib/mock_redis/list_methods.rb
86
87
  - lib/mock_redis/multi_db_wrapper.rb
87
88
  - lib/mock_redis/pipelined_wrapper.rb
@@ -95,6 +96,7 @@ files:
95
96
  - lib/mock_redis/zset.rb
96
97
  - lib/mock_redis/zset_methods.rb
97
98
  - mock_redis.gemspec
99
+ - spec/client_spec.rb
98
100
  - spec/cloning_spec.rb
99
101
  - spec/commands/append_spec.rb
100
102
  - spec/commands/auth_spec.rb
@@ -245,6 +247,7 @@ signing_key:
245
247
  specification_version: 3
246
248
  summary: Redis mock that just lives in memory; useful for testing.
247
249
  test_files:
250
+ - spec/client_spec.rb
248
251
  - spec/cloning_spec.rb
249
252
  - spec/commands/append_spec.rb
250
253
  - spec/commands/auth_spec.rb