1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
Description: Fix tests for Ruby 2.7+ compatibility
Author: Denise Yu <deniseyu@github.com>
Date: Mon, 24 Aug 2020 17:40:19 -0400
Origin: upstream, https://github.com/guilleiguaran/fakeredis/commit/b594709a3209aa671db2c6ebd8bac4a256a46ee2.patch
Bug-Debian: https://bugs.debian.org/996225
Last-Update: 2021-11-15
diff --git a/spec/keys_spec.rb b/spec/keys_spec.rb
index 5dfe423..5f5a89a 100644
--- a/spec/keys_spec.rb
+++ b/spec/keys_spec.rb
@@ -362,14 +362,14 @@ module FakeRedis
it "uses ex option to set the expire time, in seconds" do
ttl = 7
- expect(@client.set("key1", "1", { :ex => ttl })).to eq("OK")
+ expect(@client.set("key1", "1", ex: ttl)).to eq("OK")
expect(@client.ttl("key1")).to eq(ttl)
end
it "uses px option to set the expire time, in miliseconds" do
ttl = 7000
- expect(@client.set("key1", "1", { :px => ttl })).to eq("OK")
+ expect(@client.set("key1", "1", px: ttl)).to eq("OK")
expect(@client.ttl("key1")).to eq(ttl / 1000)
end
@@ -379,30 +379,30 @@ module FakeRedis
ttl_px = 6000
ttl_ex = 10
- @client.set("key1", "1", { :px => ttl_px, :ex => ttl_ex })
+ @client.set("key1", "1", px: ttl_px, ex: ttl_ex)
expect(@client.ttl("key1")).to eq(ttl_px / 1000)
- @client.set("key1", "1", { :ex => ttl_ex, :px => ttl_px })
+ @client.set("key1", "1", ex: ttl_ex, px: ttl_px)
expect(@client.ttl("key1")).to eq(ttl_px / 1000)
end
it "uses nx option to only set the key if it does not already exist" do
- expect(@client.set("key1", "1", { :nx => true })).to eq(true)
- expect(@client.set("key1", "2", { :nx => true })).to eq(false)
+ expect(@client.set("key1", "1", nx: true)).to eq(true)
+ expect(@client.set("key1", "2", nx: true)).to eq(false)
expect(@client.get("key1")).to eq("1")
end
it "uses xx option to only set the key if it already exists" do
- expect(@client.set("key2", "1", { :xx => true })).to eq(false)
+ expect(@client.set("key2", "1", xx: true)).to eq(false)
@client.set("key2", "2")
- expect(@client.set("key2", "1", { :xx => true })).to eq(true)
+ expect(@client.set("key2", "1", xx: true)).to eq(true)
expect(@client.get("key2")).to eq("1")
end
it "does not set the key if both xx and nx option are specified" do
- expect(@client.set("key2", "1", { :nx => true, :xx => true })).to eq(false)
+ expect(@client.set("key2", "1", nx: true, xx: true)).to eq(false)
expect(@client.get("key2")).to be_nil
end
end
diff --git a/spec/memory_spec.rb b/spec/memory_spec.rb
index f692f14..8520e6b 100644
--- a/spec/memory_spec.rb
+++ b/spec/memory_spec.rb
@@ -21,7 +21,7 @@ def result
cursor = 0
loop do
- cursor, keys = redis.scan(cursor, match_arguments)
+ cursor, keys = redis.scan(cursor, **match_arguments)
returned_keys += keys
break if cursor == '0'
end
diff --git a/spec/sorted_sets_spec.rb b/spec/sorted_sets_spec.rb
index f74f55d..230924e 100644
--- a/spec/sorted_sets_spec.rb
+++ b/spec/sorted_sets_spec.rb
@@ -685,13 +685,13 @@ module FakeRedis
context "with {nx: true, incr: true}" do
let(:options) { {nx: true, incr: true} }
it "should increment to the provided score only if the element is new and return the element's score" do
- expect(@client.zadd("key", 1, "first", options)).to eq(1.0)
+ expect(@client.zadd("key", 1, "first", **options)).to eq(1.0)
expect(@client.zscore("key", "first")).to eq(1.0)
- expect(@client.zadd("key", 2, "second", options)).to eq(2.0)
+ expect(@client.zadd("key", 2, "second", **options)).to eq(2.0)
expect(@client.zscore("key", "second")).to eq(2.0)
- expect(@client.zadd("key", 99, "first", options)).to be_nil
+ expect(@client.zadd("key", 99, "first", **options)).to be_nil
expect(@client.zscore("key", "first")).to eq(1.0)
end
end
@@ -699,11 +699,11 @@ module FakeRedis
context "with {nx: true, ch: true}" do
let(:options) { {nx: true, ch: true} }
it "should add only new elements, not update existing elements, and return the number of added elements" do
- expect(@client.zadd("key", 1, "first", options)).to eq(true)
- expect(@client.zadd("key", 1, "first", options)).to eq(false)
+ expect(@client.zadd("key", 1, "first", **options)).to eq(true)
+ expect(@client.zadd("key", 1, "first", **options)).to eq(false)
# add two new elements
- expect(@client.zadd("key", [99, "first", 2, "second", 3, "third"], options)).to eq(2)
+ expect(@client.zadd("key", [99, "first", 2, "second", 3, "third"], **options)).to eq(2)
expect(@client.zscore("key", "first")).to eq(1.0)
end
end
@@ -712,19 +712,19 @@ module FakeRedis
let(:options) { {nx: true, incr: true, ch: true} }
it "should add only new elements" do
- expect(@client.zadd("key", 1, "first", options)).to eq(1.0)
- expect(@client.zadd("key", 99, "first", options)).to be_nil
+ expect(@client.zadd("key", 1, "first", **options)).to eq(1.0)
+ expect(@client.zadd("key", 99, "first", **options)).to be_nil
expect(@client.zscore("key", "first")).to eq(1.0)
end
# when INCR is present, return value is always the new score of member
it "should return the score of the new member" do
- expect(@client.zadd("key", 2, "second", options)).to eq(2.0)
+ expect(@client.zadd("key", 2, "second", **options)).to eq(2.0)
end
it "should return nil when the member already exists" do
@client.zadd("key", 1, "first")
- expect(@client.zadd("key", 99, "first", options)).to be_nil
+ expect(@client.zadd("key", 99, "first", **options)).to be_nil
end
end
@@ -733,12 +733,12 @@ module FakeRedis
before { @client.zadd("key", 1, "existing") }
it "should return nil if the member does not already exist" do
- expect(@client.zadd("key", 1, "new1", options)).to be_nil
+ expect(@client.zadd("key", 1, "new1", **options)).to be_nil
expect(@client.zscore("key", "new1")).to be_nil
end
it "should increment only existing elements" do
- expect(@client.zadd("key", [11, "existing"], options)).to eq(12.0)
+ expect(@client.zadd("key", [11, "existing"], **options)).to eq(12.0)
expect(@client.zscore("key", "existing")).to eq(12.0)
end
end
@@ -748,8 +748,8 @@ module FakeRedis
it "should return the number of updated elements and not add new members" do
@client.zadd("key", 1, "first")
- expect(@client.zadd("key", 99, "first", options)).to eq(true)
- expect(@client.zadd("key", [100, "first", 2, "second"], options)).to eq(1.0)
+ expect(@client.zadd("key", 99, "first", **options)).to eq(true)
+ expect(@client.zadd("key", [100, "first", 2, "second"], **options)).to eq(1.0)
expect(@client.zscore("key", "second")).to be_nil
end
end
@@ -760,11 +760,11 @@ module FakeRedis
# when INCR is present, return value is always the new score of member
it "should return the new score of the inserted member" do
- expect(@client.zadd("key", 2, "existing", options)).to eq(3.0)
+ expect(@client.zadd("key", 2, "existing", **options)).to eq(3.0)
end
it "should increment only existing elements" do
- expect(@client.zadd("key", 1, "new", options)).to be_nil
+ expect(@client.zadd("key", 1, "new", **options)).to be_nil
end
end
end
|