fakeredis 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +1,73 @@
1
1
  shared_examples_for "a sortable" do
2
2
  it 'returns empty array on nil' do
3
- @client.sort(nil).should == []
3
+ expect(@client.sort(nil)).to eq([])
4
4
  end
5
5
 
6
6
  context 'ordering' do
7
7
  it 'orders ascending by default' do
8
- @client.sort(@key).should == ['1', '2']
8
+ expect(@client.sort(@key)).to eq(['1', '2'])
9
9
  end
10
10
 
11
11
  it 'orders by ascending when specified' do
12
- @client.sort(@key, :order => "ASC").should == ['1', '2']
12
+ expect(@client.sort(@key, :order => "ASC")).to eq(['1', '2'])
13
13
  end
14
14
 
15
15
  it 'orders by descending when specified' do
16
- @client.sort(@key, :order => "DESC").should == ['2', '1']
16
+ expect(@client.sort(@key, :order => "DESC")).to eq(['2', '1'])
17
17
  end
18
18
 
19
19
  it "orders by ascending when alpha is specified" do
20
- @client.sort(@key, :order => "ALPHA").should == ["1", "2"]
20
+ expect(@client.sort(@key, :order => "ALPHA")).to eq(["1", "2"])
21
21
  end
22
22
  end
23
23
 
24
24
  context 'projections' do
25
25
  it 'projects element when :get is "#"' do
26
- @client.sort(@key, :get => '#').should == ['1', '2']
26
+ expect(@client.sort(@key, :get => '#')).to eq(['1', '2'])
27
27
  end
28
28
 
29
29
  it 'projects through a key pattern' do
30
- @client.sort(@key, :get => 'fake-redis-test:values_*').should == ['a', 'b']
30
+ expect(@client.sort(@key, :get => 'fake-redis-test:values_*')).to eq(['a', 'b'])
31
31
  end
32
32
 
33
33
  it 'projects through a key pattern and reflects element' do
34
- @client.sort(@key, :get => ['#', 'fake-redis-test:values_*']).should == [['1', 'a'], ['2', 'b']]
34
+ expect(@client.sort(@key, :get => ['#', 'fake-redis-test:values_*'])).to eq([['1', 'a'], ['2', 'b']])
35
35
  end
36
36
 
37
37
  it 'projects through a hash key pattern' do
38
- @client.sort(@key, :get => 'fake-redis-test:hash_*->key').should == ['x', 'y']
38
+ expect(@client.sort(@key, :get => 'fake-redis-test:hash_*->key')).to eq(['x', 'y'])
39
39
  end
40
40
  end
41
41
 
42
42
  context 'weights' do
43
43
  it 'weights by projecting through a key pattern' do
44
- @client.sort(@key, :by => "fake-redis-test:weight_*").should == ['2', '1']
44
+ expect(@client.sort(@key, :by => "fake-redis-test:weight_*")).to eq(['2', '1'])
45
45
  end
46
46
 
47
47
  it 'weights by projecting through a key pattern and a specific order' do
48
- @client.sort(@key, :order => "DESC", :by => "fake-redis-test:weight_*").should == ['1', '2']
48
+ expect(@client.sort(@key, :order => "DESC", :by => "fake-redis-test:weight_*")).to eq(['1', '2'])
49
49
  end
50
50
  end
51
51
 
52
52
  context 'limit' do
53
53
  it 'only returns requested window in the enumerable' do
54
- @client.sort(@key, :limit => [0, 1]).should == ['1']
54
+ expect(@client.sort(@key, :limit => [0, 1])).to eq(['1'])
55
+ end
56
+
57
+ it 'returns an empty array if the offset if more than the length of the list' do
58
+ expect(@client.sort(@key, :limit => [3, 1])).to eq([])
55
59
  end
56
60
  end
57
61
 
58
62
  context 'store' do
59
63
  it 'stores into another key' do
60
- @client.sort(@key, :store => "fake-redis-test:some_bucket").should == 2
61
- @client.lrange("fake-redis-test:some_bucket", 0, -1).should == ['1', '2']
64
+ expect(@client.sort(@key, :store => "fake-redis-test:some_bucket")).to eq(2)
65
+ expect(@client.lrange("fake-redis-test:some_bucket", 0, -1)).to eq(['1', '2'])
62
66
  end
63
67
 
64
68
  it "stores into another key with other options specified" do
65
- @client.sort(@key, :store => "fake-redis-test:some_bucket", :by => "fake-redis-test:weight_*").should == 2
66
- @client.lrange("fake-redis-test:some_bucket", 0, -1).should == ['2', '1']
69
+ expect(@client.sort(@key, :store => "fake-redis-test:some_bucket", :by => "fake-redis-test:weight_*")).to eq(2)
70
+ expect(@client.lrange("fake-redis-test:some_bucket", 0, -1)).to eq(['2', '1'])
67
71
  end
68
72
  end
69
73
  end
@@ -12,12 +12,12 @@ module FakeRedis
12
12
 
13
13
  context '#multi' do
14
14
  it "should respond with 'OK'" do
15
- @client.multi.should == 'OK'
15
+ expect(@client.multi).to eq('OK')
16
16
  end
17
17
 
18
18
  it "should forbid nesting" do
19
19
  @client.multi
20
- lambda{@client.multi}.should raise_error(Redis::CommandError)
20
+ expect{@client.multi}.to raise_error(Redis::CommandError)
21
21
  end
22
22
 
23
23
  it "should mark the start of a transaction block" do
@@ -28,24 +28,24 @@ module FakeRedis
28
28
  multi.mget("key1", "key2")
29
29
  end
30
30
 
31
- transaction.should be == ["OK", "OK", true, ["1", "2"]]
31
+ expect(transaction).to eq(["OK", "OK", true, ["1", "2"]])
32
32
  end
33
33
  end
34
34
 
35
35
  context '#discard' do
36
36
  it "should responde with 'OK' after #multi" do
37
37
  @client.multi
38
- @client.discard.should == 'OK'
38
+ expect(@client.discard).to eq('OK')
39
39
  end
40
40
 
41
41
  it "can't be run outside of #multi/#exec" do
42
- lambda{@client.discard}.should raise_error(Redis::CommandError)
42
+ expect{@client.discard}.to raise_error(Redis::CommandError)
43
43
  end
44
44
  end
45
45
 
46
46
  context '#exec' do
47
47
  it "can't be run outside of #multi" do
48
- lambda{@client.exec}.should raise_error(Redis::CommandError)
48
+ expect{@client.exec}.to raise_error(Redis::CommandError)
49
49
  end
50
50
  end
51
51
 
@@ -57,8 +57,8 @@ module FakeRedis
57
57
  end
58
58
 
59
59
  it "makes commands respond with 'QUEUED'" do
60
- @client.set(@string, 'string').should == 'QUEUED'
61
- @client.lpush(@list, 'list').should == 'QUEUED'
60
+ expect(@client.set(@string, 'string')).to eq('QUEUED')
61
+ expect(@client.lpush(@list, 'list')).to eq('QUEUED')
62
62
  end
63
63
 
64
64
  it "gives you the commands' responses when you call #exec" do
@@ -66,7 +66,7 @@ module FakeRedis
66
66
  @client.lpush(@list, 'list')
67
67
  @client.lpush(@list, 'list')
68
68
 
69
- @client.exec.should == ['OK', 1, 2]
69
+ expect(@client.exec).to eq(['OK', 1, 2])
70
70
  end
71
71
 
72
72
  it "does not raise exceptions, but rather puts them in #exec's response" do
@@ -75,9 +75,17 @@ module FakeRedis
75
75
  @client.lpush(@list, 'list')
76
76
 
77
77
  responses = @client.exec
78
- responses[0].should == 'OK'
79
- responses[1].should be_a(RuntimeError)
80
- responses[2].should == 1
78
+ expect(responses[0]).to eq('OK')
79
+ expect(responses[1]).to be_a(RuntimeError)
80
+ expect(responses[2]).to eq(1)
81
+ end
82
+ end
83
+
84
+ context 'executing hash commands in a block' do
85
+ it "returns true if the nested hash command succeeds" do
86
+ responses = @client.multi { |multi| multi.hset('hash', 'key', 'value') }
87
+
88
+ expect(responses[0]).to eq(true)
81
89
  end
82
90
  end
83
91
  end
@@ -8,11 +8,11 @@ module FakeRedis
8
8
  end
9
9
 
10
10
  it "#ZCOUNT" do
11
- @client.ZCOUNT("key", 2, 3).should == @client.zcount("key", 2, 3)
11
+ expect(@client.ZCOUNT("key", 2, 3)).to eq(@client.zcount("key", 2, 3))
12
12
  end
13
13
 
14
14
  it "#ZSCORE" do
15
- @client.ZSCORE("key", 2).should == @client.zscore("key", 2)
15
+ expect(@client.ZSCORE("key", 2)).to eq(@client.zscore("key", 2))
16
16
  end
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakeredis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillermo Iguaran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,10 +53,13 @@ files:
53
53
  - README.md
54
54
  - Rakefile
55
55
  - fakeredis.gemspec
56
+ - gemfiles/redisrb-master.gemfile
56
57
  - lib/fake_redis.rb
57
58
  - lib/fakeredis.rb
59
+ - lib/fakeredis/bitop_command.rb
58
60
  - lib/fakeredis/command_executor.rb
59
61
  - lib/fakeredis/expiring_hash.rb
62
+ - lib/fakeredis/minitest.rb
60
63
  - lib/fakeredis/rspec.rb
61
64
  - lib/fakeredis/sort_method.rb
62
65
  - lib/fakeredis/sorted_set_argument_handler.rb
@@ -65,6 +68,7 @@ files:
65
68
  - lib/fakeredis/version.rb
66
69
  - lib/fakeredis/zset.rb
67
70
  - lib/redis/connection/memory.rb
71
+ - spec/bitop_command_spec.rb
68
72
  - spec/compatibility_spec.rb
69
73
  - spec/connection_spec.rb
70
74
  - spec/hashes_spec.rb
@@ -78,6 +82,8 @@ files:
78
82
  - spec/spec_helper.rb
79
83
  - spec/spec_helper_live_redis.rb
80
84
  - spec/strings_spec.rb
85
+ - spec/subscription_spec.rb
86
+ - spec/support/shared_examples/bitwise_operation.rb
81
87
  - spec/support/shared_examples/sortable.rb
82
88
  - spec/transactions_spec.rb
83
89
  - spec/upcase_method_name_spec.rb
@@ -101,11 +107,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
107
  version: '0'
102
108
  requirements: []
103
109
  rubyforge_project:
104
- rubygems_version: 2.2.0
110
+ rubygems_version: 2.5.1
105
111
  signing_key:
106
112
  specification_version: 4
107
113
  summary: Fake (In-memory) driver for redis-rb.
108
114
  test_files:
115
+ - spec/bitop_command_spec.rb
109
116
  - spec/compatibility_spec.rb
110
117
  - spec/connection_spec.rb
111
118
  - spec/hashes_spec.rb
@@ -119,6 +126,8 @@ test_files:
119
126
  - spec/spec_helper.rb
120
127
  - spec/spec_helper_live_redis.rb
121
128
  - spec/strings_spec.rb
129
+ - spec/subscription_spec.rb
130
+ - spec/support/shared_examples/bitwise_operation.rb
122
131
  - spec/support/shared_examples/sortable.rb
123
132
  - spec/transactions_spec.rb
124
133
  - spec/upcase_method_name_spec.rb