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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e5400764eb671ac7bd63e5fbd30ffd6d173f65d
4
- data.tar.gz: e73c3fa5290e7683b17f89b7e0f1b3c206a56bdb
3
+ metadata.gz: 04841b06996c44694737b6b20bcde77b09d1bded
4
+ data.tar.gz: 3d4bc58d1d60f70e62b18a39d9cd67dee6d33f49
5
5
  SHA512:
6
- metadata.gz: 48a656be5270cfac4ea3821b8fa55f8db3c67fc2abca37147fd7eefe3105110c90849447d5cb688549dd6b38a38a6e1ad1ad2ae9e3b6611d157f82296263331a
7
- data.tar.gz: 82fdef73b35c494bfc44a3239c94affca04e4ded03d0627576c6591e55a7e9e8d8b10e4a9e7fbbfeeadf800c5e53fed87dc6fc78a6af187599d79b8689c3efa4
6
+ metadata.gz: 4d9d5c7e1ce1698d11c491913bff94caf84d99127de21f3f808fcd36acd210be63e5633cf089249060309968790683d5528ce0c662b95116bcccbc6911504f24
7
+ data.tar.gz: abff8383bad36eb141262c93c2eff9fa49160a332dbb5ad78d12ab4d7a6abcb4165103ec42dc5808366c6c19bb443b05df4ba1934529c47f704d3052a31c5783
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## Current release (in development)
2
+
3
+ ## 0.1.1
4
+
5
+ * Pass clock file configuration to Clockwork::Test::Manager [#7](https://github.com/kevin-j-m/clockwork-test/pull/7)
6
+
7
+ *Kevin Murphy*
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 opts[:start_time]
23
+ if @start_time
22
24
  @time_altered = true
23
- Timecop.travel(opts[:start_time])
25
+ Timecop.travel(@start_time)
24
26
  end
25
27
 
26
28
  super()
@@ -1,5 +1,5 @@
1
1
  module Clockwork
2
2
  module Test
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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
@@ -10,4 +10,8 @@ module Clockwork
10
10
  every(1.minute, "Run a job") do
11
11
  "Here's a running job"
12
12
  end
13
+
14
+ every(1.day, "Run at certain time", at: "17:30") do
15
+ "Run at certain time"
16
+ end
13
17
  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.1.0
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-14 00:00:00.000000000 Z
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