hella-redis 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.l.yml +9 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/.t.yml +6 -0
- data/Gemfile +5 -1
- data/README.md +31 -22
- data/hella-redis.gemspec +13 -9
- data/lib/hella-redis.rb +13 -15
- data/lib/hella-redis/connection_pool.rb +15 -18
- data/lib/hella-redis/connection_pool_spy.rb +7 -11
- data/lib/hella-redis/connection_spy.rb +10 -11
- data/lib/hella-redis/version.rb +3 -1
- data/log/{.gitkeep → .keep} +0 -0
- data/test/helper.rb +4 -11
- data/test/support/factory.rb +10 -9
- data/test/unit/connection_pool_spy_tests.rb +23 -25
- data/test/unit/connection_pool_tests.rb +7 -8
- data/test/unit/connection_spy_tests.rb +13 -14
- data/test/unit/hella-redis_tests.rb +28 -34
- metadata +90 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c11849c706992fadaf24788eab0d8e5998350e08b429646c772097fc32cd048
|
4
|
+
data.tar.gz: c291e238be0cff2321ea88058c3c3eb22496702595b6f6900e9a80570901865e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f8ea4a862606da3b802ff7a841320dfe05ca6cea1304aa05b089b022d7711f4bc2779c9032b4cc231a731e9b6e9b4c3ab096c7dab35cdd6c3b731f0c65bcbb8
|
7
|
+
data.tar.gz: fe824c06209a19cea1e0b72ac261bf788e9b6d044803acd3003e5216be0ea1429fd2c1e37fd5a34227831d32f0d822668729483710477333ae053e3a38aaf022
|
data/.l.yml
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.3
|
data/.t.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,13 +8,14 @@ This gem is a wrapper that builds a connection pool of redis connections. It al
|
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
# create
|
11
|
-
@redis =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
@redis =
|
12
|
+
HellaRedis.new(
|
13
|
+
timeout: 1,
|
14
|
+
size: 5,
|
15
|
+
redis_ns: "hella-redis-test",
|
16
|
+
driver: "ruby",
|
17
|
+
url: "redis://localhost:6379/0"
|
18
|
+
) # => HellaRedis:ConnectionPool instance
|
18
19
|
|
19
20
|
# it's actually a pool of connections
|
20
21
|
@redis.connection do |connection|
|
@@ -26,24 +27,25 @@ end
|
|
26
27
|
### Test Mode
|
27
28
|
|
28
29
|
```ruby
|
29
|
-
ENV[
|
30
|
-
|
31
|
-
@redis_spy =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
ENV["HELLA_REDIS_TEST_MODE"] = "yes" # set to anything "truthy"
|
31
|
+
|
32
|
+
@redis_spy =
|
33
|
+
HellaRedis.new({
|
34
|
+
timeout: 1,
|
35
|
+
size: 5,
|
36
|
+
redis_ns: "hella-redis-test",
|
37
|
+
driver: "ruby",
|
38
|
+
url: "redis://localhost:6379/0"
|
39
|
+
}) # => HellaRedis::ConnectionPoolSpy instance
|
40
|
+
|
41
|
+
@redis_spy.connection do |connection|
|
42
|
+
connection # => HellaRedis::ConnectionSpy instance
|
43
|
+
connection.info
|
42
44
|
end
|
43
45
|
|
44
46
|
@redis_spy.calls.size # => 1
|
45
47
|
@redis_spy.calls.first.tap do |call|
|
46
|
-
call.command # =>
|
48
|
+
call.command # => :info
|
47
49
|
call.args # => nil
|
48
50
|
call.block # => nil
|
49
51
|
end
|
@@ -52,13 +54,20 @@ end
|
|
52
54
|
@redis_spy.connection_calls.first.tap do |connection_call|
|
53
55
|
connection_call.block # => block instance
|
54
56
|
end
|
57
|
+
|
58
|
+
Assert.stub(@redis_spy.connection_spy, :get).with("some-key"){ "some-value" }
|
59
|
+
value = @redis_spy.connection do |connection|
|
60
|
+
connection.get("some_key")
|
61
|
+
end
|
62
|
+
assert_that("some-value").equals(value)
|
63
|
+
@redis_spy.calls.size # => 1 (unchanged b/c we stubbed the :get method)
|
55
64
|
```
|
56
65
|
|
57
66
|
## Installation
|
58
67
|
|
59
68
|
Add this line to your application's Gemfile:
|
60
69
|
|
61
|
-
gem
|
70
|
+
gem "hella-redis"
|
62
71
|
|
63
72
|
And then execute:
|
64
73
|
|
data/hella-redis.gemspec
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require "hella-redis/version"
|
5
7
|
|
@@ -8,20 +10,22 @@ Gem::Specification.new do |gem|
|
|
8
10
|
gem.version = HellaRedis::VERSION
|
9
11
|
gem.authors = ["Kelly Redding", "Collin Redding"]
|
10
12
|
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
11
|
-
gem.summary =
|
12
|
-
gem.description =
|
13
|
+
gem.summary = "It's-a hella-redis!"
|
14
|
+
gem.description = "It's-a hella-redis!"
|
13
15
|
gem.homepage = "http://github.com/redding/hella-redis"
|
14
|
-
gem.license =
|
16
|
+
gem.license = "MIT"
|
15
17
|
|
16
|
-
gem.files = `git ls-files`.split(
|
18
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
19
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
21
|
gem.require_paths = ["lib"]
|
20
22
|
|
21
|
-
gem.
|
23
|
+
gem.required_ruby_version = "~> 2.5"
|
22
24
|
|
23
|
-
gem.
|
24
|
-
gem.
|
25
|
-
gem.add_dependency("connection_pool", ["= 0.9.2"]) # temp, for 1.8.7 support
|
25
|
+
gem.add_development_dependency("assert", ["~> 2.19.6"])
|
26
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.3"])
|
26
27
|
|
28
|
+
gem.add_dependency("redis", ["~> 4.2.5"])
|
29
|
+
gem.add_dependency("redis-namespace", ["~> 1.8.1"])
|
30
|
+
gem.add_dependency("connection_pool", ["~> 2.2.5"])
|
27
31
|
end
|
data/lib/hella-redis.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis/connection_pool'
|
3
|
-
require 'hella-redis/connection_pool_spy'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
3
|
+
require "hella-redis/version"
|
4
|
+
require "hella-redis/connection_pool"
|
5
|
+
require "hella-redis/connection_pool_spy"
|
6
6
|
|
7
|
+
module HellaRedis
|
7
8
|
def self.new(args)
|
8
|
-
|
9
|
+
send(ENV["HELLA_REDIS_TEST_MODE"] ? :mock : :real, args)
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.real(args)
|
@@ -17,7 +18,6 @@ module HellaRedis
|
|
17
18
|
end
|
18
19
|
|
19
20
|
class Config
|
20
|
-
|
21
21
|
attr_reader :url, :driver, :redis_ns, :timeout, :size
|
22
22
|
|
23
23
|
def initialize(args = nil)
|
@@ -29,18 +29,16 @@ module HellaRedis
|
|
29
29
|
@size = args[:size] || 1
|
30
30
|
end
|
31
31
|
|
32
|
-
def ==(
|
33
|
-
if
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
def ==(other)
|
33
|
+
if other.is_a?(Config)
|
34
|
+
url == other.url &&
|
35
|
+
driver == other.driver &&
|
36
|
+
redis_ns == other.redis_ns &&
|
37
|
+
timeout == other.timeout &&
|
38
|
+
size == other.size
|
39
39
|
else
|
40
40
|
super
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
43
|
end
|
45
|
-
|
46
44
|
end
|
@@ -1,23 +1,22 @@
|
|
1
|
-
|
2
|
-
require 'redis'
|
3
|
-
require 'redis-namespace'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
3
|
+
require "connection_pool"
|
4
|
+
require "redis"
|
5
|
+
require "redis-namespace"
|
6
6
|
|
7
|
+
module HellaRedis
|
7
8
|
class ConnectionPool
|
8
|
-
|
9
9
|
def initialize(config)
|
10
|
-
@pool =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
:
|
18
|
-
|
19
|
-
|
20
|
-
end
|
10
|
+
@pool =
|
11
|
+
::ConnectionPool.new(
|
12
|
+
timeout: config.timeout,
|
13
|
+
size: config.size,
|
14
|
+
) do
|
15
|
+
::Redis::Namespace.new(
|
16
|
+
config.redis_ns,
|
17
|
+
redis: ::Redis.new(url: config.url, driver: config.driver),
|
18
|
+
)
|
19
|
+
end
|
21
20
|
end
|
22
21
|
|
23
22
|
def connection
|
@@ -25,7 +24,5 @@ module HellaRedis
|
|
25
24
|
yield connection if block_given?
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
30
|
-
|
31
28
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis/connection_pool'
|
3
|
-
require 'hella-redis/connection_spy'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
3
|
+
require "redis"
|
4
|
+
require "hella-redis/connection_pool"
|
5
|
+
require "hella-redis/connection_spy"
|
6
6
|
|
7
|
+
module HellaRedis
|
7
8
|
class ConnectionPoolSpy
|
8
|
-
|
9
9
|
attr_reader :config, :connection_spy, :connection_calls
|
10
10
|
|
11
11
|
def initialize(config)
|
@@ -28,14 +28,10 @@ module HellaRedis
|
|
28
28
|
@connection_spy.calls = []
|
29
29
|
end
|
30
30
|
|
31
|
-
def ==(
|
32
|
-
if
|
33
|
-
self.config == other_pool_spy.config
|
34
|
-
end
|
31
|
+
def ==(other)
|
32
|
+
config == other.config if other.is_a?(ConnectionPoolSpy)
|
35
33
|
end
|
36
34
|
|
37
35
|
ConnectionCall = Struct.new(:block)
|
38
|
-
|
39
36
|
end
|
40
|
-
|
41
37
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "redis"
|
4
4
|
|
5
|
+
module HellaRedis
|
5
6
|
class ConnectionSpy
|
6
|
-
|
7
7
|
attr_accessor :calls
|
8
8
|
|
9
9
|
def initialize(config)
|
10
|
-
@instance =
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
@instance =
|
11
|
+
::Redis.new(
|
12
|
+
url: config.url,
|
13
|
+
driver: config.driver,
|
14
|
+
)
|
14
15
|
@calls = []
|
15
16
|
end
|
16
17
|
|
@@ -25,19 +26,17 @@ module HellaRedis
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def method_missing(name, *args, &block)
|
28
|
-
if
|
29
|
+
if respond_to?(name)
|
29
30
|
@calls << ConnectionCall.new(name, args, block)
|
30
31
|
else
|
31
32
|
super
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
+
def respond_to_missing?(*args)
|
36
37
|
super || @instance.respond_to?(*args)
|
37
38
|
end
|
38
39
|
|
39
40
|
ConnectionCall = Struct.new(:command, :args, :block)
|
40
|
-
|
41
41
|
end
|
42
|
-
|
43
42
|
end
|
data/lib/hella-redis/version.rb
CHANGED
data/log/{.gitkeep → .keep}
RENAMED
File without changes
|
data/test/helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# this file is automatically required when you run `assert`
|
2
4
|
# put any test helpers here
|
3
5
|
|
@@ -5,15 +7,6 @@
|
|
5
7
|
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
6
8
|
|
7
9
|
# require pry for debugging (`binding.pry`)
|
8
|
-
require
|
9
|
-
|
10
|
-
require 'test/support/factory'
|
11
|
-
|
12
|
-
# 1.8.7 backfills
|
10
|
+
require "pry"
|
13
11
|
|
14
|
-
|
15
|
-
if !(a = Array.new).respond_to?(:sample) && a.respond_to?(:choice)
|
16
|
-
class Array
|
17
|
-
alias_method :sample, :choice
|
18
|
-
end
|
19
|
-
end
|
12
|
+
require "test/support/factory"
|
data/test/support/factory.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "assert/factory"
|
4
|
+
require "hella-redis"
|
3
5
|
|
4
6
|
module Factory
|
5
7
|
extend Assert::Factory
|
6
8
|
|
7
9
|
def self.config(args = nil)
|
8
|
-
HellaRedis::Config.new(
|
10
|
+
HellaRedis::Config.new(config_args(args))
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.config_args(args = nil)
|
12
|
-
{ :
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
14
|
+
{ timeout: Factory.integer,
|
15
|
+
size: Factory.integer(5),
|
16
|
+
redis_ns: "hella-redis-test-#{Factory.string}",
|
17
|
+
url: "redis://localhost:6379/0",
|
18
|
+
driver: "ruby",
|
17
19
|
}.merge(args || {})
|
18
20
|
end
|
19
|
-
|
20
21
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis/connection_pool_spy'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require "assert"
|
4
|
+
require "hella-redis/connection_pool_spy"
|
5
5
|
|
6
|
-
|
6
|
+
require "hella-redis/connection_spy"
|
7
7
|
|
8
|
+
class HellaRedis::ConnectionPoolSpy
|
8
9
|
class UnitTests < Assert::Context
|
9
10
|
desc "HellaRedis::ConnectionPoolSpy"
|
10
11
|
setup do
|
11
|
-
Assert.
|
12
|
-
@
|
13
|
-
Assert.stub_send(HellaRedis::ConnectionSpy, :new, *args)
|
12
|
+
Assert.stub_tap_on_call(HellaRedis::ConnectionSpy, :new) do |_, call|
|
13
|
+
@connection_spy_new_call = call
|
14
14
|
end
|
15
15
|
|
16
16
|
@config = Factory.config
|
@@ -22,55 +22,53 @@ class HellaRedis::ConnectionPoolSpy
|
|
22
22
|
should have_imeths :calls, :connection, :reset!
|
23
23
|
|
24
24
|
should "know its config and redis spy" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
assert_that(subject.config).is(@config)
|
26
|
+
assert_that(subject.connection_spy)
|
27
|
+
.is_an_instance_of(HellaRedis::ConnectionSpy)
|
28
|
+
assert_that(@connection_spy_new_call.args).equals([@config])
|
29
29
|
end
|
30
30
|
|
31
31
|
should "default its connection calls" do
|
32
|
-
|
32
|
+
assert_that(subject.connection_calls).equals([])
|
33
33
|
end
|
34
34
|
|
35
35
|
should "know its calls" do
|
36
|
-
|
36
|
+
assert_that(subject.calls).is(subject.connection_spy.calls)
|
37
37
|
end
|
38
38
|
|
39
39
|
should "yield its connection spy using `connection`" do
|
40
40
|
yielded = nil
|
41
41
|
subject.connection{ |c| yielded = c }
|
42
42
|
|
43
|
-
|
43
|
+
assert_that(yielded).is(subject.connection_spy)
|
44
44
|
end
|
45
45
|
|
46
46
|
should "track calls to connection" do
|
47
|
-
block = proc{ |
|
47
|
+
block = proc{ |_c| Factory.string }
|
48
48
|
subject.connection(&block)
|
49
49
|
|
50
50
|
call = subject.connection_calls.last
|
51
|
-
|
51
|
+
assert_that(call.block).is(block)
|
52
52
|
end
|
53
53
|
|
54
54
|
should "remove all calls on `reset!`" do
|
55
|
-
subject.connection
|
55
|
+
subject.connection(&:info)
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
assert_that(subject.calls.empty?).is_false
|
58
|
+
assert_that(subject.connection_calls.empty?).is_false
|
59
59
|
|
60
60
|
subject.reset!
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
assert_that(subject.calls.empty?).is_true
|
63
|
+
assert_that(subject.connection_calls.empty?).is_true
|
64
64
|
end
|
65
65
|
|
66
66
|
should "know if it is equal to another pool spy" do
|
67
67
|
equal_pool_spy = HellaRedis::ConnectionPoolSpy.new(@config)
|
68
|
-
|
68
|
+
assert_that(equal_pool_spy).equals(subject)
|
69
69
|
|
70
70
|
not_equal_config = HellaRedis::ConnectionPoolSpy.new(Factory.config)
|
71
|
-
|
71
|
+
assert_that(not_equal_config).does_not_equal(subject)
|
72
72
|
end
|
73
|
-
|
74
73
|
end
|
75
|
-
|
76
74
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis/connection_pool'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require "assert"
|
4
|
+
require "hella-redis/connection_pool"
|
5
5
|
|
6
|
-
|
6
|
+
require "redis-namespace"
|
7
7
|
|
8
|
+
class HellaRedis::ConnectionPool
|
8
9
|
class UnitTests < Assert::Context
|
9
10
|
desc "HellaRedis::Connection"
|
10
11
|
setup do
|
@@ -16,11 +17,9 @@ class HellaRedis::ConnectionPool
|
|
16
17
|
|
17
18
|
should "build a redis namespace and yield it using `connection`" do
|
18
19
|
subject.connection do |connection|
|
19
|
-
|
20
|
-
|
20
|
+
assert_that(connection).is_an_instance_of(::Redis::Namespace)
|
21
|
+
assert_that{ connection.get(Factory.string) }.does_not_raise
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis/connection_spy'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "hella-redis/connection_spy"
|
5
5
|
|
6
|
+
class HellaRedis::ConnectionSpy
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "HellaRedis::ConnectionSpy"
|
8
9
|
setup do
|
@@ -14,37 +15,35 @@ class HellaRedis::ConnectionSpy
|
|
14
15
|
should have_imeths :pipelined, :multi
|
15
16
|
|
16
17
|
should "default its calls" do
|
17
|
-
|
18
|
+
assert_that(subject.calls).equals([])
|
18
19
|
end
|
19
20
|
|
20
21
|
should "track redis calls made to it" do
|
21
|
-
|
22
|
+
assert_that(subject.respond_to?(:set)).is_true
|
22
23
|
|
23
24
|
key, value = [Factory.string, Factory.string]
|
24
25
|
subject.set(key, value)
|
25
26
|
|
26
27
|
call = subject.calls.first
|
27
|
-
|
28
|
-
|
28
|
+
assert_that(call.command).equals(:set)
|
29
|
+
assert_that(call.args).equals([key, value])
|
29
30
|
end
|
30
31
|
|
31
32
|
should "track the call and yield itself using `pipelined`" do
|
32
33
|
subject.pipelined{ |c| c.set(Factory.string, Factory.string) }
|
33
|
-
|
34
|
+
assert_that(subject.calls.map(&:command)).equals([:pipelined, :set])
|
34
35
|
end
|
35
36
|
|
36
37
|
should "track the call and yield itself using `multi`" do
|
37
38
|
subject.multi{ |c| c.set(Factory.string, Factory.string) }
|
38
|
-
|
39
|
+
assert_that(subject.calls.map(&:command)).equals([:multi, :set])
|
39
40
|
end
|
40
41
|
|
41
42
|
should "raise no method errors for non-redis methods" do
|
42
|
-
|
43
|
-
|
43
|
+
assert_that(subject.respond_to?(:super_awesome_set)).is_false
|
44
|
+
assert_that{
|
44
45
|
subject.super_awesome_set(Factory.string, Factory.string)
|
45
|
-
|
46
|
+
}.raises(NoMethodError)
|
46
47
|
end
|
47
|
-
|
48
48
|
end
|
49
|
-
|
50
49
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'hella-redis'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "hella-redis"
|
5
5
|
|
6
|
+
module HellaRedis
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "HellaRedis"
|
8
9
|
setup do
|
@@ -12,7 +13,6 @@ module HellaRedis
|
|
12
13
|
subject{ @module }
|
13
14
|
|
14
15
|
should have_imeths :new, :real, :mock
|
15
|
-
|
16
16
|
end
|
17
17
|
|
18
18
|
class NewRealMockTests < UnitTests
|
@@ -21,46 +21,44 @@ module HellaRedis
|
|
21
21
|
|
22
22
|
@pool = ConnectionPool.new(@config)
|
23
23
|
@pool_new_called_with = nil
|
24
|
-
Assert.
|
25
|
-
@
|
24
|
+
Assert.stub_on_call(ConnectionPool, :new) do |call|
|
25
|
+
@pool_new_call = call
|
26
26
|
@pool
|
27
27
|
end
|
28
28
|
|
29
29
|
@pool_spy = ConnectionPoolSpy.new(@config)
|
30
30
|
@pool_spy_new_called_with = nil
|
31
|
-
Assert.
|
32
|
-
@
|
31
|
+
Assert.stub_on_call(ConnectionPoolSpy, :new) do |call|
|
32
|
+
@pool_spy_new_call = call
|
33
33
|
@pool_spy
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
37
36
|
end
|
38
37
|
|
39
38
|
class NewTests < NewRealMockTests
|
40
39
|
desc "`new`"
|
41
40
|
setup do
|
42
|
-
@current_test_mode = ENV[
|
43
|
-
ENV[
|
41
|
+
@current_test_mode = ENV["HELLA_REDIS_TEST_MODE"]
|
42
|
+
ENV["HELLA_REDIS_TEST_MODE"] = "yes"
|
44
43
|
end
|
45
44
|
teardown do
|
46
|
-
ENV[
|
45
|
+
ENV["HELLA_REDIS_TEST_MODE"] = @current_test_mode
|
47
46
|
end
|
48
47
|
|
49
48
|
should "build and return a new connection pool" do
|
50
|
-
ENV.delete(
|
49
|
+
ENV.delete("HELLA_REDIS_TEST_MODE")
|
51
50
|
redis = subject.new(@config_args)
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
assert_that(@pool_new_call.args).equals([@config])
|
53
|
+
assert_that(redis).equals(@pool)
|
55
54
|
end
|
56
55
|
|
57
56
|
should "build and return a connection pool spy in test mode" do
|
58
57
|
redis = subject.new(@config_args)
|
59
58
|
|
60
|
-
|
61
|
-
|
59
|
+
assert_that(@pool_spy_new_call.args).equals([@config])
|
60
|
+
assert_that(redis).equals(@pool_spy)
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
65
63
|
|
66
64
|
class RealTests < NewRealMockTests
|
@@ -69,10 +67,9 @@ module HellaRedis
|
|
69
67
|
should "build and return a connection pool spy" do
|
70
68
|
redis = subject.real(@config_args)
|
71
69
|
|
72
|
-
|
73
|
-
|
70
|
+
assert_that(@pool_new_call.args).equals([@config])
|
71
|
+
assert_that(redis).equals(@pool)
|
74
72
|
end
|
75
|
-
|
76
73
|
end
|
77
74
|
|
78
75
|
class MockTests < NewRealMockTests
|
@@ -81,10 +78,9 @@ module HellaRedis
|
|
81
78
|
should "build and return a connection pool spy" do
|
82
79
|
redis = subject.mock(@config_args)
|
83
80
|
|
84
|
-
|
85
|
-
|
81
|
+
assert_that(@pool_spy_new_call.args).equals([@config])
|
82
|
+
assert_that(redis).equals(@pool_spy)
|
86
83
|
end
|
87
|
-
|
88
84
|
end
|
89
85
|
|
90
86
|
class ConfigTests < UnitTests
|
@@ -97,27 +93,25 @@ module HellaRedis
|
|
97
93
|
should have_readers :url, :driver, :redis_ns, :timeout, :size
|
98
94
|
|
99
95
|
should "know its attributes" do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
assert_that(subject.url).equals(@config_args[:url])
|
97
|
+
assert_that(subject.driver).equals(@config_args[:driver])
|
98
|
+
assert_that(subject.redis_ns).equals(@config_args[:redis_ns])
|
99
|
+
assert_that(subject.timeout).equals(@config_args[:timeout])
|
100
|
+
assert_that(subject.size).equals(@config_args[:size])
|
105
101
|
end
|
106
102
|
|
107
103
|
should "default its size" do
|
108
104
|
@config_args.delete(:size)
|
109
105
|
config = Config.new(@config_args)
|
110
|
-
|
106
|
+
assert_that(config.size).equals(1)
|
111
107
|
end
|
112
108
|
|
113
109
|
should "know if it is equal to another config" do
|
114
110
|
equal_config = Config.new(@config_args)
|
115
|
-
|
111
|
+
assert_that(subject).equals(equal_config)
|
116
112
|
|
117
113
|
not_equal_config = Config.new
|
118
|
-
|
114
|
+
assert_that(subject).does_not_equal(not_equal_config)
|
119
115
|
end
|
120
|
-
|
121
116
|
end
|
122
|
-
|
123
117
|
end
|
metadata
CHANGED
@@ -1,69 +1,99 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hella-redis
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Kelly Redding
|
8
8
|
- Collin Redding
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: assert
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.19.6
|
21
|
+
type: :development
|
17
22
|
prerelease: false
|
18
|
-
|
19
|
-
requirements:
|
20
|
-
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.19.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: much-style-guide
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.6.3
|
23
35
|
type: :development
|
24
|
-
version_requirements: *id001
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: redis
|
27
36
|
prerelease: false
|
28
|
-
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.6.3
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: redis
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 4.2.5
|
33
49
|
type: :runtime
|
34
|
-
version_requirements: *id002
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: redis-namespace
|
37
50
|
prerelease: false
|
38
|
-
|
39
|
-
requirements:
|
40
|
-
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 4.2.5
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: redis-namespace
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.8.1
|
43
63
|
type: :runtime
|
44
|
-
version_requirements: *id003
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: connection_pool
|
47
64
|
prerelease: false
|
48
|
-
|
49
|
-
requirements:
|
50
|
-
- - "
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.1
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: connection_pool
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.2.5
|
53
77
|
type: :runtime
|
54
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.2.5
|
55
84
|
description: It's-a hella-redis!
|
56
|
-
email:
|
85
|
+
email:
|
57
86
|
- kelly@kellyredding.com
|
58
87
|
- collin.redding@me.com
|
59
88
|
executables: []
|
60
|
-
|
61
89
|
extensions: []
|
62
|
-
|
63
90
|
extra_rdoc_files: []
|
64
|
-
|
65
|
-
|
66
|
-
- .
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".l.yml"
|
94
|
+
- ".rubocop.yml"
|
95
|
+
- ".ruby-version"
|
96
|
+
- ".t.yml"
|
67
97
|
- Gemfile
|
68
98
|
- LICENSE
|
69
99
|
- README.md
|
@@ -73,41 +103,38 @@ files:
|
|
73
103
|
- lib/hella-redis/connection_pool_spy.rb
|
74
104
|
- lib/hella-redis/connection_spy.rb
|
75
105
|
- lib/hella-redis/version.rb
|
76
|
-
- log/.
|
106
|
+
- log/.keep
|
77
107
|
- test/helper.rb
|
78
108
|
- test/support/factory.rb
|
79
109
|
- test/unit/connection_pool_spy_tests.rb
|
80
110
|
- test/unit/connection_pool_tests.rb
|
81
111
|
- test/unit/connection_spy_tests.rb
|
82
112
|
- test/unit/hella-redis_tests.rb
|
83
|
-
- tmp/.
|
113
|
+
- tmp/.keep
|
84
114
|
homepage: http://github.com/redding/hella-redis
|
85
|
-
licenses:
|
115
|
+
licenses:
|
86
116
|
- MIT
|
87
117
|
metadata: {}
|
88
|
-
|
89
118
|
post_install_message:
|
90
119
|
rdoc_options: []
|
91
|
-
|
92
|
-
require_paths:
|
120
|
+
require_paths:
|
93
121
|
- lib
|
94
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
-
|
97
|
-
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '2.5'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
103
132
|
requirements: []
|
104
|
-
|
105
|
-
rubyforge_project:
|
106
|
-
rubygems_version: 2.6.6
|
133
|
+
rubygems_version: 3.1.6
|
107
134
|
signing_key:
|
108
135
|
specification_version: 4
|
109
136
|
summary: It's-a hella-redis!
|
110
|
-
test_files:
|
137
|
+
test_files:
|
111
138
|
- test/helper.rb
|
112
139
|
- test/support/factory.rb
|
113
140
|
- test/unit/connection_pool_spy_tests.rb
|