teckel 0.4.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teckel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Schulze
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mutant-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: yard
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,22 +109,30 @@ files:
95
109
  - README.md
96
110
  - lib/teckel.rb
97
111
  - lib/teckel/chain.rb
112
+ - lib/teckel/chain/config.rb
98
113
  - lib/teckel/chain/result.rb
99
114
  - lib/teckel/chain/runner.rb
100
115
  - lib/teckel/chain/step.rb
101
116
  - lib/teckel/config.rb
102
117
  - lib/teckel/contracts.rb
103
118
  - lib/teckel/operation.rb
119
+ - lib/teckel/operation/config.rb
104
120
  - lib/teckel/operation/result.rb
105
121
  - lib/teckel/operation/runner.rb
106
122
  - lib/teckel/result.rb
107
123
  - lib/teckel/version.rb
124
+ - spec/chain/around_hook_spec.rb
125
+ - spec/chain/default_settings_spec.rb
108
126
  - spec/chain/inheritance_spec.rb
127
+ - spec/chain/none_input_spec.rb
109
128
  - spec/chain/results_spec.rb
110
- - spec/chain_around_hook_spec.rb
111
129
  - spec/chain_spec.rb
112
130
  - spec/config_spec.rb
113
131
  - spec/doctest_helper.rb
132
+ - spec/operation/config_spec.rb
133
+ - spec/operation/contract_trace_spec.rb
134
+ - spec/operation/default_settings_spec.rb
135
+ - spec/operation/fail_on_input_spec.rb
114
136
  - spec/operation/inheritance_spec.rb
115
137
  - spec/operation/result_spec.rb
116
138
  - spec/operation/results_spec.rb
@@ -126,11 +148,12 @@ homepage: https://github.com/fnordfish/teckel
126
148
  licenses:
127
149
  - Apache-2.0
128
150
  metadata:
129
- changelog_uri: https://github.com/github.com/fnordfish/blob/master/CHANGELOG.md
130
- source_code_uri: https://github.com/github.com/fnordfish
131
- bug_tracker_uri: https://github.com/github.com/fnordfish/issues
132
- documentation_uri: https://www.rubydoc.info/gems/teckel/0.4.0
133
- post_install_message:
151
+ changelog_uri: https://github.com/fnordfish/teckel/blob/main/CHANGELOG.md
152
+ source_code_uri: https://github.com/fnordfish/teckel
153
+ bug_tracker_uri: https://github.com/fnordfish/teckel/issues
154
+ documentation_uri: https://www.rubydoc.info/gems/teckel/0.8.0
155
+ user_docs_uri: https://fnordfish.github.io/teckel/
156
+ post_install_message:
134
157
  rdoc_options: []
135
158
  require_paths:
136
159
  - lib
@@ -145,17 +168,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
168
  - !ruby/object:Gem::Version
146
169
  version: '0'
147
170
  requirements: []
148
- rubygems_version: 3.1.2
149
- signing_key:
171
+ rubygems_version: 3.2.15
172
+ signing_key:
150
173
  specification_version: 4
151
174
  summary: Operations with enforced in/out/err data structures
152
175
  test_files:
176
+ - spec/chain/around_hook_spec.rb
177
+ - spec/chain/default_settings_spec.rb
153
178
  - spec/chain/inheritance_spec.rb
179
+ - spec/chain/none_input_spec.rb
154
180
  - spec/chain/results_spec.rb
155
- - spec/chain_around_hook_spec.rb
156
181
  - spec/chain_spec.rb
157
182
  - spec/config_spec.rb
158
183
  - spec/doctest_helper.rb
184
+ - spec/operation/config_spec.rb
185
+ - spec/operation/contract_trace_spec.rb
186
+ - spec/operation/default_settings_spec.rb
187
+ - spec/operation/fail_on_input_spec.rb
159
188
  - spec/operation/inheritance_spec.rb
160
189
  - spec/operation/result_spec.rb
161
190
  - spec/operation/results_spec.rb
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'support/dry_base'
4
- require 'support/fake_db'
5
- require 'support/fake_models'
6
-
7
- RSpec.describe Teckel::Chain do
8
- module TeckelChainAroundHookTest
9
- class CreateUser
10
- include ::Teckel::Operation
11
-
12
- result!
13
-
14
- input Types::Hash.schema(name: Types::String, age: Types::Coercible::Integer.optional)
15
- output Types.Instance(User)
16
- error Types::Hash.schema(message: Types::String, errors: Types::Array.of(Types::Hash))
17
-
18
- def call(input)
19
- user = User.new(name: input[:name], age: input[:age])
20
- if user.save
21
- success!(user)
22
- else
23
- fail!(message: "Could not safe User", errors: user.errors)
24
- end
25
- end
26
- end
27
-
28
- class AddFriend
29
- include ::Teckel::Operation
30
-
31
- result!
32
-
33
- settings Struct.new(:fail_befriend)
34
-
35
- input Types.Instance(User)
36
- output Types::Hash.schema(user: Types.Instance(User), friend: Types.Instance(User))
37
- error Types::Hash.schema(message: Types::String)
38
-
39
- def call(user)
40
- if settings&.fail_befriend
41
- fail!(message: "Did not find a friend.")
42
- else
43
- { user: user, friend: User.new(name: "A friend", age: 42) }
44
- end
45
- end
46
- end
47
-
48
- @stack = []
49
- def self.stack
50
- @stack
51
- end
52
-
53
- class Chain
54
- include Teckel::Chain
55
-
56
- around ->(chain, input) {
57
- result = nil
58
- begin
59
- TeckelChainAroundHookTest.stack << :before
60
-
61
- FakeDB.transaction do
62
- result = chain.call(input)
63
- raise FakeDB::Rollback if result.failure?
64
- end
65
-
66
- TeckelChainAroundHookTest.stack << :after
67
- result
68
- rescue FakeDB::Rollback
69
- result
70
- end
71
- }
72
-
73
- step :create, CreateUser
74
- step :befriend, AddFriend
75
- end
76
- end
77
-
78
- before { TeckelChainAroundHookTest.stack.clear }
79
-
80
- context "success" do
81
- it "result matches" do
82
- result = TeckelChainAroundHookTest::Chain.call(name: "Bob", age: 23)
83
- expect(result.success).to include(user: kind_of(User), friend: kind_of(User))
84
- end
85
-
86
- it "runs around hook" do
87
- TeckelChainAroundHookTest::Chain.call(name: "Bob", age: 23)
88
- expect(TeckelChainAroundHookTest.stack).to eq([:before, :after])
89
- end
90
- end
91
-
92
- context "failure" do
93
- it "runs around hook" do
94
- TeckelChainAroundHookTest::Chain.
95
- with(befriend: :fail).
96
- call(name: "Bob", age: 23)
97
- expect(TeckelChainAroundHookTest.stack).to eq([:before])
98
- end
99
- end
100
- end