spicerack 0.19.1 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spicerack/rspec/configurable/matchers.rb +9 -2
- data/lib/spicerack/rspec/configurable/matchers/configuration/define_config_option.rb +47 -0
- data/lib/spicerack/rspec/configurable/matchers/global/delegate_config_to.rb +64 -0
- data/lib/spicerack/rspec/configurable/spec_helper.rb +2 -1
- data/lib/spicerack/version.rb +1 -1
- metadata +18 -17
- data/lib/spicerack/rspec/configurable/matchers/define_config_option.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d8f8c4cd9f9bf491920b112806922319441f328cbae676f435107bd0abbb78
|
4
|
+
data.tar.gz: 6b0c0b806356f0605e99aff509e9b3566f5e2004b8272d57c47fcb69f6705bd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98471d11ba2fbe8eba7df1aac4b0901bb8ac7e0cc92c9af26be52300b0a789c4163ec3863f14b44f1ac5922808c719130fc7d002b619ca15b3b84b20223e4c3f
|
7
|
+
data.tar.gz: a2e5b336954f85e994a0a433a753a9e78a582c388f212bd4de143d6bb1408db1fdd79924ccc20515179d3211c2dd9a606ad45659e015216823b614acd29bcc22
|
@@ -4,10 +4,17 @@ module Spicerack
|
|
4
4
|
module RSpec
|
5
5
|
module Configurable
|
6
6
|
module Matchers
|
7
|
-
|
7
|
+
module Configuration
|
8
|
+
extend ::RSpec::Matchers::DSL
|
9
|
+
end
|
10
|
+
|
11
|
+
module Global
|
12
|
+
extend ::RSpec::Matchers::DSL
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
12
18
|
|
13
|
-
require_relative "matchers/define_config_option"
|
19
|
+
require_relative "matchers/configuration/define_config_option"
|
20
|
+
require_relative "matchers/global/delegate_config_to"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spicerack
|
4
|
+
module RSpec
|
5
|
+
module Configurable
|
6
|
+
module Matchers
|
7
|
+
module Configuration
|
8
|
+
# RSpec matcher to test options of a Configurable class
|
9
|
+
#
|
10
|
+
# class ExampleConfiguration
|
11
|
+
# include Spicerack::Configurable
|
12
|
+
#
|
13
|
+
# option :foo
|
14
|
+
# option :bar, default: :baz
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# RSpec.describe ExampleConfiguration, type: :configuration do
|
18
|
+
# subject { described_class.new }
|
19
|
+
#
|
20
|
+
# it { is_expected.to define_config_option :foo }
|
21
|
+
# it { is_expected.to define_config_option :bar, default: :baz }
|
22
|
+
# end
|
23
|
+
define :define_config_option do |option, default: nil|
|
24
|
+
description { "define config option #{option}" }
|
25
|
+
failure_message { "expected #{@obj} to define config option #{option} #{with_default(default)}".strip }
|
26
|
+
|
27
|
+
match do |obj|
|
28
|
+
@obj = obj
|
29
|
+
|
30
|
+
if obj.is_a? Spicerack::Configurable::ConfigObject
|
31
|
+
expect(obj).to define_option option, default: default
|
32
|
+
else
|
33
|
+
expect(obj).to respond_to :config
|
34
|
+
expect(obj.config.instance_variable_get(:@config)).to be_present
|
35
|
+
expect(obj.config.instance_variable_get(:@config)).to define_option option, default: default
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def with_default(default)
|
40
|
+
"with default #{default}" unless default.nil?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spicerack
|
4
|
+
module RSpec
|
5
|
+
module Configurable
|
6
|
+
module Matchers
|
7
|
+
module Global
|
8
|
+
# RSpec matcher to test options of a Configurable class
|
9
|
+
#
|
10
|
+
# module MyGem
|
11
|
+
# include Spicerack::Configurable::ConfigDelegation
|
12
|
+
# delegates_to_configuration
|
13
|
+
#
|
14
|
+
# class MyGem::Configuration
|
15
|
+
# include Spicerack::Configurable
|
16
|
+
# ...
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# RSpec.describe ExampleConfiguration, type: :configuration do
|
21
|
+
# subject { described_class }
|
22
|
+
#
|
23
|
+
# it { is_expected.to delegate_config_to MyGem::Configuration }
|
24
|
+
# end
|
25
|
+
define :delegate_config_to do |config_module|
|
26
|
+
attr_reader :obj, :config_module
|
27
|
+
|
28
|
+
description { "delegates configuration methods to #{config_module}" }
|
29
|
+
|
30
|
+
failure_message { "expected #{target} to delegate configuration methods to #{config_module}" }
|
31
|
+
failure_message_when_negated { "expected #{target} not to delegate configuration methods to #{config_module}" }
|
32
|
+
|
33
|
+
match_unless_raises do |obj|
|
34
|
+
@obj = obj
|
35
|
+
@config_module = config_module
|
36
|
+
|
37
|
+
stub_configuration_methods
|
38
|
+
|
39
|
+
expect(target.config).to eq config_return_value
|
40
|
+
expect(target.configure).to eq configure_return_value
|
41
|
+
end
|
42
|
+
|
43
|
+
def target
|
44
|
+
obj.is_a?(Module) ? obj : obj.class
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_configuration_methods
|
48
|
+
allow(config_module).to receive(:config).and_return(config_return_value)
|
49
|
+
allow(config_module).to receive(:configure).and_return(configure_return_value)
|
50
|
+
end
|
51
|
+
|
52
|
+
def config_return_value
|
53
|
+
@config_return_value ||= double
|
54
|
+
end
|
55
|
+
|
56
|
+
def configure_return_value
|
57
|
+
@configure_return_value ||= double
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -4,6 +4,7 @@ require_relative "matchers"
|
|
4
4
|
require_relative "dsl"
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
|
-
config.include(Spicerack::RSpec::Configurable::Matchers
|
7
|
+
config.include(Spicerack::RSpec::Configurable::Matchers::Global)
|
8
|
+
config.include(Spicerack::RSpec::Configurable::Matchers::Configuration, type: :configuration)
|
8
9
|
config.include(Spicerack::RSpec::Configurable::DSL, type: :configuration)
|
9
10
|
end
|
data/lib/spicerack/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spicerack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-
|
14
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: around_the_world
|
@@ -19,70 +19,70 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.19.
|
22
|
+
version: 0.19.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.19.
|
29
|
+
version: 0.19.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: redis_hash
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.19.
|
36
|
+
version: 0.19.2
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.19.
|
43
|
+
version: 0.19.2
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: short_circu_it
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - '='
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.19.
|
50
|
+
version: 0.19.2
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - '='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.19.
|
57
|
+
version: 0.19.2
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: technologic
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - '='
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.19.
|
64
|
+
version: 0.19.2
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.19.
|
71
|
+
version: 0.19.2
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: tablesalt
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - '='
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.19.
|
78
|
+
version: 0.19.2
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.19.
|
85
|
+
version: 0.19.2
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: bundler
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,28 +207,28 @@ dependencies:
|
|
207
207
|
requirements:
|
208
208
|
- - '='
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 0.19.
|
210
|
+
version: 0.19.2
|
211
211
|
type: :development
|
212
212
|
prerelease: false
|
213
213
|
version_requirements: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
215
|
- - '='
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version: 0.19.
|
217
|
+
version: 0.19.2
|
218
218
|
- !ruby/object:Gem::Dependency
|
219
219
|
name: spicerack-styleguide
|
220
220
|
requirement: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
222
|
- - '='
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version: 0.19.
|
224
|
+
version: 0.19.2
|
225
225
|
type: :development
|
226
226
|
prerelease: false
|
227
227
|
version_requirements: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
229
|
- - '='
|
230
230
|
- !ruby/object:Gem::Version
|
231
|
-
version: 0.19.
|
231
|
+
version: 0.19.2
|
232
232
|
- !ruby/object:Gem::Dependency
|
233
233
|
name: will_paginate
|
234
234
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,7 +310,8 @@ files:
|
|
310
310
|
- lib/spicerack/root_object.rb
|
311
311
|
- lib/spicerack/rspec/configurable/dsl.rb
|
312
312
|
- lib/spicerack/rspec/configurable/matchers.rb
|
313
|
-
- lib/spicerack/rspec/configurable/matchers/define_config_option.rb
|
313
|
+
- lib/spicerack/rspec/configurable/matchers/configuration/define_config_option.rb
|
314
|
+
- lib/spicerack/rspec/configurable/matchers/global/delegate_config_to.rb
|
314
315
|
- lib/spicerack/rspec/configurable/spec_helper.rb
|
315
316
|
- lib/spicerack/rspec/custom_matchers.rb
|
316
317
|
- lib/spicerack/rspec/custom_matchers/define_argument.rb
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spicerack
|
4
|
-
module RSpec
|
5
|
-
module Configurable
|
6
|
-
module Matchers
|
7
|
-
# RSpec matcher to test options of a Configurable class
|
8
|
-
#
|
9
|
-
# class ExampleConfiguration
|
10
|
-
# include Spicerack::Configurable
|
11
|
-
#
|
12
|
-
# option :foo
|
13
|
-
# option :bar, default: :baz
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# RSpec.describe ExampleConfiguration, type: :configuration do
|
17
|
-
# subject { described_class.new }
|
18
|
-
#
|
19
|
-
# it { is_expected.to define_config_option :foo }
|
20
|
-
# it { is_expected.to define_config_option :bar, default: :baz }
|
21
|
-
# end
|
22
|
-
define :define_config_option do |option, default: nil|
|
23
|
-
description { "define config option #{option}" }
|
24
|
-
failure_message { "expected #{subject} to define config option #{option} #{with_default(default)}".strip }
|
25
|
-
|
26
|
-
match do |obj|
|
27
|
-
if obj.is_a? Spicerack::Configurable::ConfigObject
|
28
|
-
expect(obj).to define_option option, default: default
|
29
|
-
else
|
30
|
-
expect(obj).to respond_to :config
|
31
|
-
expect(obj.config.instance_variable_get(:@config)).to be_present
|
32
|
-
expect(obj.config.instance_variable_get(:@config)).to define_option option, default: default
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def with_default(default)
|
37
|
-
"with default #{default}" unless default.nil?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|