stepper_motor 0.1.6 → 0.1.8
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/.github/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +51 -0
- data/CHANGELOG.md +77 -2
- data/Gemfile +11 -0
- data/README.md +13 -374
- data/Rakefile +21 -3
- data/bin/test +5 -0
- data/lib/generators/install_generator.rb +6 -1
- data/lib/generators/stepper_motor_migration_003.rb.erb +6 -0
- data/lib/generators/stepper_motor_migration_004.rb.erb +26 -0
- data/lib/stepper_motor/forward_scheduler.rb +8 -4
- data/lib/stepper_motor/journey/flow_control.rb +58 -0
- data/lib/stepper_motor/journey/recovery.rb +34 -0
- data/lib/stepper_motor/journey.rb +85 -84
- data/lib/stepper_motor/perform_step_job_v2.rb +2 -2
- data/lib/stepper_motor/railtie.rb +1 -1
- data/lib/stepper_motor/recover_stuck_journeys_job_v1.rb +3 -1
- data/lib/stepper_motor/step.rb +70 -5
- data/lib/stepper_motor/version.rb +1 -1
- data/lib/stepper_motor.rb +1 -2
- data/lib/tasks/stepper_motor_tasks.rake +8 -0
- data/manual/MANUAL.md +538 -0
- data/rbi/stepper_motor.rbi +459 -0
- data/sig/stepper_motor.rbs +406 -3
- data/stepper_motor.gemspec +49 -0
- data/test/dummy/Rakefile +8 -0
- data/test/dummy/app/assets/stylesheets/application.css +1 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/helpers/application_helper.rb +4 -0
- data/test/dummy/app/jobs/application_job.rb +9 -0
- data/test/dummy/app/mailers/application_mailer.rb +6 -0
- data/test/dummy/app/models/application_record.rb +5 -0
- data/test/dummy/app/views/layouts/application.html.erb +27 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/app/views/pwa/manifest.json.erb +22 -0
- data/test/dummy/app/views/pwa/service-worker.js +26 -0
- data/test/dummy/bin/dev +2 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/config/application.rb +28 -0
- data/test/dummy/config/boot.rb +7 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/database.yml +32 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/development.rb +71 -0
- data/test/dummy/config/environments/production.rb +91 -0
- data/test/dummy/config/environments/test.rb +55 -0
- data/test/dummy/config/initializers/content_security_policy.rb +27 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +10 -0
- data/test/dummy/config/initializers/inflections.rb +18 -0
- data/test/dummy/config/initializers/stepper_motor.rb +3 -0
- data/test/dummy/config/locales/en.yml +31 -0
- data/test/dummy/config/puma.rb +40 -0
- data/test/dummy/config/routes.rb +16 -0
- data/test/dummy/config/storage.yml +34 -0
- data/test/dummy/config.ru +8 -0
- data/test/dummy/db/migrate/20250520094921_stepper_motor_migration_001.rb +38 -0
- data/test/dummy/db/migrate/20250520094922_stepper_motor_migration_002.rb +8 -0
- data/test/dummy/db/migrate/20250522212312_stepper_motor_migration_003.rb +7 -0
- data/test/dummy/db/migrate/20250525110812_stepper_motor_migration_004.rb +28 -0
- data/test/dummy/db/schema.rb +37 -0
- data/test/dummy/public/400.html +114 -0
- data/test/dummy/public/404.html +114 -0
- data/test/dummy/public/406-unsupported-browser.html +114 -0
- data/test/dummy/public/422.html +114 -0
- data/test/dummy/public/500.html +114 -0
- data/test/dummy/public/icon.png +0 -0
- data/test/dummy/public/icon.svg +3 -0
- data/test/side_effects_helper.rb +67 -0
- data/test/stepper_motor/cyclic_scheduler_test.rb +77 -0
- data/{spec/stepper_motor/forward_scheduler_spec.rb → test/stepper_motor/forward_scheduler_test.rb} +9 -10
- data/test/stepper_motor/journey/exception_handling_test.rb +89 -0
- data/test/stepper_motor/journey/flow_control_test.rb +78 -0
- data/test/stepper_motor/journey/idempotency_test.rb +65 -0
- data/test/stepper_motor/journey/step_definition_test.rb +187 -0
- data/test/stepper_motor/journey/uniqueness_test.rb +48 -0
- data/test/stepper_motor/journey_test.rb +352 -0
- data/{spec/stepper_motor/recover_stuck_journeys_job_spec.rb → test/stepper_motor/recover_stuck_journeys_job_test.rb} +14 -14
- data/{spec/stepper_motor/recovery_spec.rb → test/stepper_motor/recovery_test.rb} +27 -27
- data/test/stepper_motor/test_helper_test.rb +44 -0
- data/test/stepper_motor_test.rb +9 -0
- data/test/test_helper.rb +46 -0
- metadata +120 -24
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.standard.yml +0 -4
- data/.yardopts +0 -1
- data/spec/helpers/side_effects.rb +0 -85
- data/spec/spec_helper.rb +0 -90
- data/spec/stepper_motor/cyclic_scheduler_spec.rb +0 -68
- data/spec/stepper_motor/generator_spec.rb +0 -16
- data/spec/stepper_motor/journey_spec.rb +0 -401
- data/spec/stepper_motor/test_helper_spec.rb +0 -48
- data/spec/stepper_motor_spec.rb +0 -7
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stepper_motor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-25 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -66,6 +65,34 @@ dependencies:
|
|
66
65
|
- - ">="
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: minitest
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rails
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '7.0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '7.0'
|
69
96
|
- !ruby/object:Gem::Dependency
|
70
97
|
name: sqlite3
|
71
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,16 +153,16 @@ dependencies:
|
|
126
153
|
name: standard
|
127
154
|
requirement: !ruby/object:Gem::Requirement
|
128
155
|
requirements:
|
129
|
-
- -
|
156
|
+
- - ">="
|
130
157
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
158
|
+
version: '0'
|
132
159
|
type: :development
|
133
160
|
prerelease: false
|
134
161
|
version_requirements: !ruby/object:Gem::Requirement
|
135
162
|
requirements:
|
136
|
-
- -
|
163
|
+
- - ">="
|
137
164
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
165
|
+
version: '0'
|
139
166
|
- !ruby/object:Gem::Dependency
|
140
167
|
name: magic_frozen_string_literal
|
141
168
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +205,20 @@ dependencies:
|
|
178
205
|
- - ">="
|
179
206
|
- !ruby/object:Gem::Version
|
180
207
|
version: '0'
|
208
|
+
- !ruby/object:Gem::Dependency
|
209
|
+
name: sord
|
210
|
+
requirement: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
type: :development
|
216
|
+
prerelease: false
|
217
|
+
version_requirements: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
181
222
|
description: Step workflows for Rails/ActiveRecord
|
182
223
|
email:
|
183
224
|
- me@julik.nl
|
@@ -185,23 +226,27 @@ executables: []
|
|
185
226
|
extensions: []
|
186
227
|
extra_rdoc_files: []
|
187
228
|
files:
|
188
|
-
- ".
|
189
|
-
- ".
|
190
|
-
- ".standard.yml"
|
191
|
-
- ".yardopts"
|
229
|
+
- ".github/dependabot.yml"
|
230
|
+
- ".github/workflows/ci.yml"
|
192
231
|
- CHANGELOG.md
|
232
|
+
- Gemfile
|
193
233
|
- LICENSE.md
|
194
234
|
- README.md
|
195
235
|
- Rakefile
|
196
236
|
- bin/console
|
197
237
|
- bin/setup
|
238
|
+
- bin/test
|
198
239
|
- lib/generators/install_generator.rb
|
199
240
|
- lib/generators/stepper_motor_migration_001.rb.erb
|
200
241
|
- lib/generators/stepper_motor_migration_002.rb.erb
|
242
|
+
- lib/generators/stepper_motor_migration_003.rb.erb
|
243
|
+
- lib/generators/stepper_motor_migration_004.rb.erb
|
201
244
|
- lib/stepper_motor.rb
|
202
245
|
- lib/stepper_motor/cyclic_scheduler.rb
|
203
246
|
- lib/stepper_motor/forward_scheduler.rb
|
204
247
|
- lib/stepper_motor/journey.rb
|
248
|
+
- lib/stepper_motor/journey/flow_control.rb
|
249
|
+
- lib/stepper_motor/journey/recovery.rb
|
205
250
|
- lib/stepper_motor/perform_step_job.rb
|
206
251
|
- lib/stepper_motor/perform_step_job_v2.rb
|
207
252
|
- lib/stepper_motor/railtie.rb
|
@@ -209,17 +254,70 @@ files:
|
|
209
254
|
- lib/stepper_motor/step.rb
|
210
255
|
- lib/stepper_motor/test_helper.rb
|
211
256
|
- lib/stepper_motor/version.rb
|
257
|
+
- lib/tasks/stepper_motor_tasks.rake
|
258
|
+
- manual/MANUAL.md
|
259
|
+
- rbi/stepper_motor.rbi
|
212
260
|
- sig/stepper_motor.rbs
|
213
|
-
-
|
214
|
-
-
|
215
|
-
-
|
216
|
-
-
|
217
|
-
-
|
218
|
-
-
|
219
|
-
-
|
220
|
-
-
|
221
|
-
-
|
222
|
-
-
|
261
|
+
- stepper_motor.gemspec
|
262
|
+
- test/dummy/Rakefile
|
263
|
+
- test/dummy/app/assets/stylesheets/application.css
|
264
|
+
- test/dummy/app/controllers/application_controller.rb
|
265
|
+
- test/dummy/app/helpers/application_helper.rb
|
266
|
+
- test/dummy/app/jobs/application_job.rb
|
267
|
+
- test/dummy/app/mailers/application_mailer.rb
|
268
|
+
- test/dummy/app/models/application_record.rb
|
269
|
+
- test/dummy/app/views/layouts/application.html.erb
|
270
|
+
- test/dummy/app/views/layouts/mailer.html.erb
|
271
|
+
- test/dummy/app/views/layouts/mailer.text.erb
|
272
|
+
- test/dummy/app/views/pwa/manifest.json.erb
|
273
|
+
- test/dummy/app/views/pwa/service-worker.js
|
274
|
+
- test/dummy/bin/dev
|
275
|
+
- test/dummy/bin/rails
|
276
|
+
- test/dummy/bin/rake
|
277
|
+
- test/dummy/bin/setup
|
278
|
+
- test/dummy/config.ru
|
279
|
+
- test/dummy/config/application.rb
|
280
|
+
- test/dummy/config/boot.rb
|
281
|
+
- test/dummy/config/cable.yml
|
282
|
+
- test/dummy/config/database.yml
|
283
|
+
- test/dummy/config/environment.rb
|
284
|
+
- test/dummy/config/environments/development.rb
|
285
|
+
- test/dummy/config/environments/production.rb
|
286
|
+
- test/dummy/config/environments/test.rb
|
287
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
288
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
289
|
+
- test/dummy/config/initializers/inflections.rb
|
290
|
+
- test/dummy/config/initializers/stepper_motor.rb
|
291
|
+
- test/dummy/config/locales/en.yml
|
292
|
+
- test/dummy/config/puma.rb
|
293
|
+
- test/dummy/config/routes.rb
|
294
|
+
- test/dummy/config/storage.yml
|
295
|
+
- test/dummy/db/migrate/20250520094921_stepper_motor_migration_001.rb
|
296
|
+
- test/dummy/db/migrate/20250520094922_stepper_motor_migration_002.rb
|
297
|
+
- test/dummy/db/migrate/20250522212312_stepper_motor_migration_003.rb
|
298
|
+
- test/dummy/db/migrate/20250525110812_stepper_motor_migration_004.rb
|
299
|
+
- test/dummy/db/schema.rb
|
300
|
+
- test/dummy/public/400.html
|
301
|
+
- test/dummy/public/404.html
|
302
|
+
- test/dummy/public/406-unsupported-browser.html
|
303
|
+
- test/dummy/public/422.html
|
304
|
+
- test/dummy/public/500.html
|
305
|
+
- test/dummy/public/icon.png
|
306
|
+
- test/dummy/public/icon.svg
|
307
|
+
- test/side_effects_helper.rb
|
308
|
+
- test/stepper_motor/cyclic_scheduler_test.rb
|
309
|
+
- test/stepper_motor/forward_scheduler_test.rb
|
310
|
+
- test/stepper_motor/journey/exception_handling_test.rb
|
311
|
+
- test/stepper_motor/journey/flow_control_test.rb
|
312
|
+
- test/stepper_motor/journey/idempotency_test.rb
|
313
|
+
- test/stepper_motor/journey/step_definition_test.rb
|
314
|
+
- test/stepper_motor/journey/uniqueness_test.rb
|
315
|
+
- test/stepper_motor/journey_test.rb
|
316
|
+
- test/stepper_motor/recover_stuck_journeys_job_test.rb
|
317
|
+
- test/stepper_motor/recovery_test.rb
|
318
|
+
- test/stepper_motor/test_helper_test.rb
|
319
|
+
- test/stepper_motor_test.rb
|
320
|
+
- test/test_helper.rb
|
223
321
|
homepage: https://steppermotor.dev
|
224
322
|
licenses:
|
225
323
|
- LGPL
|
@@ -228,7 +326,6 @@ metadata:
|
|
228
326
|
homepage_uri: https://steppermotor.dev
|
229
327
|
source_code_uri: https://github.com/stepper-motor/stepper_motor
|
230
328
|
changelog_uri: https://github.com/stepper-motor/stepper_motor/blob/main/CHANGELOG.md
|
231
|
-
post_install_message:
|
232
329
|
rdoc_options: []
|
233
330
|
require_paths:
|
234
331
|
- lib
|
@@ -243,8 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
340
|
- !ruby/object:Gem::Version
|
244
341
|
version: '0'
|
245
342
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
247
|
-
signing_key:
|
343
|
+
rubygems_version: 3.6.6
|
248
344
|
specification_version: 4
|
249
345
|
summary: Effortless step workflows that embed nicely inside Rails
|
250
346
|
test_files: []
|
data/.rspec
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.1.1
|
data/.standard.yml
DELETED
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--markup markdown - docs/MANUAL.md
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SideEffects
|
4
|
-
module SpecHelper
|
5
|
-
def self.included(into)
|
6
|
-
into.before(:each) { SideEffects.clear! }
|
7
|
-
into.after(:each) { SideEffects.clear! }
|
8
|
-
super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.produced?(name)
|
13
|
-
Thread.current[:side_effects].to_h.key?(name.to_s)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.none?
|
17
|
-
Thread.current[:side_effects].to_h.empty?
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.names
|
21
|
-
Thread.current[:side_effects].to_h.keys.map(&:to_s)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.clear!
|
25
|
-
Thread.current[:side_effects] = {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.touch!(name)
|
29
|
-
if Thread.current[:side_effects].nil?
|
30
|
-
raise <<~ERROR
|
31
|
-
The current thread locals do not contain :side_effects, which means that your job
|
32
|
-
is running on a different thread than the specs. This is probably due to bad configuration
|
33
|
-
of the ActiveJob test adapter.
|
34
|
-
ERROR
|
35
|
-
end
|
36
|
-
Thread.current[:side_effects][name.to_s] = true
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec::Matchers.define :have_produced_side_effects_named do |*side_effect_names|
|
40
|
-
match(notify_expectation_failures: true) do |actual|
|
41
|
-
SideEffects.clear!
|
42
|
-
actual.call
|
43
|
-
side_effect_names.each do |side_effect_name|
|
44
|
-
expect(SideEffects).to be_produced(side_effect_name), "The side effect named #{side_effect_name.inspect} should have been produced, but wasn't"
|
45
|
-
end
|
46
|
-
true
|
47
|
-
end
|
48
|
-
|
49
|
-
def supports_block_expectations?
|
50
|
-
true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
RSpec::Matchers.define :not_have_produced_side_effects_named do |*side_effect_names|
|
55
|
-
match(notify_expectation_failures: true) do |actual|
|
56
|
-
expect(side_effect_names).not_to be_empty
|
57
|
-
|
58
|
-
SideEffects.clear!
|
59
|
-
actual.call
|
60
|
-
|
61
|
-
side_effect_names.each do |side_effect_name|
|
62
|
-
expect(SideEffects).not_to be_produced(side_effect_name), "The side effect named #{side_effect_name.inspect} should not have been produced, but was"
|
63
|
-
end
|
64
|
-
|
65
|
-
true
|
66
|
-
end
|
67
|
-
|
68
|
-
def supports_block_expectations?
|
69
|
-
true
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
RSpec::Matchers.define :not_have_produced_any_side_effects do
|
74
|
-
match(notify_expectation_failures: true) do |actual|
|
75
|
-
SideEffects.clear!
|
76
|
-
actual.call
|
77
|
-
expect(SideEffects).to be_none
|
78
|
-
true
|
79
|
-
end
|
80
|
-
|
81
|
-
def supports_block_expectations?
|
82
|
-
true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "stepper_motor"
|
4
|
-
require "active_support/testing/time_helpers"
|
5
|
-
require "active_job"
|
6
|
-
require "active_record"
|
7
|
-
require "globalid"
|
8
|
-
require_relative "helpers/side_effects"
|
9
|
-
require "fileutils"
|
10
|
-
|
11
|
-
module StepperMotorRailtieTestHelpers
|
12
|
-
def establish_test_connection
|
13
|
-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: fake_app_root + "/db.sqlite3")
|
14
|
-
StepperMotor::InstallGenerator.source_root(File.dirname(__FILE__) + "/../../lib")
|
15
|
-
end
|
16
|
-
|
17
|
-
def fake_app_root
|
18
|
-
File.dirname(__FILE__) + "/app"
|
19
|
-
end
|
20
|
-
|
21
|
-
def run_generator
|
22
|
-
generator = StepperMotor::InstallGenerator.new
|
23
|
-
generator.destination_root = fake_app_root
|
24
|
-
generator.create_migration_file
|
25
|
-
end
|
26
|
-
|
27
|
-
def run_migrations
|
28
|
-
# Before running the migrations we need to require the migration files, since there is no
|
29
|
-
# "full" Rails environment available
|
30
|
-
Dir.glob(fake_app_root + "/db/migrate/*.rb").sort.each do |migration_file_path|
|
31
|
-
require migration_file_path
|
32
|
-
end
|
33
|
-
|
34
|
-
ActiveRecord::Migrator.migrations_paths = [File.join(fake_app_root + "/db/migrate")]
|
35
|
-
ActiveRecord::Tasks::DatabaseTasks.root = fake_app_root
|
36
|
-
ActiveRecord::Tasks::DatabaseTasks.migrate
|
37
|
-
end
|
38
|
-
extend self
|
39
|
-
end
|
40
|
-
|
41
|
-
module ActiveSupportTestCaseMethodsStub
|
42
|
-
def self.included(into)
|
43
|
-
into.before(:each) { before_setup }
|
44
|
-
into.after(:each) { after_teardown }
|
45
|
-
end
|
46
|
-
|
47
|
-
def before_setup
|
48
|
-
# Blank implementation as TestCase modules super() into it
|
49
|
-
end
|
50
|
-
|
51
|
-
def after_teardown
|
52
|
-
# Blank implementation as TestCase modules super() into it
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
module JourneyDefinitionHelper
|
57
|
-
def create_journey_subclass(&blk)
|
58
|
-
# https://stackoverflow.com/questions/4113479/dynamic-class-definition-with-a-class-name
|
59
|
-
random_component = Random.hex(2)
|
60
|
-
random_name = "JourneySubclass#{random_component}"
|
61
|
-
klass = Class.new(StepperMotor::Journey, &blk)
|
62
|
-
Object.const_set(random_name, klass)
|
63
|
-
klass
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
RSpec.configure do |config|
|
68
|
-
# Enable flags like --only-failures and --next-failure
|
69
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
70
|
-
|
71
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
72
|
-
config.disable_monkey_patching!
|
73
|
-
|
74
|
-
config.expect_with :rspec do |c|
|
75
|
-
c.syntax = :expect
|
76
|
-
end
|
77
|
-
|
78
|
-
config.include ActiveSupport::Testing::TimeHelpers
|
79
|
-
config.include StepperMotorRailtieTestHelpers
|
80
|
-
config.include SideEffects::SpecHelper
|
81
|
-
config.include ActiveSupportTestCaseMethodsStub
|
82
|
-
config.include JourneyDefinitionHelper
|
83
|
-
|
84
|
-
config.before :suite do
|
85
|
-
StepperMotorRailtieTestHelpers.establish_test_connection
|
86
|
-
StepperMotorRailtieTestHelpers.run_generator
|
87
|
-
StepperMotorRailtieTestHelpers.run_migrations
|
88
|
-
ActiveJob::Base.logger.level = Logger::FATAL
|
89
|
-
end
|
90
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe "StepperMotor::CyclicScheduler" do
|
6
|
-
include ActiveJob::TestHelper
|
7
|
-
|
8
|
-
before do
|
9
|
-
@previous_scheduler = StepperMotor.scheduler
|
10
|
-
StepperMotor::Journey.delete_all
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
StepperMotor.scheduler = @previous_scheduler
|
15
|
-
end
|
16
|
-
|
17
|
-
def far_future_journey_class
|
18
|
-
@klass ||= create_journey_subclass do
|
19
|
-
step :do_thing, wait: 40.minutes do
|
20
|
-
raise "We do not test this so it should never run"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "does not schedule a journey which is too far in the future" do
|
26
|
-
scheduler = StepperMotor::CyclicScheduler.new(cycle_duration: 30.seconds)
|
27
|
-
StepperMotor.scheduler = scheduler
|
28
|
-
|
29
|
-
expect(scheduler).to receive(:schedule).with(instance_of(far_future_journey_class)).once.and_call_original
|
30
|
-
_journey = far_future_journey_class.create!
|
31
|
-
|
32
|
-
expect(scheduler).not_to receive(:schedule)
|
33
|
-
scheduler.run_scheduling_cycle
|
34
|
-
end
|
35
|
-
|
36
|
-
it "only schedules journeys which are within its execution window" do
|
37
|
-
scheduler = StepperMotor::CyclicScheduler.new(cycle_duration: 40.minutes)
|
38
|
-
StepperMotor.scheduler = scheduler
|
39
|
-
|
40
|
-
expect(scheduler).to receive(:schedule).with(instance_of(far_future_journey_class)).once.and_call_original
|
41
|
-
journey = far_future_journey_class.create!
|
42
|
-
|
43
|
-
expect(scheduler).to receive(:schedule).with(journey).and_call_original
|
44
|
-
scheduler.run_scheduling_cycle
|
45
|
-
end
|
46
|
-
|
47
|
-
it "also schedules journeys which had to run in the past" do
|
48
|
-
scheduler = StepperMotor::CyclicScheduler.new(cycle_duration: 10.seconds)
|
49
|
-
StepperMotor.scheduler = scheduler
|
50
|
-
|
51
|
-
expect(scheduler).to receive(:schedule).with(instance_of(far_future_journey_class)).once.and_call_original
|
52
|
-
journey = far_future_journey_class.create!
|
53
|
-
journey.update!(next_step_to_be_performed_at: 10.minutes.ago)
|
54
|
-
|
55
|
-
expect(scheduler).to receive(:schedule).with(journey).and_call_original
|
56
|
-
scheduler.run_scheduling_cycle
|
57
|
-
end
|
58
|
-
|
59
|
-
it "performs the scheduling job" do
|
60
|
-
scheduler = StepperMotor::CyclicScheduler.new(cycle_duration: 10.seconds)
|
61
|
-
StepperMotor.scheduler = scheduler
|
62
|
-
job_class = StepperMotor::CyclicScheduler::RunSchedulingCycleJob
|
63
|
-
expect(scheduler).to receive(:run_scheduling_cycle).and_call_original
|
64
|
-
job_class.perform_now
|
65
|
-
end
|
66
|
-
|
67
|
-
it "does not perform the job if the configured scheduler is not the CyclicScheduler"
|
68
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe "StepperMotor::InstallGenerator" do
|
6
|
-
it "is able to set up a test database" do
|
7
|
-
expect {
|
8
|
-
establish_test_connection
|
9
|
-
run_generator
|
10
|
-
run_migrations
|
11
|
-
}.not_to raise_error
|
12
|
-
expect(ActiveRecord::Base.connection.tables).to include("stepper_motor_journeys")
|
13
|
-
ensure
|
14
|
-
FileUtils.rm_rf(fake_app_root)
|
15
|
-
end
|
16
|
-
end
|