clockwork-test 0.1.0 → 0.1.1
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/CHANGELOG.md +7 -0
- data/README.md +1 -0
- data/lib/clockwork/test/manager.rb +4 -2
- data/lib/clockwork/test/version.rb +1 -1
- data/lib/clockwork/test.rb +7 -1
- data/spec/acceptance/clock_spec.rb +31 -0
- data/spec/fixtures/clock.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04841b06996c44694737b6b20bcde77b09d1bded
|
4
|
+
data.tar.gz: 3d4bc58d1d60f70e62b18a39d9cd67dee6d33f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d9d5c7e1ce1698d11c491913bff94caf84d99127de21f3f808fcd36acd210be63e5633cf089249060309968790683d5528ce0c662b95116bcccbc6911504f24
|
7
|
+
data.tar.gz: abff8383bad36eb141262c93c2eff9fa49160a332dbb5ad78d12ab4d7a6abcb4165103ec42dc5808366c6c19bb443b05df4ba1934529c47f704d3052a31c5783
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -188,3 +188,4 @@ After each invocation of `Clockwork::Test.run` and assertions made against it, `
|
|
188
188
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
189
189
|
5. Push to the branch (`git push origin my-new-feature`)
|
190
190
|
6. Create a new Pull Request
|
191
|
+
7. Add a new entry to the CHANGELOG.md in the Current Release section. Include a description of the change, the PR, and your name.
|
@@ -9,18 +9,20 @@ module Clockwork
|
|
9
9
|
|
10
10
|
@total_ticks = 0
|
11
11
|
@max_ticks = opts[:max_ticks]
|
12
|
+
@start_time = opts[:start_time]
|
12
13
|
@end_time = opts[:end_time]
|
13
14
|
config[:logger].level = Logger::ERROR
|
14
15
|
end
|
15
16
|
|
16
17
|
def run(opts = {})
|
17
18
|
@max_ticks = opts[:max_ticks] if opts[:max_ticks]
|
19
|
+
@start_time = opts[:start_time] if opts[:start_time]
|
18
20
|
@end_time = opts[:end_time] if opts[:end_time]
|
19
21
|
@tick_speed = opts[:tick_speed]
|
20
22
|
|
21
|
-
if
|
23
|
+
if @start_time
|
22
24
|
@time_altered = true
|
23
|
-
Timecop.travel(
|
25
|
+
Timecop.travel(@start_time)
|
24
26
|
end
|
25
27
|
|
26
28
|
super()
|
data/lib/clockwork/test.rb
CHANGED
@@ -13,6 +13,11 @@ module Clockwork
|
|
13
13
|
::Clockwork.manager.every(period, job, options, &block)
|
14
14
|
::Clockwork::Test.manager.every(period, job, options, &block)
|
15
15
|
end
|
16
|
+
|
17
|
+
def configure(&block)
|
18
|
+
::Clockwork.manager.configure(&block)
|
19
|
+
::Clockwork::Test.manager.configure(&block)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
module Test
|
@@ -46,7 +51,8 @@ module Clockwork
|
|
46
51
|
}
|
47
52
|
|
48
53
|
# TODO parse file rather than loading it
|
49
|
-
# and overloading Clockwork::Methods::every
|
54
|
+
# and overloading Clockwork::Methods::every
|
55
|
+
# and Clockwork::Methods::configure
|
50
56
|
load file
|
51
57
|
|
52
58
|
manager.run(run_opts)
|
@@ -47,4 +47,35 @@ describe "Clockwork" do
|
|
47
47
|
it { should have_run(test_job_name, times: 2) }
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe "Run at certain time" do
|
52
|
+
subject(:clockwork) { Clockwork::Test }
|
53
|
+
|
54
|
+
before(:each) do
|
55
|
+
Time.zone = time_zone
|
56
|
+
|
57
|
+
Clockwork::Test.run(clock_opts)
|
58
|
+
end
|
59
|
+
|
60
|
+
after(:each) { Clockwork::Test.clear! }
|
61
|
+
|
62
|
+
let(:clock_opts) { { file: clock_file, start_time: start_time, max_ticks: 1 } }
|
63
|
+
|
64
|
+
let(:time_zone) { "US/Eastern" }
|
65
|
+
let(:start_time) { Time.zone.local(2008, 9, 1, 17, 30, 0) }
|
66
|
+
|
67
|
+
it { should have_run("Run at certain time").once }
|
68
|
+
|
69
|
+
context "before the job should be run" do
|
70
|
+
let(:start_time) { Time.zone.local(2015, 9, 13, 17, 29, 59) }
|
71
|
+
|
72
|
+
it { should_not have_run("Run at certain time") }
|
73
|
+
end
|
74
|
+
|
75
|
+
context "after the job should be run" do
|
76
|
+
let(:start_time) { Time.zone.local(2015, 9, 13, 17, 31, 0) }
|
77
|
+
|
78
|
+
it { should_not have_run("Run at certain time") }
|
79
|
+
end
|
80
|
+
end
|
50
81
|
end
|
data/spec/fixtures/clock.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Murphy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
120
|
- ".travis.yml"
|
121
|
+
- CHANGELOG.md
|
121
122
|
- Gemfile
|
122
123
|
- LICENSE.txt
|
123
124
|
- README.md
|