interactor 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +4 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/README.md +1 -0
- data/Rakefile +2 -1
- data/interactor.gemspec +9 -9
- data/lib/interactor/context.rb +1 -1
- data/spec/integration_spec.rb +303 -267
- data/spec/interactor/context_spec.rb +36 -8
- data/spec/interactor/hooks_spec.rb +13 -13
- metadata +4 -4
@@ -16,7 +16,7 @@ module Interactor
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "doesn't affect the original hash" do
|
19
|
-
hash = {
|
19
|
+
hash = {foo: "bar"}
|
20
20
|
context = Context.build(hash)
|
21
21
|
|
22
22
|
expect(context).to be_a(Context)
|
@@ -61,7 +61,11 @@ module Interactor
|
|
61
61
|
|
62
62
|
it "sets success to false" do
|
63
63
|
expect {
|
64
|
-
|
64
|
+
begin
|
65
|
+
context.fail!
|
66
|
+
rescue
|
67
|
+
nil
|
68
|
+
end
|
65
69
|
}.to change {
|
66
70
|
context.success?
|
67
71
|
}.from(true).to(false)
|
@@ -69,17 +73,29 @@ module Interactor
|
|
69
73
|
|
70
74
|
it "sets failure to true" do
|
71
75
|
expect {
|
72
|
-
|
76
|
+
begin
|
77
|
+
context.fail!
|
78
|
+
rescue
|
79
|
+
nil
|
80
|
+
end
|
73
81
|
}.to change {
|
74
82
|
context.failure?
|
75
83
|
}.from(false).to(true)
|
76
84
|
end
|
77
85
|
|
78
86
|
it "preserves failure" do
|
79
|
-
|
87
|
+
begin
|
88
|
+
context.fail!
|
89
|
+
rescue
|
90
|
+
nil
|
91
|
+
end
|
80
92
|
|
81
93
|
expect {
|
82
|
-
|
94
|
+
begin
|
95
|
+
context.fail!
|
96
|
+
rescue
|
97
|
+
nil
|
98
|
+
end
|
83
99
|
}.not_to change {
|
84
100
|
context.failure?
|
85
101
|
}
|
@@ -87,7 +103,11 @@ module Interactor
|
|
87
103
|
|
88
104
|
it "preserves the context" do
|
89
105
|
expect {
|
90
|
-
|
106
|
+
begin
|
107
|
+
context.fail!
|
108
|
+
rescue
|
109
|
+
nil
|
110
|
+
end
|
91
111
|
}.not_to change {
|
92
112
|
context.foo
|
93
113
|
}
|
@@ -95,7 +115,11 @@ module Interactor
|
|
95
115
|
|
96
116
|
it "updates the context" do
|
97
117
|
expect {
|
98
|
-
|
118
|
+
begin
|
119
|
+
context.fail!(foo: "baz")
|
120
|
+
rescue
|
121
|
+
nil
|
122
|
+
end
|
99
123
|
}.to change {
|
100
124
|
context.foo
|
101
125
|
}.from("bar").to("baz")
|
@@ -103,7 +127,11 @@ module Interactor
|
|
103
127
|
|
104
128
|
it "updates the context with a string key" do
|
105
129
|
expect {
|
106
|
-
|
130
|
+
begin
|
131
|
+
context.fail!("foo" => "baz")
|
132
|
+
rescue
|
133
|
+
nil
|
134
|
+
end
|
107
135
|
}.to change {
|
108
136
|
context.foo
|
109
137
|
}.from("bar").to("baz")
|
@@ -43,7 +43,7 @@ module Interactor
|
|
43
43
|
expect(hooked.process).to eq([
|
44
44
|
:around_before,
|
45
45
|
:process,
|
46
|
-
:around_after
|
46
|
+
:around_after,
|
47
47
|
])
|
48
48
|
end
|
49
49
|
end
|
@@ -63,7 +63,7 @@ module Interactor
|
|
63
63
|
expect(hooked.process).to eq([
|
64
64
|
:around_before,
|
65
65
|
:process,
|
66
|
-
:around_after
|
66
|
+
:around_after,
|
67
67
|
])
|
68
68
|
end
|
69
69
|
end
|
@@ -93,7 +93,7 @@ module Interactor
|
|
93
93
|
:around_before2,
|
94
94
|
:process,
|
95
95
|
:around_after2,
|
96
|
-
:around_after1
|
96
|
+
:around_after1,
|
97
97
|
])
|
98
98
|
end
|
99
99
|
end
|
@@ -125,7 +125,7 @@ module Interactor
|
|
125
125
|
:around_before2,
|
126
126
|
:process,
|
127
127
|
:around_after2,
|
128
|
-
:around_after1
|
128
|
+
:around_after1,
|
129
129
|
])
|
130
130
|
end
|
131
131
|
end
|
@@ -146,7 +146,7 @@ module Interactor
|
|
146
146
|
it "runs the before hook method" do
|
147
147
|
expect(hooked.process).to eq([
|
148
148
|
:before,
|
149
|
-
:process
|
149
|
+
:process,
|
150
150
|
])
|
151
151
|
end
|
152
152
|
end
|
@@ -163,7 +163,7 @@ module Interactor
|
|
163
163
|
it "runs the before hook block" do
|
164
164
|
expect(hooked.process).to eq([
|
165
165
|
:before,
|
166
|
-
:process
|
166
|
+
:process,
|
167
167
|
])
|
168
168
|
end
|
169
169
|
end
|
@@ -187,7 +187,7 @@ module Interactor
|
|
187
187
|
expect(hooked.process).to eq([
|
188
188
|
:before1,
|
189
189
|
:before2,
|
190
|
-
:process
|
190
|
+
:process,
|
191
191
|
])
|
192
192
|
end
|
193
193
|
end
|
@@ -213,7 +213,7 @@ module Interactor
|
|
213
213
|
expect(hooked.process).to eq([
|
214
214
|
:before1,
|
215
215
|
:before2,
|
216
|
-
:process
|
216
|
+
:process,
|
217
217
|
])
|
218
218
|
end
|
219
219
|
end
|
@@ -234,7 +234,7 @@ module Interactor
|
|
234
234
|
it "runs the after hook method" do
|
235
235
|
expect(hooked.process).to eq([
|
236
236
|
:process,
|
237
|
-
:after
|
237
|
+
:after,
|
238
238
|
])
|
239
239
|
end
|
240
240
|
end
|
@@ -251,7 +251,7 @@ module Interactor
|
|
251
251
|
it "runs the after hook block" do
|
252
252
|
expect(hooked.process).to eq([
|
253
253
|
:process,
|
254
|
-
:after
|
254
|
+
:after,
|
255
255
|
])
|
256
256
|
end
|
257
257
|
end
|
@@ -275,7 +275,7 @@ module Interactor
|
|
275
275
|
expect(hooked.process).to eq([
|
276
276
|
:process,
|
277
277
|
:after2,
|
278
|
-
:after1
|
278
|
+
:after1,
|
279
279
|
])
|
280
280
|
end
|
281
281
|
end
|
@@ -301,7 +301,7 @@ module Interactor
|
|
301
301
|
expect(hooked.process).to eq([
|
302
302
|
:process,
|
303
303
|
:after2,
|
304
|
-
:after1
|
304
|
+
:after1,
|
305
305
|
])
|
306
306
|
end
|
307
307
|
end
|
@@ -349,7 +349,7 @@ module Interactor
|
|
349
349
|
:after2,
|
350
350
|
:after1,
|
351
351
|
:around_after2,
|
352
|
-
:around_after1
|
352
|
+
:around_after1,
|
353
353
|
])
|
354
354
|
end
|
355
355
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extra_rdoc_files: []
|
|
46
46
|
files:
|
47
47
|
- ".gitignore"
|
48
48
|
- ".rspec"
|
49
|
+
- ".standard.yml"
|
49
50
|
- ".travis.yml"
|
50
51
|
- CHANGELOG.md
|
51
52
|
- CONTRIBUTING.md
|
@@ -85,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
- !ruby/object:Gem::Version
|
86
87
|
version: '0'
|
87
88
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.7.6
|
89
|
+
rubygems_version: 3.1.2
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Simple interactor implementation
|