substation 0.0.9 → 0.0.10.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +0 -1
- data/Changelog.md +24 -82
- data/Gemfile.devtools +17 -24
- data/README.md +46 -116
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/mutant.yml +0 -1
- data/config/reek.yml +5 -10
- data/lib/substation.rb +3 -8
- data/lib/substation/chain.rb +64 -108
- data/lib/substation/chain/dsl.rb +30 -57
- data/lib/substation/dispatcher.rb +1 -3
- data/lib/substation/environment.rb +23 -9
- data/lib/substation/environment/dsl.rb +3 -4
- data/lib/substation/observer.rb +2 -4
- data/lib/substation/processor.rb +7 -106
- data/lib/substation/processor/evaluator.rb +42 -83
- data/lib/substation/processor/pivot.rb +25 -0
- data/lib/substation/processor/wrapper.rb +2 -4
- data/lib/substation/request.rb +1 -10
- data/lib/substation/response.rb +0 -11
- data/lib/substation/utils.rb +1 -3
- data/lib/substation/version.rb +1 -3
- data/spec/integration/substation/dispatcher/call_spec.rb +12 -12
- data/spec/spec_helper.rb +21 -30
- data/spec/unit/substation/chain/call_spec.rb +32 -202
- data/spec/unit/substation/chain/dsl/builder/class_methods/call_spec.rb +2 -2
- data/spec/unit/substation/chain/dsl/builder/dsl_spec.rb +6 -8
- data/spec/unit/substation/chain/dsl/builder/failure_chain_spec.rb +30 -0
- data/spec/unit/substation/chain/dsl/chain_spec.rb +2 -1
- data/spec/unit/substation/chain/dsl/class_methods/processors_spec.rb +24 -0
- data/spec/unit/substation/chain/dsl/initialize_spec.rb +19 -0
- data/spec/unit/substation/chain/dsl/processors_spec.rb +21 -9
- data/spec/unit/substation/chain/dsl/use_spec.rb +3 -2
- data/spec/unit/substation/chain/each_spec.rb +9 -5
- data/spec/unit/substation/chain/incoming/result_spec.rb +21 -0
- data/spec/unit/substation/chain/outgoing/call_spec.rb +25 -0
- data/spec/unit/substation/{processor → chain/outgoing}/result_spec.rb +5 -6
- data/spec/unit/substation/dispatcher/action/call_spec.rb +6 -7
- data/spec/unit/substation/dispatcher/action/class_methods/coerce_spec.rb +5 -7
- data/spec/unit/substation/dispatcher/action_names_spec.rb +1 -1
- data/spec/unit/substation/dispatcher/call_spec.rb +3 -3
- data/spec/unit/substation/dispatcher/class_methods/coerce_spec.rb +7 -7
- data/spec/unit/substation/environment/chain_spec.rb +32 -22
- data/spec/unit/substation/environment/class_methods/build_spec.rb +4 -11
- data/spec/unit/substation/environment/dsl/class_methods/registry_spec.rb +3 -5
- data/spec/unit/substation/environment/dsl/register_spec.rb +3 -8
- data/spec/unit/substation/environment/dsl/registry_spec.rb +3 -5
- data/spec/unit/substation/observer/chain/call_spec.rb +3 -5
- data/spec/unit/substation/observer/class_methods/coerce_spec.rb +2 -4
- data/spec/unit/substation/observer/null/call_spec.rb +1 -3
- data/spec/unit/substation/processor/evaluator/call_spec.rb +35 -21
- data/spec/unit/substation/processor/pivot/call_spec.rb +17 -0
- data/spec/unit/substation/processor/wrapper/call_spec.rb +7 -8
- data/spec/unit/substation/request/env_spec.rb +4 -5
- data/spec/unit/substation/request/error_spec.rb +4 -5
- data/spec/unit/substation/request/input_spec.rb +4 -5
- data/spec/unit/substation/request/success_spec.rb +4 -5
- data/spec/unit/substation/response/env_spec.rb +5 -6
- data/spec/unit/substation/response/failure/success_predicate_spec.rb +4 -5
- data/spec/unit/substation/response/input_spec.rb +5 -6
- data/spec/unit/substation/response/output_spec.rb +4 -5
- data/spec/unit/substation/response/request_spec.rb +5 -6
- data/spec/unit/substation/response/success/success_predicate_spec.rb +4 -5
- data/spec/unit/substation/utils/class_methods/coerce_callable_spec.rb +13 -15
- data/spec/unit/substation/utils/class_methods/const_get_spec.rb +6 -6
- data/spec/unit/substation/utils/class_methods/symbolize_keys_spec.rb +4 -4
- data/substation.gemspec +1 -1
- metadata +18 -45
- data/config/rubocop.yml +0 -35
- data/lib/substation/processor/transformer.rb +0 -26
- data/spec/unit/substation/chain/class_methods/failure_response_spec.rb +0 -16
- data/spec/unit/substation/chain/dsl/class_methods/build_spec.rb +0 -24
- data/spec/unit/substation/chain/dsl/failure_chain_spec.rb +0 -35
- data/spec/unit/substation/chain/failure_data/equalizer_spec.rb +0 -46
- data/spec/unit/substation/chain/failure_data/hash_spec.rb +0 -13
- data/spec/unit/substation/environment/equalizer_spec.rb +0 -25
- data/spec/unit/substation/processor/evaluator/class_methods/new_spec.rb +0 -9
- data/spec/unit/substation/processor/evaluator/data/call_spec.rb +0 -34
- data/spec/unit/substation/processor/evaluator/pivot/call_spec.rb +0 -34
- data/spec/unit/substation/processor/evaluator/request/call_spec.rb +0 -34
- data/spec/unit/substation/processor/fallible/name_spec.rb +0 -15
- data/spec/unit/substation/processor/fallible/with_failure_chain_spec.rb +0 -18
- data/spec/unit/substation/processor/incoming/result_spec.rb +0 -25
- data/spec/unit/substation/processor/outgoing/call_spec.rb +0 -28
- data/spec/unit/substation/processor/outgoing/name_spec.rb +0 -14
- data/spec/unit/substation/processor/outgoing/success_predicate_spec.rb +0 -15
- data/spec/unit/substation/processor/success_predicate_spec.rb +0 -22
- data/spec/unit/substation/processor/transformer/call_spec.rb +0 -21
- data/spec/unit/substation/request/name_spec.rb +0 -15
- data/spec/unit/substation/response/to_request_spec.rb +0 -19
@@ -6,33 +6,33 @@ describe Utils, '.const_get' do
|
|
6
6
|
|
7
7
|
subject { described_class.const_get(name) }
|
8
8
|
|
9
|
-
context
|
10
|
-
context
|
9
|
+
context "with a toplevel constant" do
|
10
|
+
context "given as String" do
|
11
11
|
let(:name) { 'Substation' }
|
12
12
|
|
13
13
|
it { should == Substation }
|
14
14
|
end
|
15
15
|
|
16
|
-
context
|
16
|
+
context "given as Symbol" do
|
17
17
|
let(:name) { :Substation }
|
18
18
|
|
19
19
|
it { should == Substation }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context "with a FQN toplevel constant" do
|
24
24
|
let(:name) { '::Substation' }
|
25
25
|
|
26
26
|
it { should == Substation }
|
27
27
|
end
|
28
28
|
|
29
|
-
context
|
29
|
+
context "with a nested constant" do
|
30
30
|
let(:name) { 'Substation::Request' }
|
31
31
|
|
32
32
|
it { should == Substation::Request }
|
33
33
|
end
|
34
34
|
|
35
|
-
context
|
35
|
+
context "with a non-existant nested constant" do
|
36
36
|
let(:name) { 'Substation::Foo' }
|
37
37
|
|
38
38
|
before do
|
@@ -6,15 +6,15 @@ describe Utils, '.symbolize_keys' do
|
|
6
6
|
|
7
7
|
subject { described_class.symbolize_keys(hash) }
|
8
8
|
|
9
|
-
context
|
9
|
+
context "with no nested hash" do
|
10
10
|
let(:hash) { { 'foo' => 'bar' } }
|
11
11
|
|
12
|
-
it { should == { :foo => 'bar'
|
12
|
+
it { should == { :foo => 'bar'} }
|
13
13
|
end
|
14
14
|
|
15
|
-
context
|
15
|
+
context "with a nested hash" do
|
16
16
|
let(:hash) { { 'foo' => { 'bar' => 'baz' } } }
|
17
17
|
|
18
|
-
it { should == { :foo => { :bar => 'baz'
|
18
|
+
it { should == { :foo => { :bar => 'baz'} } }
|
19
19
|
end
|
20
20
|
end
|
data/substation.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
17
|
gem.extra_rdoc_files = %w[LICENSE README.md TODO]
|
18
18
|
|
19
|
-
gem.add_dependency 'adamantium', '~> 0.0
|
19
|
+
gem.add_dependency 'adamantium', '~> 0.1.0'
|
20
20
|
gem.add_dependency 'equalizer', '~> 0.0.5'
|
21
21
|
gem.add_dependency 'abstract_type', '~> 0.0.5'
|
22
22
|
gem.add_dependency 'concord', '~> 0.1.0'
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: substation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.10.beta2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Martin Gamsjaeger (snusnu)
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: adamantium
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0
|
19
|
+
version: 0.1.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0
|
26
|
+
version: 0.1.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: equalizer
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: abstract_type
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: concord
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: bundler
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -120,7 +109,6 @@ files:
|
|
120
109
|
- config/flog.yml
|
121
110
|
- config/mutant.yml
|
122
111
|
- config/reek.yml
|
123
|
-
- config/rubocop.yml
|
124
112
|
- config/yardstick.yml
|
125
113
|
- lib/substation.rb
|
126
114
|
- lib/substation/chain.rb
|
@@ -131,7 +119,7 @@ files:
|
|
131
119
|
- lib/substation/observer.rb
|
132
120
|
- lib/substation/processor.rb
|
133
121
|
- lib/substation/processor/evaluator.rb
|
134
|
-
- lib/substation/processor/
|
122
|
+
- lib/substation/processor/pivot.rb
|
135
123
|
- lib/substation/processor/wrapper.rb
|
136
124
|
- lib/substation/request.rb
|
137
125
|
- lib/substation/response.rb
|
@@ -140,17 +128,18 @@ files:
|
|
140
128
|
- spec/integration/substation/dispatcher/call_spec.rb
|
141
129
|
- spec/spec_helper.rb
|
142
130
|
- spec/unit/substation/chain/call_spec.rb
|
143
|
-
- spec/unit/substation/chain/class_methods/failure_response_spec.rb
|
144
131
|
- spec/unit/substation/chain/dsl/builder/class_methods/call_spec.rb
|
145
132
|
- spec/unit/substation/chain/dsl/builder/dsl_spec.rb
|
133
|
+
- spec/unit/substation/chain/dsl/builder/failure_chain_spec.rb
|
146
134
|
- spec/unit/substation/chain/dsl/chain_spec.rb
|
147
|
-
- spec/unit/substation/chain/dsl/class_methods/
|
148
|
-
- spec/unit/substation/chain/dsl/
|
135
|
+
- spec/unit/substation/chain/dsl/class_methods/processors_spec.rb
|
136
|
+
- spec/unit/substation/chain/dsl/initialize_spec.rb
|
149
137
|
- spec/unit/substation/chain/dsl/processors_spec.rb
|
150
138
|
- spec/unit/substation/chain/dsl/use_spec.rb
|
151
139
|
- spec/unit/substation/chain/each_spec.rb
|
152
|
-
- spec/unit/substation/chain/
|
153
|
-
- spec/unit/substation/chain/
|
140
|
+
- spec/unit/substation/chain/incoming/result_spec.rb
|
141
|
+
- spec/unit/substation/chain/outgoing/call_spec.rb
|
142
|
+
- spec/unit/substation/chain/outgoing/result_spec.rb
|
154
143
|
- spec/unit/substation/dispatcher/action/call_spec.rb
|
155
144
|
- spec/unit/substation/dispatcher/action/class_methods/coerce_spec.rb
|
156
145
|
- spec/unit/substation/dispatcher/action_names_spec.rb
|
@@ -161,29 +150,15 @@ files:
|
|
161
150
|
- spec/unit/substation/environment/dsl/class_methods/registry_spec.rb
|
162
151
|
- spec/unit/substation/environment/dsl/register_spec.rb
|
163
152
|
- spec/unit/substation/environment/dsl/registry_spec.rb
|
164
|
-
- spec/unit/substation/environment/equalizer_spec.rb
|
165
153
|
- spec/unit/substation/observer/chain/call_spec.rb
|
166
154
|
- spec/unit/substation/observer/class_methods/coerce_spec.rb
|
167
155
|
- spec/unit/substation/observer/null/call_spec.rb
|
168
156
|
- spec/unit/substation/processor/evaluator/call_spec.rb
|
169
|
-
- spec/unit/substation/processor/
|
170
|
-
- spec/unit/substation/processor/evaluator/data/call_spec.rb
|
171
|
-
- spec/unit/substation/processor/evaluator/pivot/call_spec.rb
|
172
|
-
- spec/unit/substation/processor/evaluator/request/call_spec.rb
|
173
|
-
- spec/unit/substation/processor/fallible/name_spec.rb
|
174
|
-
- spec/unit/substation/processor/fallible/with_failure_chain_spec.rb
|
175
|
-
- spec/unit/substation/processor/incoming/result_spec.rb
|
176
|
-
- spec/unit/substation/processor/outgoing/call_spec.rb
|
177
|
-
- spec/unit/substation/processor/outgoing/name_spec.rb
|
178
|
-
- spec/unit/substation/processor/outgoing/success_predicate_spec.rb
|
179
|
-
- spec/unit/substation/processor/result_spec.rb
|
180
|
-
- spec/unit/substation/processor/success_predicate_spec.rb
|
181
|
-
- spec/unit/substation/processor/transformer/call_spec.rb
|
157
|
+
- spec/unit/substation/processor/pivot/call_spec.rb
|
182
158
|
- spec/unit/substation/processor/wrapper/call_spec.rb
|
183
159
|
- spec/unit/substation/request/env_spec.rb
|
184
160
|
- spec/unit/substation/request/error_spec.rb
|
185
161
|
- spec/unit/substation/request/input_spec.rb
|
186
|
-
- spec/unit/substation/request/name_spec.rb
|
187
162
|
- spec/unit/substation/request/success_spec.rb
|
188
163
|
- spec/unit/substation/response/env_spec.rb
|
189
164
|
- spec/unit/substation/response/failure/success_predicate_spec.rb
|
@@ -191,34 +166,32 @@ files:
|
|
191
166
|
- spec/unit/substation/response/output_spec.rb
|
192
167
|
- spec/unit/substation/response/request_spec.rb
|
193
168
|
- spec/unit/substation/response/success/success_predicate_spec.rb
|
194
|
-
- spec/unit/substation/response/to_request_spec.rb
|
195
169
|
- spec/unit/substation/utils/class_methods/coerce_callable_spec.rb
|
196
170
|
- spec/unit/substation/utils/class_methods/const_get_spec.rb
|
197
171
|
- spec/unit/substation/utils/class_methods/symbolize_keys_spec.rb
|
198
172
|
- substation.gemspec
|
199
173
|
homepage: https://github.com/snusnu/substation
|
200
174
|
licenses: []
|
175
|
+
metadata: {}
|
201
176
|
post_install_message:
|
202
177
|
rdoc_options: []
|
203
178
|
require_paths:
|
204
179
|
- lib
|
205
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
-
none: false
|
207
181
|
requirements:
|
208
|
-
- -
|
182
|
+
- - '>='
|
209
183
|
- !ruby/object:Gem::Version
|
210
184
|
version: '0'
|
211
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
-
none: false
|
213
186
|
requirements:
|
214
|
-
- -
|
187
|
+
- - '>'
|
215
188
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
189
|
+
version: 1.3.1
|
217
190
|
requirements: []
|
218
191
|
rubyforge_project:
|
219
|
-
rubygems_version:
|
192
|
+
rubygems_version: 2.0.2
|
220
193
|
signing_key:
|
221
|
-
specification_version:
|
194
|
+
specification_version: 4
|
222
195
|
summary: Think of it as a domain level request router. It assumes that every usecase
|
223
196
|
in your application has a name and is implemented in a dedicated action handler
|
224
197
|
(class).
|
data/config/rubocop.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Includes:
|
3
|
-
- '../**/*.rake'
|
4
|
-
Excludes:
|
5
|
-
- '../spec/spec_helper.rb'
|
6
|
-
|
7
|
-
# Avoid parameter lists longer than five parameters.
|
8
|
-
ParameterLists:
|
9
|
-
Max: 3
|
10
|
-
CountKeywordArgs: true
|
11
|
-
|
12
|
-
# Avoid more than `Max` levels of nesting.
|
13
|
-
BlockNesting:
|
14
|
-
Max: 3
|
15
|
-
|
16
|
-
HashSyntax:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Blocks:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
SpaceInsideBrackets:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Documentation:
|
26
|
-
Enabled: false # reek already checks this and rubocop requires duplicate docs
|
27
|
-
|
28
|
-
SingleLineMethods:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
LineLength:
|
32
|
-
Max: 106 # the offending lines are in specs, sadly this means global disabling for now
|
33
|
-
|
34
|
-
MethodLength:
|
35
|
-
Max: 12 # reek performs these checks anyway
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Substation
|
4
|
-
module Processor
|
5
|
-
|
6
|
-
# A processor that transforms output data into something else
|
7
|
-
class Transformer
|
8
|
-
|
9
|
-
include Processor::Outgoing
|
10
|
-
include Adamantium::Flat
|
11
|
-
|
12
|
-
# Transform response data into something else
|
13
|
-
#
|
14
|
-
# @param [Response] response
|
15
|
-
# the response to process
|
16
|
-
#
|
17
|
-
# @return [Response]
|
18
|
-
#
|
19
|
-
# @api private
|
20
|
-
def call(response)
|
21
|
-
respond_with(response, handler.call(response))
|
22
|
-
end
|
23
|
-
|
24
|
-
end # class Wrapper
|
25
|
-
end # module Processor
|
26
|
-
end # module Substation
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Chain, '.failure_response' do
|
6
|
-
subject { described_class.failure_response(request, data, exception) }
|
7
|
-
|
8
|
-
let(:request) { mock(:env => mock, :input => mock) }
|
9
|
-
let(:data) { mock }
|
10
|
-
let(:exception) { mock }
|
11
|
-
|
12
|
-
let(:expected) { Response::Failure.new(request, failure_data) }
|
13
|
-
let(:failure_data) { described_class::FailureData.new(data, exception) }
|
14
|
-
|
15
|
-
it { should eql(expected) }
|
16
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Chain::DSL, '.build' do
|
6
|
-
|
7
|
-
let(:chain) { EMPTY_ARRAY }
|
8
|
-
let(:failure_chain) { Chain::EMPTY }
|
9
|
-
|
10
|
-
context 'and a block is given' do
|
11
|
-
subject { described_class.build(chain, failure_chain, &block) }
|
12
|
-
|
13
|
-
let(:block) { ->(_) { use(Spec::FAKE_PROCESSOR) } }
|
14
|
-
let(:processor) { Spec::FAKE_PROCESSOR }
|
15
|
-
|
16
|
-
it { should include(processor) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'and no block is given' do
|
20
|
-
subject { described_class.build(chain, failure_chain) }
|
21
|
-
|
22
|
-
its(:processors) { should be_empty }
|
23
|
-
end
|
24
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Chain::DSL, '#failure_chain' do
|
6
|
-
subject { object.failure_chain(name, failure_chain) }
|
7
|
-
|
8
|
-
let(:object) { dsl.new([ Spec::FAKE_PROCESSOR ]) }
|
9
|
-
let(:dsl) { described_class::Builder.call(registry) }
|
10
|
-
let(:registry) { Environment::DSL.registry(&block) }
|
11
|
-
let(:block) { ->(_) { register(:test, Spec::Processor) } }
|
12
|
-
|
13
|
-
let(:processor) { Spec::FAKE_PROCESSOR.with_failure_chain(failure_chain) }
|
14
|
-
let(:failure_chain) { mock }
|
15
|
-
|
16
|
-
context 'when the processor to alter is registered' do
|
17
|
-
let(:name) { :test }
|
18
|
-
|
19
|
-
its(:processors) { should include(processor) }
|
20
|
-
|
21
|
-
it 'should replace the processor' do
|
22
|
-
expect(subject.processors.length).to be(1)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when the processor to alter is not registered' do
|
27
|
-
let(:name) { :unknown }
|
28
|
-
|
29
|
-
specify {
|
30
|
-
expect {
|
31
|
-
subject
|
32
|
-
}.to raise_error(UnknownProcessor, 'No processor named :unknown is registered')
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Chain::FailureData, 'equalizer behavior' do
|
6
|
-
subject { object == other }
|
7
|
-
|
8
|
-
let(:object) { described_class.new(data, exception) }
|
9
|
-
let(:data) { mock }
|
10
|
-
let(:exception) { RuntimeError.new }
|
11
|
-
|
12
|
-
let(:other) { described_class.new(other_data, other_exception) }
|
13
|
-
|
14
|
-
context 'with equal data associated' do
|
15
|
-
|
16
|
-
let(:other_data) { data }
|
17
|
-
|
18
|
-
context 'and equal exception classes' do
|
19
|
-
let(:other_exception) { RuntimeError.new }
|
20
|
-
|
21
|
-
it { should be(true) }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'and different exception classes' do
|
25
|
-
let(:other_exception) { StandardError.new }
|
26
|
-
|
27
|
-
it { should be(false) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'with different data associated' do
|
32
|
-
let(:other_data) { mock }
|
33
|
-
|
34
|
-
context 'and equal exception classes' do
|
35
|
-
let(:other_exception) { RuntimeError.new }
|
36
|
-
|
37
|
-
it { should be(false) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'and different exception classes' do
|
41
|
-
let(:other_exception) { StandardError.new }
|
42
|
-
|
43
|
-
it { should be(false) }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|