light-service-ext 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +9 -1
- data/README.md +193 -5
- data/dev/setup.rb +5 -3
- data/lib/light-service-ext/application_action.rb +0 -21
- data/lib/light-service-ext/application_context.rb +29 -1
- data/lib/light-service-ext/application_validator_action.rb +2 -2
- data/lib/light-service-ext/configuration.rb +28 -0
- data/lib/light-service-ext/constants.rb +1 -1
- data/lib/light-service-ext/error_info.rb +11 -11
- data/lib/light-service-ext/version.rb +1 -1
- data/lib/light-service-ext/with_error_handler.rb +26 -0
- data/lib/light-service-ext.rb +35 -13
- data/light-service-ext.gemspec +2 -1
- data/spec/light-service-ext/application_action_spec.rb +39 -0
- data/spec/light-service-ext/application_context_spec.rb +189 -0
- data/spec/{light_service_ext → light-service-ext}/application_organizer_spec.rb +9 -2
- data/spec/light-service-ext/configuration_spec.rb +66 -0
- data/spec/{light_service_ext → light-service-ext}/error_info_spec.rb +18 -7
- data/spec/light-service-ext/with_error_handler_spec.rb +62 -0
- data/spec/light_service_ext_spec.rb +67 -1
- data/spec/spec_helper.rb +7 -3
- metadata +42 -22
- data/spec/light_service_ext/application_action_spec.rb +0 -77
- data/spec/light_service_ext/application_context_spec.rb +0 -68
- /data/spec/{light_service_ext → light-service-ext}/all_actions_complete_action_spec.rb +0 -0
- /data/spec/{light_service_ext → light-service-ext}/application_contract_spec.rb +0 -0
- /data/spec/{light_service_ext → light-service-ext}/application_validator_action_spec.rb +0 -0
- /data/spec/{light_service_ext → light-service-ext}/around_action_execute_extension_spec.rb +0 -0
- /data/spec/{light_service_ext → light-service-ext}/context_error_spec.rb +0 -0
- /data/spec/{light_service_ext → light-service-ext}/regex_spec.rb +0 -0
@@ -1,68 +0,0 @@
|
|
1
|
-
module LightServiceExt
|
2
|
-
RSpec.describe ApplicationContext do
|
3
|
-
describe '.make_with_defaults' do
|
4
|
-
let(:input) { { key: 'some-value' } }
|
5
|
-
let(:overrides) { {} }
|
6
|
-
|
7
|
-
subject(:ctx_with_defaults) { described_class.make_with_defaults(input, overrides) }
|
8
|
-
|
9
|
-
context 'with non symbolized input keys' do
|
10
|
-
let(:input) { { "key" => 'some-value' } }
|
11
|
-
|
12
|
-
it 'symbolizes input attr keys' do
|
13
|
-
expect(ctx_with_defaults[:input].keys).to include(:key)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns context with default attrs' do
|
18
|
-
expect(ctx_with_defaults.keys).to match_array(%i[input
|
19
|
-
errors
|
20
|
-
params
|
21
|
-
successful_actions
|
22
|
-
api_responses
|
23
|
-
allow_raise_on_failure])
|
24
|
-
|
25
|
-
expect(ctx_with_defaults[:input]).to eql(input)
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'overrideable attrs' do
|
29
|
-
{ errors: { key: 'some-error' },
|
30
|
-
params: { key: 'value' },
|
31
|
-
allow_raise_on_failure: false }.each_pair do |overridable_key, value|
|
32
|
-
it "allows for default #{overridable_key.inspect} to be changed" do
|
33
|
-
ctx_with_defaults = described_class.make_with_defaults(input, **{ overridable_key => value })
|
34
|
-
expect(ctx_with_defaults[overridable_key]).to eql(value)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'with successful_actions set' do
|
39
|
-
subject(:ctx_with_defaults) do
|
40
|
-
described_class.make_with_defaults(input, successful_actions: ['some-action-class-name'])
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'prevents successful_actions to change from default' do
|
44
|
-
expect(ctx_with_defaults[:successful_actions]).to be_empty
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with api_responses set' do
|
49
|
-
subject(:ctx_with_defaults) do
|
50
|
-
described_class.make_with_defaults(input, api_responses: ['some-api-response'])
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'prevents successful_actions to change from default' do
|
54
|
-
expect(ctx_with_defaults[:api_responses]).to be_empty
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with unexpected override' do
|
59
|
-
subject(:ctx_with_defaults) { described_class.make_with_defaults(input, unknown_key: 'some-value') }
|
60
|
-
|
61
|
-
it 'prevents successful_actions to change from default' do
|
62
|
-
expect(ctx_with_defaults.keys).not_to include(:unknown_key)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|