clockwork-test 0.3.0 → 0.4.0
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/Appraisals +4 -0
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/gemfiles/clockwork_1_3_1.gemfile +1 -1
- data/gemfiles/clockwork_1_3_1.gemfile.lock +2 -2
- data/gemfiles/clockwork_2_0_0.gemfile +1 -1
- data/gemfiles/clockwork_2_0_0.gemfile.lock +2 -2
- data/gemfiles/clockwork_2_0_1.gemfile +1 -1
- data/gemfiles/clockwork_2_0_1.gemfile.lock +2 -2
- data/gemfiles/clockwork_2_0_2.gemfile +1 -1
- data/gemfiles/clockwork_2_0_2.gemfile.lock +2 -2
- data/gemfiles/clockwork_2_0_3.gemfile +1 -1
- data/gemfiles/clockwork_2_0_3.gemfile.lock +2 -2
- data/gemfiles/clockwork_master.gemfile +2 -2
- data/gemfiles/clockwork_master.gemfile.lock +2 -2
- data/lib/clockwork/test.rb +10 -0
- data/lib/clockwork/test/version.rb +1 -1
- data/spec/acceptance/clock_spec.rb +45 -0
- data/spec/fixtures/clock.rb +10 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de2974b4b235f211ee27a41608cd6ad9e3e203d7a6ad3407c7bd4ec52f61ef65
|
4
|
+
data.tar.gz: d10601201d5ee48f74221a56d2944e813d811e21fdb4f946d8288f7d279a58a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d851795a2d280f58fd493190b8f6a337034d316365e69829ae3fcc347ac509ff14689d3affe7403ef4e1dc1cd09d6c57dfcef0e1d79b8e882105ce6004d7f9cf
|
7
|
+
data.tar.gz: 539d7b1e31e071e9ba330b8761a457d1ba83d1a5ea58e8459524a2f6cbd60e3994f98514262fc199a865c45c961af3c15d8873cb86fbfc288bfa35a1e51cf493
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Current release (in development)
|
2
2
|
|
3
|
+
## 0.4.0 [2020-04-23]
|
4
|
+
|
5
|
+
* Support clockwork callbacks [#34] (https://github.com/kevin-j-m/clockwork-test/pull/34)
|
6
|
+
|
7
|
+
*Rahul Agrawal*
|
8
|
+
|
3
9
|
## 0.3.0 [2018-06-19]
|
4
10
|
|
5
11
|
* Introduce release process documentation [#14](https://github.com/kevin-j-m/clockwork-test/pull/14)
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ describe Clockwork do
|
|
57
57
|
after(:each) { Clockwork::Test.clear! }
|
58
58
|
|
59
59
|
it "runs the job once" do
|
60
|
-
Clockwork::Test.run(max_ticks: 1)
|
60
|
+
Clockwork::Test.run(max_ticks: 1, file: "./clockwork.rb")
|
61
61
|
|
62
62
|
expect(Clockwork::Test.ran_job?("Run a job")).to be_truthy
|
63
63
|
expect(Clockwork::Test.times_run("Run a job")).to eq 1
|
@@ -69,7 +69,7 @@ describe Clockwork do
|
|
69
69
|
end_time = Time.new(2015, 11, 2, 3, 0, 0)
|
70
70
|
|
71
71
|
Clockwork::Test.run(start_time: start_time, end_time: end_time, tick_speed:
|
72
|
-
1.minute)
|
72
|
+
1.minute, file: "./clockwork.rb")
|
73
73
|
|
74
74
|
expect(Clockwork::Test.times_run("Run a job")).to eq 60
|
75
75
|
end
|
@@ -77,7 +77,7 @@ describe Clockwork do
|
|
77
77
|
describe "RSpec Custom Matcher" do
|
78
78
|
subject(:clockwork) { Clockwork::Test }
|
79
79
|
|
80
|
-
before { Clockwork::Test.run(max_ticks: 1) }
|
80
|
+
before { Clockwork::Test.run(max_ticks: 1, file: "./clockwork.rb") }
|
81
81
|
|
82
82
|
it { should have_run("Run a job") }
|
83
83
|
it { should have_run("Run a job").once }
|
data/lib/clockwork/test.rb
CHANGED
@@ -18,6 +18,16 @@ module Clockwork
|
|
18
18
|
::Clockwork.manager.configure(&block)
|
19
19
|
::Clockwork::Test.manager.configure(&block)
|
20
20
|
end
|
21
|
+
|
22
|
+
def handler(&block)
|
23
|
+
::Clockwork.manager.handler(&block)
|
24
|
+
::Clockwork::Test.manager.handler(&block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def on(event, options={}, &block)
|
28
|
+
::Clockwork.manager.on(event, options, &block)
|
29
|
+
::Clockwork::Test.manager.on(event, options, &block)
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
module Test
|
@@ -22,6 +22,22 @@ describe "Clockwork" do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe "Runs the callback" do
|
26
|
+
let(:logger) { instance_double("Logger") }
|
27
|
+
around do |example|
|
28
|
+
old_logger = Clockwork::Test.manager.config[:logger]
|
29
|
+
Clockwork::Test.configure { |config| config[:logger] = logger }
|
30
|
+
example.run
|
31
|
+
Clockwork::Test.configure { |config| config[:logger] = old_logger }
|
32
|
+
end
|
33
|
+
|
34
|
+
it "runs the defined callback" do
|
35
|
+
allow(logger).to receive(:info)
|
36
|
+
Clockwork::Test.run(file: clock_file, max_ticks: 1)
|
37
|
+
expect(logger).to have_received(:info).once.with("Running before tick")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
25
41
|
describe "Custom matchers" do
|
26
42
|
subject(:clockwork) { Clockwork::Test }
|
27
43
|
|
@@ -77,6 +93,35 @@ describe "Clockwork" do
|
|
77
93
|
end
|
78
94
|
end
|
79
95
|
|
96
|
+
describe "Run with wildcards" do
|
97
|
+
subject(:clockwork) { Clockwork::Test }
|
98
|
+
|
99
|
+
before(:each) { Clockwork::Test.run(clock_opts) }
|
100
|
+
after(:each) { Clockwork::Test.clear! }
|
101
|
+
|
102
|
+
let(:clock_opts) { { file: clock_file, start_time: start_time, end_time: end_time, tick_speed: 1.minute } }
|
103
|
+
|
104
|
+
let(:start_time) { Time.new(2008, 9, 1, 17, 0, 0) }
|
105
|
+
let(:end_time) { start_time + 1.hour }
|
106
|
+
|
107
|
+
it { should have_run("Run at 10 past the hour").once }
|
108
|
+
|
109
|
+
it "logs the job being run" do
|
110
|
+
expect(Clockwork::Test.times_run("Run at 10 past the hour")).to eq 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "Run with no custom block" do
|
115
|
+
subject(:clockwork) { Clockwork::Test }
|
116
|
+
|
117
|
+
before(:each) { Clockwork::Test.run(clock_opts) }
|
118
|
+
after(:each) { Clockwork::Test.clear! }
|
119
|
+
|
120
|
+
let(:clock_opts) { { file: clock_file, max_ticks: 1, tick_speed: 1.hour } }
|
121
|
+
|
122
|
+
it { should have_run("JobNamePassedToTheHandler").once }
|
123
|
+
end
|
124
|
+
|
80
125
|
if Gem::Version.new("2.0.2") < Gem::Version.new(Gem.loaded_specs["clockwork"].version)
|
81
126
|
describe "Runs when skip_first_run is specified" do
|
82
127
|
subject(:clockwork) { Clockwork::Test }
|
data/spec/fixtures/clock.rb
CHANGED
@@ -6,6 +6,10 @@ module Clockwork
|
|
6
6
|
end
|
7
7
|
|
8
8
|
handler { |job| logger.info "Running #{job}" }
|
9
|
+
on(:before_tick) do
|
10
|
+
logger ||= manager.config[:logger]
|
11
|
+
logger.info "Running before tick"
|
12
|
+
end
|
9
13
|
|
10
14
|
every(1.minute, "Run a job") do
|
11
15
|
"Here's a running job"
|
@@ -18,4 +22,10 @@ module Clockwork
|
|
18
22
|
every(1.day, "Run but not at start", skip_first_run: true) do
|
19
23
|
"Run at certain time"
|
20
24
|
end
|
25
|
+
|
26
|
+
every(1.hour, "Run at 10 past the hour", at: "**:10") do
|
27
|
+
"Run at 10 past the hour"
|
28
|
+
end
|
29
|
+
|
30
|
+
every(1.hour, "JobNamePassedToTheHandler")
|
21
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clockwork-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Murphy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -184,8 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
|
-
|
188
|
-
rubygems_version: 2.7.7
|
187
|
+
rubygems_version: 3.1.2
|
189
188
|
signing_key:
|
190
189
|
specification_version: 4
|
191
190
|
summary: Test clockwork scheduled jobs
|