smash_the_state 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 591b5f213e895130ff25cf2bc2638275d6f89a054abbe01c0fb55ff5c6f3cc84
|
4
|
+
data.tar.gz: 249752c9f3aa7a7efea1adf1dcc4af85bfe135235bf0d07b6961fb3a5eca2a80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c74f691d3f1d7d9e6fe008e67d97b7da9cf24cef2d444a57744c1a4ee41f559358d39d6e1e74f5222f93c5d41c1eb9a53f3a61f9635a0cd522798fc77e0d2395
|
7
|
+
data.tar.gz: fbf4c5c27f114281a9db33f2d76d64a50f8f42594f1e2a5a84dfce2414893e1728dae5702e0ea8a65ccd4a3c82790ace05cba760e4634f08ab157e8b115c2e91
|
@@ -50,6 +50,11 @@ module SmashTheState
|
|
50
50
|
|
51
51
|
def override_step(step_name, options = {}, &block)
|
52
52
|
sequence.override_step(step_name, options, &block)
|
53
|
+
|
54
|
+
# also override the dry run step
|
55
|
+
return if dry_run_sequence.steps_for_name(step_name).length.zero?
|
56
|
+
|
57
|
+
dry_run_sequence.override_step(step_name, options, &block)
|
53
58
|
end
|
54
59
|
|
55
60
|
def error(*steps, &block)
|
@@ -131,6 +136,9 @@ module SmashTheState
|
|
131
136
|
|
132
137
|
# also copy the state class over
|
133
138
|
child_class.instance_variable_set(:@state_class, state_class && state_class.dup)
|
139
|
+
|
140
|
+
# also copy the dry run sequence
|
141
|
+
child_class.dry_run_sequence.steps.concat(dry_run_sequence.steps.map(&:dup))
|
134
142
|
end
|
135
143
|
end
|
136
144
|
end
|
data/spec/unit/operation_spec.rb
CHANGED
@@ -120,9 +120,9 @@ describe SmashTheState::Operation do
|
|
120
120
|
step_name,
|
121
121
|
step_options,
|
122
122
|
&implementation
|
123
|
-
)
|
123
|
+
)
|
124
124
|
|
125
|
-
|
125
|
+
klass.override_step(step_name, step_options, &implementation)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -147,6 +147,15 @@ describe SmashTheState::Operation do
|
|
147
147
|
state.countup += "two"
|
148
148
|
state
|
149
149
|
end
|
150
|
+
|
151
|
+
dry_run_sequence do
|
152
|
+
step :one
|
153
|
+
step :two
|
154
|
+
step :three do |state|
|
155
|
+
state.countup += "blar"
|
156
|
+
state
|
157
|
+
end
|
158
|
+
end
|
150
159
|
end
|
151
160
|
end
|
152
161
|
end
|
@@ -189,6 +198,10 @@ describe SmashTheState::Operation do
|
|
189
198
|
too_large = child.call(countup: "")
|
190
199
|
expect(too_large.errors[:countup]).to eq(["can't be blank"])
|
191
200
|
end
|
201
|
+
|
202
|
+
it "populates the dry run sequence and honors overridden steps" do
|
203
|
+
expect(child.dry_run(countup: "zero").countup).to eq("zerooneoneandahalfblar")
|
204
|
+
end
|
192
205
|
end
|
193
206
|
|
194
207
|
describe "self#dynamic_schema" do
|
@@ -223,8 +236,8 @@ describe SmashTheState::Operation do
|
|
223
236
|
describe "self#dry_run_sequence" do
|
224
237
|
context "with a custom dry run sequence block" do
|
225
238
|
before do
|
226
|
-
klass.step :step_one do |state|
|
227
|
-
state.name = state.name + " one"
|
239
|
+
klass.step :step_one do |state, _original_state, run_options|
|
240
|
+
state.name = state.name + " one " + run_options.to_json
|
228
241
|
state
|
229
242
|
end
|
230
243
|
|
@@ -253,16 +266,17 @@ describe SmashTheState::Operation do
|
|
253
266
|
end
|
254
267
|
|
255
268
|
it "provides a custom sequence for the dry run that " \
|
256
|
-
"contains only side-effect free steps"
|
269
|
+
"contains only side-effect free steps, and specifies " \
|
270
|
+
"whether the run is dry the run options" do
|
257
271
|
result = klass.call(name: "Sam")
|
258
|
-
expect(result.name).to eq("Sam one two three")
|
272
|
+
expect(result.name).to eq("Sam one {\"dry\":false} two three")
|
259
273
|
|
260
274
|
expect(
|
261
275
|
klass.dry_run_sequence.steps.all?(&:side_effect_free?)
|
262
276
|
).to eq(true)
|
263
277
|
|
264
278
|
dry_result = klass.dry_run(name: "Sam")
|
265
|
-
expect(dry_result.name).to eq("Sam one custom")
|
279
|
+
expect(dry_result.name).to eq("Sam one {\"dry\":true} custom")
|
266
280
|
end
|
267
281
|
end
|
268
282
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smash_the_state
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Connor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_attributes
|
@@ -83,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
87
|
-
rubygems_version: 2.7.6.2
|
86
|
+
rubygems_version: 3.1.4
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: A useful utility for transforming state that provides step sequencing, middleware,
|