stepper_motor 0.1.3 → 0.1.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf607219c84d08a1a2f523a8bfdb2f65735ef947b9d18df6079f8b3154ffce5
|
4
|
+
data.tar.gz: e75a98bbdc4e87eb2d7053cd045dcd97733fa3d748e5db7193c41f9d10042183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66dbb65657298caab318a6feae9ce01c402f61f56f95d26b12e82f803c71f8dc12dcca4c18475ab91782f1082cedcffe7a48ffef89ce9d14c7c4ee114afb8b2e
|
7
|
+
data.tar.gz: 2dbcefac4833a846fc0abd0dda9cdfc1c4ef6212f6d7e94ee887548e57ed3d5aeb8bdb9ff0ac71803ec3b0db88b5df1ea4dd34c8b19c733d200ebd4ae4d9b2ed
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
## [0.1.
|
1
|
+
## [0.1.x] - 2025-01-01
|
2
2
|
|
3
|
-
-
|
3
|
+
- Development versions. Expect bugs of mysterious kinds.
|
@@ -13,6 +13,6 @@
|
|
13
13
|
# this scheduler is not a good fit for you, and you will need to use the {CyclicScheduler} instead.
|
14
14
|
class StepperMotor::ForwardScheduler
|
15
15
|
def schedule(journey)
|
16
|
-
StepperMotor::PerformStepJob.set(
|
16
|
+
StepperMotor::PerformStepJob.set(wait_until: journey.next_step_to_be_performed_at).perform_later(journey.to_global_id.to_s)
|
17
17
|
end
|
18
18
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,11 +13,9 @@ RSpec.describe "StepperMotor::CyclicScheduler" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def far_future_journey_class
|
16
|
-
@klass ||=
|
17
|
-
|
18
|
-
|
19
|
-
raise "We do not test this so it should never run"
|
20
|
-
end
|
16
|
+
@klass ||= create_journey_subclass do
|
17
|
+
step :do_thing, wait: 40.minutes do
|
18
|
+
raise "We do not test this so it should never run"
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "StepperMotor::ForwardScheduler" do
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
6
|
+
before do
|
7
|
+
@previous_scheduler = StepperMotor.scheduler
|
8
|
+
StepperMotor::Journey.delete_all
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
StepperMotor.scheduler = @previous_scheduler
|
13
|
+
end
|
14
|
+
|
15
|
+
def far_future_journey_class
|
16
|
+
@klass ||= create_journey_subclass do
|
17
|
+
step :do_thing, wait: 40.minutes do
|
18
|
+
raise "We do not test this so it should never run"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "schedules a journey 40 minutes ahead" do
|
24
|
+
scheduler = StepperMotor::ForwardScheduler.new
|
25
|
+
StepperMotor.scheduler = scheduler
|
26
|
+
|
27
|
+
expect(scheduler).to receive(:schedule).with(instance_of(far_future_journey_class)).once.and_call_original
|
28
|
+
_journey = far_future_journey_class.create!
|
29
|
+
|
30
|
+
expect(enqueued_jobs.size).to eq(1)
|
31
|
+
job = enqueued_jobs.first
|
32
|
+
|
33
|
+
expect(job["job_class"]).to eq("StepperMotor::PerformStepJob")
|
34
|
+
expect(job["scheduled_at"]).not_to be_nil
|
35
|
+
|
36
|
+
scheduled_at = Time.parse(job["scheduled_at"])
|
37
|
+
expect(scheduled_at).to be_within(5.seconds).of(40.minutes.from_now)
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- spec/helpers/side_effects.rb
|
198
198
|
- spec/spec_helper.rb
|
199
199
|
- spec/stepper_motor/cyclic_scheduler_spec.rb
|
200
|
+
- spec/stepper_motor/forward_scheduler_spec.rb
|
200
201
|
- spec/stepper_motor/generator_spec.rb
|
201
202
|
- spec/stepper_motor/journey_spec.rb
|
202
203
|
- spec/stepper_motor/test_helper_spec.rb
|