light-service-ext 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/CHANGELOG.md +9 -1
  4. data/README.md +193 -5
  5. data/dev/setup.rb +5 -3
  6. data/lib/light-service-ext/application_action.rb +0 -21
  7. data/lib/light-service-ext/application_context.rb +29 -1
  8. data/lib/light-service-ext/application_validator_action.rb +2 -2
  9. data/lib/light-service-ext/configuration.rb +28 -0
  10. data/lib/light-service-ext/constants.rb +1 -1
  11. data/lib/light-service-ext/error_info.rb +11 -11
  12. data/lib/light-service-ext/version.rb +1 -1
  13. data/lib/light-service-ext/with_error_handler.rb +26 -0
  14. data/lib/light-service-ext.rb +35 -13
  15. data/light-service-ext.gemspec +1 -0
  16. data/spec/light-service-ext/application_action_spec.rb +39 -0
  17. data/spec/light-service-ext/application_context_spec.rb +189 -0
  18. data/spec/{light_service_ext → light-service-ext}/application_organizer_spec.rb +9 -2
  19. data/spec/light-service-ext/configuration_spec.rb +66 -0
  20. data/spec/{light_service_ext → light-service-ext}/error_info_spec.rb +18 -7
  21. data/spec/light-service-ext/with_error_handler_spec.rb +62 -0
  22. data/spec/light_service_ext_spec.rb +67 -1
  23. data/spec/spec_helper.rb +7 -3
  24. metadata +42 -22
  25. data/spec/light_service_ext/application_action_spec.rb +0 -77
  26. data/spec/light_service_ext/application_context_spec.rb +0 -68
  27. /data/spec/{light_service_ext → light-service-ext}/all_actions_complete_action_spec.rb +0 -0
  28. /data/spec/{light_service_ext → light-service-ext}/application_contract_spec.rb +0 -0
  29. /data/spec/{light_service_ext → light-service-ext}/application_validator_action_spec.rb +0 -0
  30. /data/spec/{light_service_ext → light-service-ext}/around_action_execute_extension_spec.rb +0 -0
  31. /data/spec/{light_service_ext → light-service-ext}/context_error_spec.rb +0 -0
  32. /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