clockwork-test 0.3.0 → 0.4.0

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: 0720316ef603e9190a19ebfd87639c2f8db3f5606f809fcae5d82719624ef300
4
- data.tar.gz: bebe9b55cfba6288e3d06331edab3196ba2c42434aaa2b830e097d9afd2d59c2
3
+ metadata.gz: de2974b4b235f211ee27a41608cd6ad9e3e203d7a6ad3407c7bd4ec52f61ef65
4
+ data.tar.gz: d10601201d5ee48f74221a56d2944e813d811e21fdb4f946d8288f7d279a58a8
5
5
  SHA512:
6
- metadata.gz: 9838b238b123348e3d692fbbdc799659997e972722006d751f46660b896a1a5536c2854c3ff85c0050009df69a6ab3ba7956a1aff3b8d3cf7fa3dc378519ea24
7
- data.tar.gz: 5ba2548b8f6e6bc0846cda612930728a010542564f25da59f227b7b7ff353f8134f85ea52990de7a8b5a134b5a2ff9917f7dbf3542f558f20308d9f5570472f3
6
+ metadata.gz: d851795a2d280f58fd493190b8f6a337034d316365e69829ae3fcc347ac509ff14689d3affe7403ef4e1dc1cd09d6c57dfcef0e1d79b8e882105ce6004d7f9cf
7
+ data.tar.gz: 539d7b1e31e071e9ba330b8761a457d1ba83d1a5ea58e8459524a2f6cbd60e3994f98514262fc199a865c45c961af3c15d8873cb86fbfc288bfa35a1e51cf493
data/Appraisals CHANGED
@@ -17,3 +17,7 @@ end
17
17
  appraise "clockwork-2-0-2" do
18
18
  gem "clockwork", "2.0.2"
19
19
  end
20
+
21
+ appraise "clockwork-2-0-3" do
22
+ gem "clockwork", "2.0.3"
23
+ end
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 }
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "clockwork", "1.3.1"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- clockwork-test (0.3.0)
4
+ clockwork-test (0.4.0)
5
5
  clockwork
6
6
  timecop
7
7
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rspec-its
70
70
 
71
71
  BUNDLED WITH
72
- 1.16.2
72
+ 1.17.3
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "clockwork", "2.0.0"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- clockwork-test (0.3.0)
4
+ clockwork-test (0.4.0)
5
5
  clockwork
6
6
  timecop
7
7
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rspec-its
70
70
 
71
71
  BUNDLED WITH
72
- 1.16.2
72
+ 1.17.3
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "clockwork", "2.0.1"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- clockwork-test (0.3.0)
4
+ clockwork-test (0.4.0)
5
5
  clockwork
6
6
  timecop
7
7
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rspec-its
70
70
 
71
71
  BUNDLED WITH
72
- 1.16.2
72
+ 1.17.3
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "clockwork", "2.0.2"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- clockwork-test (0.3.0)
4
+ clockwork-test (0.4.0)
5
5
  clockwork
6
6
  timecop
7
7
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rspec-its
70
70
 
71
71
  BUNDLED WITH
72
- 1.16.2
72
+ 1.17.3
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "clockwork", "2.0.3"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- clockwork-test (0.2.0)
4
+ clockwork-test (0.4.0)
5
5
  clockwork
6
6
  timecop
7
7
 
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  rspec-its
68
68
 
69
69
  BUNDLED WITH
70
- 1.16.0.pre.3
70
+ 1.17.3
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "clockwork", :git => "https://github.com/Rykian/clockwork"
6
+ gem "clockwork", git: "https://github.com/Rykian/clockwork"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: ..
10
10
  specs:
11
- clockwork-test (0.3.0)
11
+ clockwork-test (0.4.0)
12
12
  clockwork
13
13
  timecop
14
14
 
@@ -72,4 +72,4 @@ DEPENDENCIES
72
72
  rspec-its
73
73
 
74
74
  BUNDLED WITH
75
- 1.16.2
75
+ 1.17.3
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Clockwork
2
2
  module Test
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -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 }
@@ -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.3.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: 2018-06-20 00:00:00.000000000 Z
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
- rubyforge_project:
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