mock_redis 0.14.1 → 0.15.0

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.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.overcommit.yml +1 -1
  4. data/.rubocop.yml +91 -0
  5. data/.simplecov +4 -0
  6. data/.travis.yml +14 -2
  7. data/CHANGELOG.md +4 -0
  8. data/Gemfile +4 -2
  9. data/README.md +1 -0
  10. data/Rakefile +2 -2
  11. data/lib/mock_redis.rb +25 -26
  12. data/lib/mock_redis/assertions.rb +0 -1
  13. data/lib/mock_redis/database.rb +35 -28
  14. data/lib/mock_redis/expire_wrapper.rb +1 -1
  15. data/lib/mock_redis/future.rb +1 -1
  16. data/lib/mock_redis/hash_methods.rb +18 -17
  17. data/lib/mock_redis/indifferent_hash.rb +4 -0
  18. data/lib/mock_redis/info_method.rb +109 -108
  19. data/lib/mock_redis/list_methods.rb +17 -16
  20. data/lib/mock_redis/multi_db_wrapper.rb +5 -4
  21. data/lib/mock_redis/pipelined_wrapper.rb +3 -3
  22. data/lib/mock_redis/set_methods.rb +10 -9
  23. data/lib/mock_redis/sort_method.rb +11 -12
  24. data/lib/mock_redis/string_methods.rb +26 -29
  25. data/lib/mock_redis/transaction_wrapper.rb +7 -8
  26. data/lib/mock_redis/utility_methods.rb +9 -12
  27. data/lib/mock_redis/version.rb +1 -1
  28. data/lib/mock_redis/zset.rb +22 -23
  29. data/lib/mock_redis/zset_methods.rb +25 -25
  30. data/spec/cloning_spec.rb +17 -18
  31. data/spec/commands/append_spec.rb +4 -4
  32. data/spec/commands/auth_spec.rb +1 -1
  33. data/spec/commands/bgrewriteaof_spec.rb +2 -2
  34. data/spec/commands/bgsave_spec.rb +2 -2
  35. data/spec/commands/bitcount_spec.rb +3 -3
  36. data/spec/commands/blpop_spec.rb +10 -10
  37. data/spec/commands/brpop_spec.rb +10 -10
  38. data/spec/commands/brpoplpush_spec.rb +9 -9
  39. data/spec/commands/connected_spec.rb +2 -2
  40. data/spec/commands/dbsize_spec.rb +3 -3
  41. data/spec/commands/decr_spec.rb +7 -7
  42. data/spec/commands/decrby_spec.rb +7 -7
  43. data/spec/commands/del_spec.rb +4 -4
  44. data/spec/commands/disconnect_spec.rb +2 -2
  45. data/spec/commands/echo_spec.rb +4 -4
  46. data/spec/commands/exists_spec.rb +3 -3
  47. data/spec/commands/expire_spec.rb +13 -13
  48. data/spec/commands/expireat_spec.rb +6 -7
  49. data/spec/commands/flushall_spec.rb +5 -5
  50. data/spec/commands/flushdb_spec.rb +5 -5
  51. data/spec/commands/future_spec.rb +2 -2
  52. data/spec/commands/get_spec.rb +7 -7
  53. data/spec/commands/getbit_spec.rb +6 -6
  54. data/spec/commands/getrange_spec.rb +9 -9
  55. data/spec/commands/getset_spec.rb +7 -7
  56. data/spec/commands/hash_operator_spec.rb +5 -5
  57. data/spec/commands/hdel_spec.rb +12 -12
  58. data/spec/commands/hexists_spec.rb +7 -7
  59. data/spec/commands/hget_spec.rb +7 -7
  60. data/spec/commands/hgetall_spec.rb +6 -6
  61. data/spec/commands/hincrby_spec.rb +14 -14
  62. data/spec/commands/hincrbyfloat_spec.rb +14 -14
  63. data/spec/commands/hkeys_spec.rb +5 -5
  64. data/spec/commands/hlen_spec.rb +5 -5
  65. data/spec/commands/hmget_spec.rb +8 -8
  66. data/spec/commands/hmset_spec.rb +10 -10
  67. data/spec/commands/hset_spec.rb +11 -11
  68. data/spec/commands/hsetnx_spec.rb +14 -14
  69. data/spec/commands/hvals_spec.rb +5 -5
  70. data/spec/commands/incr_spec.rb +7 -7
  71. data/spec/commands/incrby_spec.rb +11 -11
  72. data/spec/commands/incrbyfloat_spec.rb +11 -11
  73. data/spec/commands/info_spec.rb +30 -30
  74. data/spec/commands/keys_spec.rb +42 -43
  75. data/spec/commands/lastsave_spec.rb +2 -2
  76. data/spec/commands/lindex_spec.rb +15 -15
  77. data/spec/commands/linsert_spec.rb +13 -13
  78. data/spec/commands/llen_spec.rb +4 -4
  79. data/spec/commands/lpop_spec.rb +6 -6
  80. data/spec/commands/lpush_spec.rb +16 -16
  81. data/spec/commands/lpushx_spec.rb +13 -13
  82. data/spec/commands/lrange_spec.rb +12 -12
  83. data/spec/commands/lrem_spec.rb +15 -15
  84. data/spec/commands/lset_spec.rb +12 -12
  85. data/spec/commands/ltrim_spec.rb +9 -9
  86. data/spec/commands/mapped_hmget_spec.rb +8 -8
  87. data/spec/commands/mapped_hmset_spec.rb +12 -12
  88. data/spec/commands/mapped_mget_spec.rb +4 -4
  89. data/spec/commands/mapped_mset_spec.rb +1 -1
  90. data/spec/commands/mget_spec.rb +11 -11
  91. data/spec/commands/move_spec.rb +29 -29
  92. data/spec/commands/mset_spec.rb +4 -4
  93. data/spec/commands/msetnx_spec.rb +10 -10
  94. data/spec/commands/persist_spec.rb +9 -10
  95. data/spec/commands/pexpire_spec.rb +12 -13
  96. data/spec/commands/pexpireat_spec.rb +6 -6
  97. data/spec/commands/ping_spec.rb +1 -1
  98. data/spec/commands/pipelined_spec.rb +5 -5
  99. data/spec/commands/pttl_spec.rb +5 -5
  100. data/spec/commands/randomkey_spec.rb +3 -3
  101. data/spec/commands/rename_spec.rb +9 -9
  102. data/spec/commands/renamenx_spec.rb +10 -10
  103. data/spec/commands/rpop_spec.rb +6 -6
  104. data/spec/commands/rpoplpush_spec.rb +7 -7
  105. data/spec/commands/rpush_spec.rb +16 -16
  106. data/spec/commands/rpushx_spec.rb +13 -13
  107. data/spec/commands/sadd_spec.rb +8 -9
  108. data/spec/commands/scan_spec.rb +6 -7
  109. data/spec/commands/scard_spec.rb +3 -3
  110. data/spec/commands/sdiff_spec.rb +10 -10
  111. data/spec/commands/sdiffstore_spec.rb +10 -10
  112. data/spec/commands/select_spec.rb +7 -7
  113. data/spec/commands/setbit_spec.rb +13 -13
  114. data/spec/commands/setex_spec.rb +4 -4
  115. data/spec/commands/setnx_spec.rb +4 -4
  116. data/spec/commands/setrange_spec.rb +12 -12
  117. data/spec/commands/sinter_spec.rb +8 -10
  118. data/spec/commands/sinterstore_spec.rb +9 -9
  119. data/spec/commands/sismember_spec.rb +5 -5
  120. data/spec/commands/smembers_spec.rb +5 -5
  121. data/spec/commands/smove_spec.rb +7 -7
  122. data/spec/commands/sort_list_spec.rb +3 -3
  123. data/spec/commands/sort_set_spec.rb +3 -3
  124. data/spec/commands/sort_zset_spec.rb +3 -3
  125. data/spec/commands/spop_spec.rb +4 -4
  126. data/spec/commands/srandmember_spec.rb +8 -8
  127. data/spec/commands/srem_spec.rb +9 -9
  128. data/spec/commands/strlen_spec.rb +4 -4
  129. data/spec/commands/sunion_spec.rb +7 -9
  130. data/spec/commands/sunionstore_spec.rb +9 -9
  131. data/spec/commands/ttl_spec.rb +5 -5
  132. data/spec/commands/type_spec.rb +1 -1
  133. data/spec/commands/zadd_spec.rb +10 -10
  134. data/spec/commands/zcard_spec.rb +4 -4
  135. data/spec/commands/zcount_spec.rb +14 -14
  136. data/spec/commands/zincrby_spec.rb +6 -6
  137. data/spec/commands/zinterstore_spec.rb +17 -17
  138. data/spec/commands/zrange_spec.rb +12 -12
  139. data/spec/commands/zrangebyscore_spec.rb +26 -26
  140. data/spec/commands/zrank_spec.rb +4 -4
  141. data/spec/commands/zrem_spec.rb +9 -9
  142. data/spec/commands/zremrangebyrank_spec.rb +5 -5
  143. data/spec/commands/zremrangebyscore_spec.rb +9 -7
  144. data/spec/commands/zrevrange_spec.rb +10 -10
  145. data/spec/commands/zrevrangebyscore_spec.rb +14 -14
  146. data/spec/commands/zrevrank_spec.rb +4 -4
  147. data/spec/commands/zscore_spec.rb +5 -5
  148. data/spec/commands/zunionstore_spec.rb +18 -18
  149. data/spec/mock_redis_spec.rb +11 -1
  150. data/spec/spec_helper.rb +13 -4
  151. data/spec/support/redis_multiplexer.rb +39 -31
  152. data/spec/support/shared_examples/only_operates_on_hashes.rb +2 -2
  153. data/spec/support/shared_examples/only_operates_on_lists.rb +2 -2
  154. data/spec/support/shared_examples/only_operates_on_sets.rb +2 -2
  155. data/spec/support/shared_examples/only_operates_on_strings.rb +3 -3
  156. data/spec/support/shared_examples/only_operates_on_zsets.rb +12 -12
  157. data/spec/support/shared_examples/sorts_enumerables.rb +12 -12
  158. data/spec/transactions_spec.rb +18 -18
  159. metadata +5 -3
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#flushall [mock only]" do
3
+ describe '#flushall [mock only]' do
4
4
  # don't want to hurt things in the real redis that are outside our
5
5
  # namespace.
6
6
  before { @mock = @redises.mock }
@@ -10,7 +10,7 @@ describe "#flushall [mock only]" do
10
10
  @mock.flushall.should == 'OK'
11
11
  end
12
12
 
13
- it "removes all keys in the current DB" do
13
+ it 'removes all keys in the current DB' do
14
14
  @mock.set('k1', 'v1')
15
15
  @mock.lpush('k2', 'v2')
16
16
 
@@ -18,7 +18,7 @@ describe "#flushall [mock only]" do
18
18
  @mock.keys('*').should == []
19
19
  end
20
20
 
21
- it "removes all keys in other DBs, too" do
21
+ it 'removes all keys in other DBs, too' do
22
22
  @mock.set('k1', 'v1')
23
23
 
24
24
  @mock.select(1)
@@ -28,9 +28,9 @@ describe "#flushall [mock only]" do
28
28
  @mock.get('k1').should be_nil
29
29
  end
30
30
 
31
- it "removes expiration times" do
31
+ it 'removes expiration times' do
32
32
  @mock.set('k1', 'v1')
33
- @mock.expire('k1', 360000)
33
+ @mock.expire('k1', 360_000)
34
34
  @mock.flushall
35
35
  @mock.set('k1', 'v1')
36
36
  @mock.ttl('k1').should == -1
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#flushdb [mock only]" do
3
+ describe '#flushdb [mock only]' do
4
4
  # don't want to hurt things in the real redis that are outside our
5
5
  # namespace.
6
6
  before { @mock = @redises.mock }
@@ -10,7 +10,7 @@ describe "#flushdb [mock only]" do
10
10
  @mock.flushdb.should == 'OK'
11
11
  end
12
12
 
13
- it "removes all keys in the current DB" do
13
+ it 'removes all keys in the current DB' do
14
14
  @mock.set('k1', 'v1')
15
15
  @mock.lpush('k2', 'v2')
16
16
 
@@ -18,7 +18,7 @@ describe "#flushdb [mock only]" do
18
18
  @mock.keys('*').should == []
19
19
  end
20
20
 
21
- it "leaves other databases alone" do
21
+ it 'leaves other databases alone' do
22
22
  @mock.set('k1', 'v1')
23
23
 
24
24
  @mock.select(1)
@@ -28,9 +28,9 @@ describe "#flushdb [mock only]" do
28
28
  @mock.get('k1').should == 'v1'
29
29
  end
30
30
 
31
- it "removes expiration times" do
31
+ it 'removes expiration times' do
32
32
  @mock.set('k1', 'v1')
33
- @mock.expire('k1', 360000)
33
+ @mock.expire('k1', 360_000)
34
34
  @mock.flushdb
35
35
  @mock.set('k1', 'v1')
36
36
  @mock.ttl('k1').should == -1
@@ -10,11 +10,11 @@ describe MockRedis::Future do
10
10
  end
11
11
 
12
12
  it 'raises an error if the value is requested before the result is set' do
13
- expect{@future.value}.to raise_error(RuntimeError)
13
+ expect { @future.value }.to raise_error(RuntimeError)
14
14
  end
15
15
 
16
16
  it 'returns the value after the result has been set' do
17
- @future.set_result(result)
17
+ @future.store_result(result)
18
18
  @future.value.should eq(result)
19
19
  end
20
20
  end
@@ -1,30 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#get(key)" do
3
+ describe '#get(key)' do
4
4
  before do
5
5
  @key = 'mock-redis-test:73288'
6
6
  end
7
7
 
8
- it "returns nil for a nonexistent value" do
8
+ it 'returns nil for a nonexistent value' do
9
9
  @redises.get('mock-redis-test:does-not-exist').should be_nil
10
10
  end
11
11
 
12
- it "returns a stored string value" do
12
+ it 'returns a stored string value' do
13
13
  @redises.set(@key, 'forsooth')
14
14
  @redises.get(@key).should == 'forsooth'
15
15
  end
16
16
 
17
- it "treats integers as strings" do
17
+ it 'treats integers as strings' do
18
18
  @redises.set(@key, 100)
19
- @redises.get(@key).should == "100"
19
+ @redises.get(@key).should == '100'
20
20
  end
21
21
 
22
- it "stringifies key" do
22
+ it 'stringifies key' do
23
23
  key = :a_symbol
24
24
 
25
25
  @redises.set(key, 'hello')
26
26
  @redises.get(key.to_s).should == 'hello'
27
27
  end
28
28
 
29
- it_should_behave_like "a string-only command"
29
+ it_should_behave_like 'a string-only command'
30
30
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#getbit(key, offset)" do
3
+ describe '#getbit(key, offset)' do
4
4
  before do
5
5
  @key = 'mock-redis-test:getbit'
6
6
  @redises.set(@key, 'h') # ASCII 0x68
7
7
  end
8
8
 
9
- it "gets the bits from the key" do
9
+ it 'gets the bits from the key' do
10
10
  @redises.getbit(@key, 0).should == 0
11
11
  @redises.getbit(@key, 1).should == 1
12
12
  @redises.getbit(@key, 2).should == 1
@@ -17,18 +17,18 @@ describe "#getbit(key, offset)" do
17
17
  @redises.getbit(@key, 7).should == 0
18
18
  end
19
19
 
20
- it "returns 0 for out-of-range bits" do
20
+ it 'returns 0 for out-of-range bits' do
21
21
  @redises.getbit(@key, 100).should == 0
22
22
  end
23
23
 
24
- it "does not modify the stored value for out-of-range bits" do
24
+ it 'does not modify the stored value for out-of-range bits' do
25
25
  @redises.getbit(@key, 100)
26
26
  @redises.get(@key).should == 'h'
27
27
  end
28
28
 
29
- it "treats nonexistent keys as empty strings" do
29
+ it 'treats nonexistent keys as empty strings' do
30
30
  @redises.getbit('mock-redis-test:not-found', 0).should == 0
31
31
  end
32
32
 
33
- it_should_behave_like "a string-only command"
33
+ it_should_behave_like 'a string-only command'
34
34
  end
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#getrange(key, start, stop)" do
3
+ describe '#getrange(key, start, stop)' do
4
4
  before do
5
5
  @key = 'mock-redis-test:getrange'
6
- @redises.set(@key, "This is a string")
6
+ @redises.set(@key, 'This is a string')
7
7
  end
8
8
 
9
- it "returns a substring" do
10
- @redises.getrange(@key, 0, 3).should == "This"
9
+ it 'returns a substring' do
10
+ @redises.getrange(@key, 0, 3).should == 'This'
11
11
  end
12
12
 
13
- it "works with negative indices" do
14
- @redises.getrange(@key, -3, -1).should == "ing"
13
+ it 'works with negative indices' do
14
+ @redises.getrange(@key, -3, -1).should == 'ing'
15
15
  end
16
16
 
17
- it "limits the result to the actual length of the string" do
18
- @redises.getrange(@key, 10, 100).should == "string"
17
+ it 'limits the result to the actual length of the string' do
18
+ @redises.getrange(@key, 10, 100).should == 'string'
19
19
  end
20
20
 
21
- it_should_behave_like "a string-only command"
21
+ it_should_behave_like 'a string-only command'
22
22
  end
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#getrange(key, value)" do
3
+ describe '#getrange(key, value)' do
4
4
  before do
5
5
  @key = 'mock-redis-test:getset'
6
- @redises.set(@key, "oldvalue")
6
+ @redises.set(@key, 'oldvalue')
7
7
  end
8
8
 
9
- it "returns the old value" do
10
- @redises.getset(@key, 'newvalue').should == "oldvalue"
9
+ it 'returns the old value' do
10
+ @redises.getset(@key, 'newvalue').should == 'oldvalue'
11
11
  end
12
12
 
13
- it "sets the value to the new value" do
13
+ it 'sets the value to the new value' do
14
14
  @redises.getset(@key, 'newvalue')
15
15
  @redises.get(@key).should == 'newvalue'
16
16
  end
17
17
 
18
- it "returns nil for nonexistent keys" do
18
+ it 'returns nil for nonexistent keys' do
19
19
  @redises.getset('mock-redis-test:not-found', 1).should be_nil
20
20
  end
21
21
 
22
- it_should_behave_like "a string-only command"
22
+ it_should_behave_like 'a string-only command'
23
23
  end
@@ -1,21 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#[](key)" do
3
+ describe '#[](key)' do
4
4
  before do
5
5
  @key = 'mock-redis-test:hash_operator'
6
6
  end
7
7
 
8
- it "returns nil for a nonexistent value" do
8
+ it 'returns nil for a nonexistent value' do
9
9
  @redises['mock-redis-test:does-not-exist'].should be_nil
10
10
  end
11
11
 
12
- it "returns a stored string value" do
12
+ it 'returns a stored string value' do
13
13
  @redises[@key] = 'forsooth'
14
14
  @redises[@key].should == 'forsooth'
15
15
  end
16
16
 
17
- it "treats integers as strings" do
17
+ it 'treats integers as strings' do
18
18
  @redises[@key] = 100
19
- @redises[@key].should == "100"
19
+ @redises[@key].should == '100'
20
20
  end
21
21
  end
@@ -1,54 +1,54 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#hdel(key, field)" do
3
+ describe '#hdel(key, field)' do
4
4
  before do
5
- @key = "mock-redis-test:hdel"
5
+ @key = 'mock-redis-test:hdel'
6
6
  @redises.hset(@key, 'k1', 'v1')
7
7
  @redises.hset(@key, 'k2', 'v2')
8
8
  end
9
9
 
10
- it "returns 1 when it removes a field" do
10
+ it 'returns 1 when it removes a field' do
11
11
  @redises.hdel(@key, 'k1').should == 1
12
12
  end
13
13
 
14
- it "returns 0 when it does not remove a field" do
14
+ it 'returns 0 when it does not remove a field' do
15
15
  @redises.hdel(@key, 'nonesuch').should == 0
16
16
  end
17
17
 
18
- it "actually removes the field" do
18
+ it 'actually removes the field' do
19
19
  @redises.hdel(@key, 'k1')
20
20
  @redises.hget(@key, 'k1').should be_nil
21
21
  end
22
22
 
23
- it "treats the field as a string" do
23
+ it 'treats the field as a string' do
24
24
  field = 2
25
25
  @redises.hset(@key, field, 'two')
26
26
  @redises.hdel(@key, field)
27
27
  @redises.hget(@key, field).should be_nil
28
28
  end
29
29
 
30
- it "removes only the field specified" do
30
+ it 'removes only the field specified' do
31
31
  @redises.hdel(@key, 'k1')
32
32
  @redises.hget(@key, 'k2').should == 'v2'
33
33
  end
34
34
 
35
- it "cleans up empty hashes" do
35
+ it 'cleans up empty hashes' do
36
36
  @redises.hdel(@key, 'k1')
37
37
  @redises.hdel(@key, 'k2')
38
38
  @redises.get(@key).should be_nil
39
39
  end
40
40
 
41
- it "supports a variable number of arguments" do
42
- @redises.hdel(@key, ['k1', 'k2'])
41
+ it 'supports a variable number of arguments' do
42
+ @redises.hdel(@key, %w[k1 k2])
43
43
  @redises.get(@key).should be_nil
44
44
  end
45
45
 
46
- it "treats variable arguments as strings" do
46
+ it 'treats variable arguments as strings' do
47
47
  field = 2
48
48
  @redises.hset(@key, field, 'two')
49
49
  @redises.hdel(@key, [field])
50
50
  @redises.hget(@key, field).should be_nil
51
51
  end
52
52
 
53
- it_should_behave_like "a hash-only command"
53
+ it_should_behave_like 'a hash-only command'
54
54
  end
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#hexists(key, field)" do
3
+ describe '#hexists(key, field)' do
4
4
  before do
5
- @key = "mock-redis-test:hexists"
5
+ @key = 'mock-redis-test:hexists'
6
6
  @redises.hset(@key, 'field', 'value')
7
7
  end
8
8
 
9
- it "returns true if the hash has that field" do
9
+ it 'returns true if the hash has that field' do
10
10
  @redises.hexists(@key, 'field').should == true
11
11
  end
12
12
 
13
- it "returns false if the hash lacks that field" do
13
+ it 'returns false if the hash lacks that field' do
14
14
  @redises.hexists(@key, 'nonesuch').should == false
15
15
  end
16
16
 
17
- it "treats the field as a string" do
17
+ it 'treats the field as a string' do
18
18
  @redises.hset(@key, 1, 'one')
19
19
  @redises.hexists(@key, 1).should == true
20
20
  end
21
21
 
22
- it "returns nil when there is no such key" do
22
+ it 'returns nil when there is no such key' do
23
23
  @redises.hexists('mock-redis-test:nonesuch', 'key').should == false
24
24
  end
25
25
 
26
- it_should_behave_like "a hash-only command"
26
+ it_should_behave_like 'a hash-only command'
27
27
  end
@@ -1,28 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#hget(key, field)" do
3
+ describe '#hget(key, field)' do
4
4
  before do
5
- @key = "mock-redis-test:hget"
5
+ @key = 'mock-redis-test:hget'
6
6
  @redises.hset(@key, 'k1', 'v1')
7
7
  @redises.hset(@key, 'k2', 'v2')
8
8
  end
9
9
 
10
- it "returns the value stored at field" do
10
+ it 'returns the value stored at field' do
11
11
  @redises.hget(@key, 'k1').should == 'v1'
12
12
  end
13
13
 
14
- it "treats the field as a string" do
14
+ it 'treats the field as a string' do
15
15
  @redises.hset(@key, '3', 'v3')
16
16
  @redises.hget(@key, 3).should == 'v3'
17
17
  end
18
18
 
19
- it "returns nil when there is no such field" do
19
+ it 'returns nil when there is no such field' do
20
20
  @redises.hget(@key, 'nonesuch').should be_nil
21
21
  end
22
22
 
23
- it "returns nil when there is no such key" do
23
+ it 'returns nil when there is no such key' do
24
24
  @redises.hget('mock-redis-test:nonesuch', 'k1').should be_nil
25
25
  end
26
26
 
27
- it_should_behave_like "a hash-only command"
27
+ it_should_behave_like 'a hash-only command'
28
28
  end
@@ -1,20 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#hgetall(key)" do
3
+ describe '#hgetall(key)' do
4
4
  before do
5
- @key = "mock-redis-test:hgetall"
5
+ @key = 'mock-redis-test:hgetall'
6
6
  @redises.hset(@key, 'k1', 'v1')
7
7
  @redises.hset(@key, 'k2', 'v2')
8
8
  end
9
9
 
10
- it "returns the (key, value) pairs stored in the hash" do
10
+ it 'returns the (key, value) pairs stored in the hash' do
11
11
  @redises.hgetall(@key).should == {
12
12
  'k1' => 'v1',
13
13
  'k2' => 'v2',
14
14
  }
15
15
  end
16
16
 
17
- it "returns [] when there is no such key" do
17
+ it 'returns [] when there is no such key' do
18
18
  @redises.hgetall('mock-redis-test:nonesuch').should == {}
19
19
  end
20
20
 
@@ -25,8 +25,8 @@ describe "#hgetall(key)" do
25
25
  hash = mr.hgetall(@key)
26
26
  hash['dont'] = 'mutate'
27
27
  new_hash = mr.hgetall(@key)
28
- new_hash.keys.sort.should == ['k1', 'k2']
28
+ new_hash.keys.sort.should == %w[k1 k2]
29
29
  end
30
30
 
31
- it_should_behave_like "a hash-only command"
31
+ it_should_behave_like 'a hash-only command'
32
32
  end
@@ -6,53 +6,53 @@ describe '#hincrby(key, field, increment)' do
6
6
  @field = 'count'
7
7
  end
8
8
 
9
- it "returns the value after the increment" do
9
+ it 'returns the value after the increment' do
10
10
  @redises.hset(@key, @field, 2)
11
11
  @redises.hincrby(@key, @field, 2).should == 4
12
12
  end
13
13
 
14
- it "treats a missing key like 0" do
14
+ it 'treats a missing key like 0' do
15
15
  @redises.hincrby(@key, @field, 1).should == 1
16
16
  end
17
17
 
18
- it "creates a hash if nothing is present" do
18
+ it 'creates a hash if nothing is present' do
19
19
  @redises.hincrby(@key, @field, 1)
20
- @redises.hget(@key, @field).should == "1"
20
+ @redises.hget(@key, @field).should == '1'
21
21
  end
22
22
 
23
- it "increments negative numbers" do
23
+ it 'increments negative numbers' do
24
24
  @redises.hset(@key, @field, -10)
25
25
  @redises.hincrby(@key, @field, 2).should == -8
26
26
  end
27
27
 
28
- it "works multiple times" do
28
+ it 'works multiple times' do
29
29
  @redises.hincrby(@key, @field, 2).should == 2
30
30
  @redises.hincrby(@key, @field, 2).should == 4
31
31
  @redises.hincrby(@key, @field, 2).should == 6
32
32
  end
33
33
 
34
- it "accepts an integer-ish string" do
35
- @redises.hincrby(@key, @field, "2").should == 2
34
+ it 'accepts an integer-ish string' do
35
+ @redises.hincrby(@key, @field, '2').should == 2
36
36
  end
37
37
 
38
- it "treats the field as a string" do
38
+ it 'treats the field as a string' do
39
39
  field = 11
40
40
  @redises.hset(@key, field, 2)
41
41
  @redises.hincrby(@key, field, 2).should == 4
42
42
  end
43
43
 
44
- it "raises an error if the value does not look like an integer" do
45
- @redises.hset(@key, @field, "one")
44
+ it 'raises an error if the value does not look like an integer' do
45
+ @redises.hset(@key, @field, 'one')
46
46
  lambda do
47
47
  @redises.hincrby(@key, @field, 1)
48
48
  end.should raise_error(RuntimeError)
49
49
  end
50
50
 
51
- it "raises an error if the delta does not look like an integer" do
51
+ it 'raises an error if the delta does not look like an integer' do
52
52
  lambda do
53
- @redises.hincrby(@key, @field, "foo")
53
+ @redises.hincrby(@key, @field, 'foo')
54
54
  end.should raise_error(RuntimeError)
55
55
  end
56
56
 
57
- it_should_behave_like "a hash-only command"
57
+ it_should_behave_like 'a hash-only command'
58
58
  end