substation 0.0.10.beta2 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -3
- data/Changelog.md +99 -24
- data/Gemfile +8 -1
- data/Gemfile.devtools +37 -21
- data/Guardfile +1 -1
- data/README.md +118 -46
- data/TODO.md +1 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/reek.yml +41 -16
- data/config/rubocop.yml +44 -0
- data/config/yardstick.yml +1 -1
- data/lib/substation.rb +41 -5
- data/lib/substation/chain.rb +73 -84
- data/lib/substation/chain/definition.rb +147 -0
- data/lib/substation/chain/dsl.rb +150 -112
- data/lib/substation/chain/dsl/config.rb +55 -0
- data/lib/substation/chain/dsl/module_builder.rb +84 -0
- data/lib/substation/dispatcher.rb +20 -229
- data/lib/substation/dsl/guard.rb +96 -0
- data/lib/substation/dsl/registry.rb +181 -0
- data/lib/substation/environment.rb +126 -23
- data/lib/substation/environment/dsl.rb +31 -12
- data/lib/substation/processor.rb +238 -7
- data/lib/substation/processor/builder.rb +26 -0
- data/lib/substation/processor/config.rb +24 -0
- data/lib/substation/processor/evaluator.rb +66 -42
- data/lib/substation/processor/evaluator/handler.rb +54 -0
- data/lib/substation/processor/evaluator/result.rb +24 -0
- data/lib/substation/processor/executor.rb +46 -0
- data/lib/substation/processor/nest.rb +40 -0
- data/lib/substation/processor/transformer.rb +46 -0
- data/lib/substation/processor/wrapper.rb +16 -5
- data/lib/substation/request.rb +29 -27
- data/lib/substation/response.rb +19 -34
- data/lib/substation/response/api.rb +37 -0
- data/lib/substation/response/exception.rb +20 -0
- data/lib/substation/response/exception/output.rb +59 -0
- data/lib/substation/response/failure.rb +11 -0
- data/lib/substation/response/success.rb +11 -0
- data/lib/substation/version.rb +3 -1
- data/spec/demo/core.rb +64 -0
- data/spec/demo/core/action.rb +49 -0
- data/spec/demo/core/action/create_person.rb +28 -0
- data/spec/demo/core/errors.rb +16 -0
- data/spec/demo/core/facade.rb +38 -0
- data/spec/demo/core/handler.rb +21 -0
- data/spec/demo/core/handler/acceptor.rb +47 -0
- data/spec/demo/core/handler/authenticator.rb +36 -0
- data/spec/demo/core/handler/authorizer.rb +38 -0
- data/spec/demo/core/input.rb +15 -0
- data/spec/demo/core/observers.rb +10 -0
- data/spec/demo/core/validator.rb +21 -0
- data/spec/demo/domain/actor.rb +29 -0
- data/spec/demo/domain/dto/person.rb +18 -0
- data/spec/demo/domain/environment.rb +55 -0
- data/spec/demo/domain/storage.rb +49 -0
- data/spec/demo/web.rb +26 -0
- data/spec/demo/web/errors.rb +9 -0
- data/spec/demo/web/facade.rb +60 -0
- data/spec/demo/web/handler/deserializer.rb +36 -0
- data/spec/demo/web/presenter.rb +38 -0
- data/spec/demo/web/presenter/person.rb +19 -0
- data/spec/demo/web/renderer.rb +45 -0
- data/spec/demo/web/sanitizer.rb +35 -0
- data/spec/demo/web/sanitizer/person.rb +20 -0
- data/spec/demo/web/views.rb +28 -0
- data/spec/integration/demo/core_spec.rb +97 -0
- data/spec/integration/demo/web_spec.rb +114 -0
- data/spec/shared/context/integration/demo.rb +33 -0
- data/spec/shared/context/unit/chain.rb +13 -0
- data/spec/shared/context/unit/processor.rb +58 -0
- data/spec/shared/context/unit/request.rb +8 -0
- data/spec/shared/examples/integration/demo.rb +35 -0
- data/spec/shared/examples/unit/processor.rb +72 -0
- data/spec/spec_helper.rb +52 -23
- data/spec/unit/substation/chain/definition_spec.rb +141 -0
- data/spec/unit/substation/chain/dsl/config/dsl_module_spec.rb +13 -0
- data/spec/unit/substation/chain/dsl/config/registry_spec.rb +13 -0
- data/spec/unit/substation/chain/dsl/config_spec.rb +18 -0
- data/spec/unit/substation/chain/dsl/module_builder_spec.rb +77 -0
- data/spec/unit/substation/chain/dsl_spec.rb +175 -0
- data/spec/unit/substation/chain_spec.rb +303 -0
- data/spec/unit/substation/dispatcher_spec.rb +68 -0
- data/spec/unit/substation/dsl/guard_spec.rb +72 -0
- data/spec/unit/substation/dsl/registry_spec.rb +181 -0
- data/spec/unit/substation/environment/dsl_spec.rb +156 -0
- data/spec/unit/substation/environment_spec.rb +259 -0
- data/spec/unit/substation/processor/builder_spec.rb +21 -0
- data/spec/unit/substation/processor/config_spec.rb +40 -0
- data/spec/unit/substation/processor/evaluator/handler_spec.rb +20 -0
- data/spec/unit/substation/processor/evaluator/pivot_spec.rb +42 -0
- data/spec/unit/substation/processor/evaluator/request_spec.rb +11 -0
- data/spec/unit/substation/processor/evaluator/result/failure_spec.rb +14 -0
- data/spec/unit/substation/processor/evaluator/result/success_spec.rb +14 -0
- data/spec/unit/substation/processor/evaluator/result_spec.rb +13 -0
- data/spec/unit/substation/processor/evaluator_spec.rb +18 -0
- data/spec/unit/substation/processor/executor/null_spec.rb +25 -0
- data/spec/unit/substation/processor/executor_spec.rb +32 -0
- data/spec/unit/substation/processor/fallible_spec.rb +24 -0
- data/spec/unit/substation/processor/incoming_spec.rb +17 -0
- data/spec/unit/substation/processor/nest/incoming_spec.rb +56 -0
- data/spec/unit/substation/processor/nest_spec.rb +6 -0
- data/spec/unit/substation/processor/outgoing_spec.rb +47 -0
- data/spec/unit/substation/processor/transformer/incoming_spec.rb +17 -0
- data/spec/unit/substation/processor/transformer/outgoing_spec.rb +17 -0
- data/spec/unit/substation/processor/wrapper/incoming_spec.rb +15 -0
- data/spec/unit/substation/processor/wrapper/outgoing_spec.rb +15 -0
- data/spec/unit/substation/processor/wrapper_spec.rb +24 -0
- data/spec/unit/substation/processor_spec.rb +68 -0
- data/spec/unit/substation/request_spec.rb +70 -0
- data/spec/unit/substation/response/api_spec.rb +22 -0
- data/spec/unit/substation/response/exception/output_spec.rb +46 -0
- data/spec/unit/substation/response/exception_spec.rb +25 -0
- data/spec/unit/substation/response/failure_spec.rb +25 -0
- data/spec/unit/substation/response/success_spec.rb +24 -0
- data/spec/unit/substation/response_spec.rb +73 -0
- data/substation.gemspec +7 -6
- metadata +157 -67
- checksums.yaml +0 -7
- data/TODO +0 -0
- data/lib/substation/observer.rb +0 -66
- data/lib/substation/processor/pivot.rb +0 -25
- data/lib/substation/utils.rb +0 -68
- data/spec/integration/substation/dispatcher/call_spec.rb +0 -260
- data/spec/unit/substation/chain/call_spec.rb +0 -63
- data/spec/unit/substation/chain/dsl/builder/class_methods/call_spec.rb +0 -19
- data/spec/unit/substation/chain/dsl/builder/dsl_spec.rb +0 -21
- data/spec/unit/substation/chain/dsl/builder/failure_chain_spec.rb +0 -30
- data/spec/unit/substation/chain/dsl/chain_spec.rb +0 -15
- data/spec/unit/substation/chain/dsl/class_methods/processors_spec.rb +0 -24
- data/spec/unit/substation/chain/dsl/initialize_spec.rb +0 -19
- data/spec/unit/substation/chain/dsl/processors_spec.rb +0 -42
- data/spec/unit/substation/chain/dsl/use_spec.rb +0 -14
- data/spec/unit/substation/chain/each_spec.rb +0 -46
- data/spec/unit/substation/chain/incoming/result_spec.rb +0 -21
- data/spec/unit/substation/chain/outgoing/call_spec.rb +0 -25
- data/spec/unit/substation/chain/outgoing/result_spec.rb +0 -21
- data/spec/unit/substation/dispatcher/action/call_spec.rb +0 -23
- data/spec/unit/substation/dispatcher/action/class_methods/coerce_spec.rb +0 -61
- data/spec/unit/substation/dispatcher/action_names_spec.rb +0 -14
- data/spec/unit/substation/dispatcher/call_spec.rb +0 -47
- data/spec/unit/substation/dispatcher/class_methods/coerce_spec.rb +0 -20
- data/spec/unit/substation/environment/chain_spec.rb +0 -50
- data/spec/unit/substation/environment/class_methods/build_spec.rb +0 -11
- data/spec/unit/substation/environment/dsl/class_methods/registry_spec.rb +0 -18
- data/spec/unit/substation/environment/dsl/register_spec.rb +0 -14
- data/spec/unit/substation/environment/dsl/registry_spec.rb +0 -19
- data/spec/unit/substation/observer/chain/call_spec.rb +0 -26
- data/spec/unit/substation/observer/class_methods/coerce_spec.rb +0 -33
- data/spec/unit/substation/observer/null/call_spec.rb +0 -12
- data/spec/unit/substation/processor/evaluator/call_spec.rb +0 -49
- data/spec/unit/substation/processor/pivot/call_spec.rb +0 -17
- data/spec/unit/substation/processor/wrapper/call_spec.rb +0 -20
- data/spec/unit/substation/request/env_spec.rb +0 -14
- data/spec/unit/substation/request/error_spec.rb +0 -15
- data/spec/unit/substation/request/input_spec.rb +0 -14
- data/spec/unit/substation/request/success_spec.rb +0 -15
- data/spec/unit/substation/response/env_spec.rb +0 -16
- data/spec/unit/substation/response/failure/success_predicate_spec.rb +0 -15
- data/spec/unit/substation/response/input_spec.rb +0 -16
- data/spec/unit/substation/response/output_spec.rb +0 -16
- data/spec/unit/substation/response/request_spec.rb +0 -16
- data/spec/unit/substation/response/success/success_predicate_spec.rb +0 -15
- data/spec/unit/substation/utils/class_methods/coerce_callable_spec.rb +0 -46
- data/spec/unit/substation/utils/class_methods/const_get_spec.rb +0 -46
- data/spec/unit/substation/utils/class_methods/symbolize_keys_spec.rb +0 -20
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Evaluator::Handler do
|
6
|
+
let(:object) { Class.new { include Processor::Evaluator::Handler }.new }
|
7
|
+
let(:output) { double }
|
8
|
+
|
9
|
+
describe '#error' do
|
10
|
+
subject { object.error(output) }
|
11
|
+
|
12
|
+
it { should eql(Processor::Evaluator::Result::Failure.new(output)) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#success' do
|
16
|
+
subject { object.success(output) }
|
17
|
+
|
18
|
+
it { should eql(Processor::Evaluator::Result::Success.new(output)) }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Evaluator::Pivot do
|
6
|
+
describe '#call' do
|
7
|
+
subject { object.call(request) }
|
8
|
+
|
9
|
+
let(:klass) { described_class }
|
10
|
+
|
11
|
+
include_context 'Processor::Call'
|
12
|
+
|
13
|
+
context 'with a successful handler' do
|
14
|
+
before do
|
15
|
+
expect(decomposer).to receive(:call).with(request).and_return(decomposed)
|
16
|
+
expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
|
17
|
+
expect(observers).to receive(:each).with(no_args).and_yield(observer)
|
18
|
+
expect(observer).to receive(:call).with(handler_result)
|
19
|
+
expect(handler_result).to receive(:success?)
|
20
|
+
end
|
21
|
+
|
22
|
+
it { should eql(handler_result) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with a failing handler' do
|
26
|
+
let(:handler_success) { false }
|
27
|
+
let(:response) { Response::Failure.new(request, composed) }
|
28
|
+
|
29
|
+
before do
|
30
|
+
expect(decomposer).to receive(:call).with(request).and_return(decomposed)
|
31
|
+
expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
|
32
|
+
expect(observers).to receive(:each).with(no_args).and_yield(observer)
|
33
|
+
expect(observer).to receive(:call).with(handler_result)
|
34
|
+
expect(handler_result).to receive(:success?)
|
35
|
+
expect(composer).to receive(:call).with(request, handler_output).and_return(composed)
|
36
|
+
expect(failure_chain).to receive(:call).with(response).and_return(failure_response)
|
37
|
+
end
|
38
|
+
|
39
|
+
it { should eql(failure_response) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Evaluator::Result::Failure do
|
6
|
+
describe '#success?' do
|
7
|
+
subject { object.success? }
|
8
|
+
|
9
|
+
let(:object) { described_class.new(output) }
|
10
|
+
let(:output) { double }
|
11
|
+
|
12
|
+
it { should be(false) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Evaluator::Result::Success, '#success?' do
|
6
|
+
describe '#success?' do
|
7
|
+
subject { object.success? }
|
8
|
+
|
9
|
+
let(:object) { described_class.new(output) }
|
10
|
+
let(:output) { double }
|
11
|
+
|
12
|
+
it { should be(true) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Evaluator do
|
6
|
+
|
7
|
+
describe '#call' do
|
8
|
+
it_behaves_like 'Processor::Evaluator#call' do
|
9
|
+
let(:klass) { Class.new(described_class) { include Processor::Incoming } }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.new' do
|
14
|
+
subject { object.new }
|
15
|
+
|
16
|
+
it_behaves_like 'an abstract type'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Executor::NULL do
|
6
|
+
|
7
|
+
let(:input) { double('input') }
|
8
|
+
let(:output) { double('output') }
|
9
|
+
|
10
|
+
describe '#compose' do
|
11
|
+
subject { described_class.compose(input, output) }
|
12
|
+
|
13
|
+
it 'should return the output unaltered' do
|
14
|
+
expect(subject).to be(output)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#decompose' do
|
19
|
+
subject { described_class.decompose(input) }
|
20
|
+
|
21
|
+
it 'should return the input unaltered' do
|
22
|
+
expect(subject).to be(input)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Executor, '#compose' do
|
6
|
+
let(:input) { double('input') }
|
7
|
+
let(:output) { double('output') }
|
8
|
+
|
9
|
+
describe '#compose' do
|
10
|
+
subject { executor.compose(input, output) }
|
11
|
+
|
12
|
+
include_context 'Processor::Executor#initialize'
|
13
|
+
|
14
|
+
before do
|
15
|
+
expect(composer).to receive(:call).with(input, output).and_return(composed)
|
16
|
+
end
|
17
|
+
|
18
|
+
it { should be(composed) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#decompose' do
|
22
|
+
subject { executor.decompose(input) }
|
23
|
+
|
24
|
+
include_context 'Processor::Executor#initialize'
|
25
|
+
|
26
|
+
before do
|
27
|
+
expect(decomposer).to receive(:call).with(input).and_return(decomposed)
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should be(decomposed) }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Fallible do
|
6
|
+
describe '#with_failure_chain' do
|
7
|
+
subject { object.with_failure_chain(chain) }
|
8
|
+
|
9
|
+
include_context 'Processor#initialize'
|
10
|
+
|
11
|
+
let(:klass) {
|
12
|
+
Class.new {
|
13
|
+
include Processor::Incoming
|
14
|
+
include Processor::Fallible
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
let(:expected) { klass.new(processor_name, handler, expected_config) }
|
19
|
+
let(:expected_config) { processor_config.with_failure_chain(chain) }
|
20
|
+
let(:chain) { double }
|
21
|
+
|
22
|
+
it { should eql(expected) }
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Incoming do
|
6
|
+
describe '#result' do
|
7
|
+
subject { object.result(response) }
|
8
|
+
|
9
|
+
include_context 'Request#initialize'
|
10
|
+
include_context 'Processor#initialize'
|
11
|
+
|
12
|
+
let(:klass) { Class.new { include Substation::Processor::Incoming } }
|
13
|
+
let(:response) { Response::Success.new(request, input) }
|
14
|
+
|
15
|
+
it { should eql(request) }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Nest::Incoming do
|
6
|
+
|
7
|
+
describe '#call' do
|
8
|
+
subject { object.call(request) }
|
9
|
+
|
10
|
+
let(:klass) { described_class }
|
11
|
+
let(:composed_state) { double }
|
12
|
+
|
13
|
+
include_context 'Processor::Call'
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(decomposer).to receive(:call).with(request).and_return(decomposed)
|
17
|
+
allow(handler).to receive(:call).with(decomposed).and_return(state)
|
18
|
+
allow(observers).to receive(:each).with(no_args).and_yield(observer)
|
19
|
+
allow(observer).to receive(:call).with(state)
|
20
|
+
allow(composer).to receive(:call).with(request, state) { composed_state }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a request' do
|
24
|
+
let(:state) { Request.new(:test, double, data) }
|
25
|
+
let(:data) { double('data') }
|
26
|
+
let(:first_pass) { request.success(data) }
|
27
|
+
|
28
|
+
before do
|
29
|
+
allow(composer).to receive(:call).with(request, first_pass) { composed_state }
|
30
|
+
end
|
31
|
+
|
32
|
+
it { should eql(request.success(composed_state)) }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with a successful response' do
|
36
|
+
let(:state) { Response::Success.new(request, {}) }
|
37
|
+
|
38
|
+
it { should eql(request.success(composed_state)) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with a failure response' do
|
42
|
+
let(:state) { Response::Failure.new(request, {}) }
|
43
|
+
|
44
|
+
it { should eql(request.error(composed_state)) }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with an unknown state' do
|
48
|
+
let(:state) { nil }
|
49
|
+
|
50
|
+
it 'raises RuntimeError' do
|
51
|
+
expect { subject }.to raise_error(RuntimeError, 'Illegal state returned from the invoked handler')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Outgoing, '#call' do
|
6
|
+
describe '#call' do
|
7
|
+
subject { object.call(request) }
|
8
|
+
|
9
|
+
include_context 'Request#initialize'
|
10
|
+
include_context 'Processor#initialize'
|
11
|
+
|
12
|
+
let(:klass) {
|
13
|
+
Class.new {
|
14
|
+
include Substation::Processor::Outgoing
|
15
|
+
def call(request)
|
16
|
+
response = request.success(request.input)
|
17
|
+
respond_with(response, :altered)
|
18
|
+
end
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:response) { Response::Success.new(request, :altered) }
|
23
|
+
|
24
|
+
it { should eql(response) }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#name' do
|
28
|
+
subject { object.name }
|
29
|
+
|
30
|
+
include_context 'Processor#initialize'
|
31
|
+
|
32
|
+
let(:klass) { Class.new { include Substation::Processor::Outgoing } }
|
33
|
+
|
34
|
+
it { should be(processor_name) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#success?' do
|
38
|
+
subject { object.success?(response) }
|
39
|
+
|
40
|
+
include_context 'Processor#initialize'
|
41
|
+
|
42
|
+
let(:klass) { Class.new { include Substation::Processor::Outgoing } }
|
43
|
+
let(:response) { double }
|
44
|
+
|
45
|
+
it { should be(true) }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Transformer::Incoming do
|
6
|
+
describe '#call' do
|
7
|
+
let(:klass) { described_class }
|
8
|
+
|
9
|
+
before do
|
10
|
+
expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
|
11
|
+
expect(observers).to receive(:each).with(no_args).and_yield(observer)
|
12
|
+
expect(observer).to receive(:call).with(handler_result)
|
13
|
+
end
|
14
|
+
|
15
|
+
it_behaves_like 'Processor::Call::Incoming#call'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Transformer::Outgoing do
|
6
|
+
describe '#call' do
|
7
|
+
let(:klass) { described_class }
|
8
|
+
|
9
|
+
before do
|
10
|
+
expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
|
11
|
+
expect(observers).to receive(:each).with(no_args).and_yield(observer)
|
12
|
+
expect(observer).to receive(:call).with(handler_result)
|
13
|
+
end
|
14
|
+
|
15
|
+
it_behaves_like 'Processor::Call::Outgoing#call'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Wrapper::Incoming do
|
6
|
+
describe '#call' do
|
7
|
+
let(:klass) { described_class }
|
8
|
+
|
9
|
+
before do
|
10
|
+
expect(handler).to receive(:new).with(decomposed).and_return(handler_result)
|
11
|
+
end
|
12
|
+
|
13
|
+
it_behaves_like 'Processor::Call::Incoming#call'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Wrapper::Outgoing do
|
6
|
+
describe '#call' do
|
7
|
+
let(:klass) { described_class }
|
8
|
+
|
9
|
+
before do
|
10
|
+
expect(handler).to receive(:new).with(decomposed).and_return(handler_result)
|
11
|
+
end
|
12
|
+
|
13
|
+
it_behaves_like 'Processor::Call::Outgoing#call'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Processor::Wrapper do
|
6
|
+
describe '#call' do
|
7
|
+
it_behaves_like 'Processor::Call::Incoming#call' do
|
8
|
+
before do
|
9
|
+
expect(handler).to receive(:new).with(decomposed).and_return(handler_result)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:klass) {
|
13
|
+
Class.new {
|
14
|
+
include Processor::Incoming
|
15
|
+
include Processor::Wrapper
|
16
|
+
|
17
|
+
def call(request)
|
18
|
+
request.success(execute(request))
|
19
|
+
end
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|