Skip to content

Commit

Permalink
Default exists_returns_integer = true
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Oct 7, 2021
1 parent 274d036 commit cf7e628
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require_relative "redis/errors"

class Redis
@exists_returns_integer = true

class << self
attr_reader :exists_returns_integer

Expand Down
10 changes: 5 additions & 5 deletions test/lint/value_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
module Lint
module ValueTypes
def test_exists
assert_equal false, r.exists("foo")
assert_equal 0, r.exists("foo")

r.set("foo", "s1")

assert_equal true, r.exists("foo")
assert_equal 1, r.exists("foo")
end

def test_exists_integer
previous_exists_returns_integer = Redis.exists_returns_integer
Redis.exists_returns_integer = true
assert_equal 0, r.exists("foo")
Redis.exists_returns_integer = false
assert_equal false, r.exists("foo")

r.set("foo", "s1")

assert_equal 1, r.exists("foo")
assert_equal true, r.exists("foo")
ensure
Redis.exists_returns_integer = previous_exists_returns_integer
end
Expand Down

0 comments on commit cf7e628

Please sign in to comment.