clockwork-test 0.1.1 → 0.2.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
  SHA1:
3
- metadata.gz: 04841b06996c44694737b6b20bcde77b09d1bded
4
- data.tar.gz: 3d4bc58d1d60f70e62b18a39d9cd67dee6d33f49
3
+ metadata.gz: ae0cfddfe422335668da047a76e3f000bc2d3c47
4
+ data.tar.gz: 293e4428ae8f1da04648211915b7c7a83b085085
5
5
  SHA512:
6
- metadata.gz: 4d9d5c7e1ce1698d11c491913bff94caf84d99127de21f3f808fcd36acd210be63e5633cf089249060309968790683d5528ce0c662b95116bcccbc6911504f24
7
- data.tar.gz: abff8383bad36eb141262c93c2eff9fa49160a332dbb5ad78d12ab4d7a6abcb4165103ec42dc5808366c6c19bb443b05df4ba1934529c47f704d3052a31c5783
6
+ metadata.gz: eb9a8a9c169b32f0923db5ade9e50a0386593b741eeb8a8bce61ec78472109faf7fc6a4afe29079ba34598ee56461b44e579641f539c5da69e09cfff445eef07
7
+ data.tar.gz: 4d8e20a57c3687a2ca5f2141286ce62d941cf3309803f560819f7a831965f493c70564cc4e947c60ffc71da212ffbce5a9f0acd3212d4279d056d296193b18be
data/.travis.yml CHANGED
@@ -2,13 +2,17 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 1.9.3
6
- - 2.0
7
- - 2.1
8
- - 2.2
5
+ - 2.2.7
6
+ - 2.3.4
7
+ - 2.4.1
9
8
  - ruby-head
10
9
  script:
11
10
  - bundle exec rspec
12
11
  matrix:
13
12
  allow_failures:
14
13
  - rvm: ruby-head
14
+ gemfile:
15
+ - gemfiles/clockwork_1_3_1.gemfile
16
+ - gemfiles/clockwork_2_0_0.gemfile
17
+ - gemfiles/clockwork_2_0_1.gemfile
18
+ - gemfiles/clockwork_2_0_2.gemfile
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise "clockwork-1-3-1" do
2
+ gem "clockwork", "1.3.1"
3
+ end
4
+
5
+ appraise "clockwork-2-0-0" do
6
+ gem "clockwork", "2.0.0"
7
+ end
8
+
9
+ appraise "clockwork-2-0-1" do
10
+ gem "clockwork", "2.0.1"
11
+ end
12
+
13
+ appraise "clockwork-2-0-2" do
14
+ gem "clockwork", "2.0.2"
15
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  ## Current release (in development)
2
2
 
3
+ ## 0.2.0
4
+
5
+ * Refactor custom matcher to remove repeated code [#8](https://github.com/kevin-j-m/clockwork-test/pull/8)
6
+
7
+ *Kevin Murphy*
8
+
9
+ * Test against ruby 2.3 explicitly [#9](https://github.com/kevin-j-m/clockwork-test/pull/9)
10
+
11
+ *Kevin Murphy*
12
+
13
+ * Avoid changing global time zone state [#10](https://github.com/kevin-j-m/clockwork-test/pull/10)
14
+
15
+ *Adam Prescott*
16
+
17
+ * Add Appraisal to test various versions of clockwork [#13](https://github.com/kevin-j-m/clockwork-test/pull/13)
18
+
19
+ *Kevin Murphy*
20
+
21
+ * Update run loop to support clockwork versions >= 2.01 [#13](https://github.com/kevin-j-m/clockwork-test/pull/13)
22
+
23
+ *Kevin Murphy*
24
+
3
25
  ## 0.1.1
4
26
 
5
27
  * Pass clock file configuration to Clockwork::Test::Manager [#7](https://github.com/kevin-j-m/clockwork-test/pull/7)
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in clockwork-test.gemspec
4
4
  gemspec
5
+
6
+ gem 'appraisal'
data/README.md CHANGED
@@ -6,7 +6,9 @@
6
6
 
7
7
  `Clockwork::Test` includes additional functionality that makes testing of your `clock.rb` file easy. This gem can help make sure that you have scheduled your events appropriately, including testing `if:` or `at:` conditions, as well as allowing you to run assertions against the code that is executed when a job is run.
8
8
 
9
- `Clockwork::Test` has been verified against the latest release of clockwork at the time of its development, which is version 1.2.0. It does not require any specific test framework to be used with it, though all examples will use `rspec`.
9
+ `Clockwork::Test` runs its test suite against various versions of clockwork, which are documented in the [Appraisals](Appraisals) file. The ruby versions its tested against are documented in the [Travis configuration](.travis.yml).
10
+
11
+ `Clockwork::Test` does not require any specific test framework to be used with it, though all examples will use `rspec`.
10
12
 
11
13
  ## Installation
12
14
 
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
1
4
  require "bundler/gem_tasks"
2
5
  require "rspec/core/rake_task"
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
5
8
 
6
9
  task :default => :spec
7
-
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "clockwork", "1.3.1"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ clockwork-test (0.1.1)
5
+ clockwork
6
+ timecop
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ appraisal (2.1.0)
17
+ bundler
18
+ rake
19
+ thor (>= 0.14.0)
20
+ clockwork (1.3.1)
21
+ activesupport
22
+ tzinfo
23
+ coderay (1.1.1)
24
+ concurrent-ruby (1.0.5)
25
+ diff-lcs (1.3)
26
+ i18n (0.8.1)
27
+ method_source (0.8.2)
28
+ minitest (5.10.1)
29
+ pry (0.10.4)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.8.1)
32
+ slop (~> 3.4)
33
+ rake (10.5.0)
34
+ rspec (3.5.0)
35
+ rspec-core (~> 3.5.0)
36
+ rspec-expectations (~> 3.5.0)
37
+ rspec-mocks (~> 3.5.0)
38
+ rspec-core (3.5.4)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-expectations (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-its (1.2.0)
44
+ rspec-core (>= 3.0.0)
45
+ rspec-expectations (>= 3.0.0)
46
+ rspec-mocks (3.5.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.5.0)
49
+ rspec-support (3.5.0)
50
+ slop (3.6.0)
51
+ thor (0.19.4)
52
+ thread_safe (0.3.6)
53
+ timecop (0.8.1)
54
+ tzinfo (1.2.3)
55
+ thread_safe (~> 0.1)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ appraisal
62
+ bundler (~> 1.7)
63
+ clockwork (= 1.3.1)
64
+ clockwork-test!
65
+ pry
66
+ rake (~> 10.0)
67
+ rspec
68
+ rspec-its
69
+
70
+ BUNDLED WITH
71
+ 1.14.6
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "clockwork", "2.0.0"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ clockwork-test (0.1.1)
5
+ clockwork
6
+ timecop
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ appraisal (2.1.0)
17
+ bundler
18
+ rake
19
+ thor (>= 0.14.0)
20
+ clockwork (2.0.0)
21
+ activesupport
22
+ tzinfo
23
+ coderay (1.1.1)
24
+ concurrent-ruby (1.0.5)
25
+ diff-lcs (1.3)
26
+ i18n (0.8.1)
27
+ method_source (0.8.2)
28
+ minitest (5.10.1)
29
+ pry (0.10.4)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.8.1)
32
+ slop (~> 3.4)
33
+ rake (10.5.0)
34
+ rspec (3.5.0)
35
+ rspec-core (~> 3.5.0)
36
+ rspec-expectations (~> 3.5.0)
37
+ rspec-mocks (~> 3.5.0)
38
+ rspec-core (3.5.4)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-expectations (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-its (1.2.0)
44
+ rspec-core (>= 3.0.0)
45
+ rspec-expectations (>= 3.0.0)
46
+ rspec-mocks (3.5.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.5.0)
49
+ rspec-support (3.5.0)
50
+ slop (3.6.0)
51
+ thor (0.19.4)
52
+ thread_safe (0.3.6)
53
+ timecop (0.8.1)
54
+ tzinfo (1.2.3)
55
+ thread_safe (~> 0.1)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ appraisal
62
+ bundler (~> 1.7)
63
+ clockwork (= 2.0.0)
64
+ clockwork-test!
65
+ pry
66
+ rake (~> 10.0)
67
+ rspec
68
+ rspec-its
69
+
70
+ BUNDLED WITH
71
+ 1.14.6
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "clockwork", "2.0.1"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ clockwork-test (0.1.1)
5
+ clockwork
6
+ timecop
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ appraisal (2.1.0)
17
+ bundler
18
+ rake
19
+ thor (>= 0.14.0)
20
+ clockwork (2.0.1)
21
+ activesupport
22
+ tzinfo
23
+ coderay (1.1.1)
24
+ concurrent-ruby (1.0.5)
25
+ diff-lcs (1.3)
26
+ i18n (0.8.1)
27
+ method_source (0.8.2)
28
+ minitest (5.10.1)
29
+ pry (0.10.4)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.8.1)
32
+ slop (~> 3.4)
33
+ rake (10.5.0)
34
+ rspec (3.5.0)
35
+ rspec-core (~> 3.5.0)
36
+ rspec-expectations (~> 3.5.0)
37
+ rspec-mocks (~> 3.5.0)
38
+ rspec-core (3.5.4)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-expectations (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-its (1.2.0)
44
+ rspec-core (>= 3.0.0)
45
+ rspec-expectations (>= 3.0.0)
46
+ rspec-mocks (3.5.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.5.0)
49
+ rspec-support (3.5.0)
50
+ slop (3.6.0)
51
+ thor (0.19.4)
52
+ thread_safe (0.3.6)
53
+ timecop (0.8.1)
54
+ tzinfo (1.2.3)
55
+ thread_safe (~> 0.1)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ appraisal
62
+ bundler (~> 1.7)
63
+ clockwork (= 2.0.1)
64
+ clockwork-test!
65
+ pry
66
+ rake (~> 10.0)
67
+ rspec
68
+ rspec-its
69
+
70
+ BUNDLED WITH
71
+ 1.14.6
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "clockwork", "2.0.2"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ clockwork-test (0.1.1)
5
+ clockwork
6
+ timecop
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ appraisal (2.1.0)
17
+ bundler
18
+ rake
19
+ thor (>= 0.14.0)
20
+ clockwork (2.0.2)
21
+ activesupport
22
+ tzinfo
23
+ coderay (1.1.1)
24
+ concurrent-ruby (1.0.5)
25
+ diff-lcs (1.3)
26
+ i18n (0.8.1)
27
+ method_source (0.8.2)
28
+ minitest (5.10.1)
29
+ pry (0.10.4)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.8.1)
32
+ slop (~> 3.4)
33
+ rake (10.5.0)
34
+ rspec (3.5.0)
35
+ rspec-core (~> 3.5.0)
36
+ rspec-expectations (~> 3.5.0)
37
+ rspec-mocks (~> 3.5.0)
38
+ rspec-core (3.5.4)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-expectations (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-its (1.2.0)
44
+ rspec-core (>= 3.0.0)
45
+ rspec-expectations (>= 3.0.0)
46
+ rspec-mocks (3.5.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.5.0)
49
+ rspec-support (3.5.0)
50
+ slop (3.6.0)
51
+ thor (0.19.4)
52
+ thread_safe (0.3.6)
53
+ timecop (0.8.1)
54
+ tzinfo (1.2.3)
55
+ thread_safe (~> 0.1)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ appraisal
62
+ bundler (~> 1.7)
63
+ clockwork (= 2.0.2)
64
+ clockwork-test!
65
+ pry
66
+ rake (~> 10.0)
67
+ rspec
68
+ rspec-its
69
+
70
+ BUNDLED WITH
71
+ 1.14.6
@@ -25,7 +25,7 @@ module Clockwork
25
25
  Timecop.travel(@start_time)
26
26
  end
27
27
 
28
- super()
28
+ tick_loop
29
29
 
30
30
  Timecop.return if @time_altered
31
31
  end
@@ -46,23 +46,20 @@ module Clockwork
46
46
 
47
47
  attr_reader :history
48
48
 
49
- def loop(&block)
50
- while 1 == 1 do
49
+ def tick_loop
50
+ while true do
51
51
  update_job_history
52
52
 
53
- block.call
53
+ tick
54
+ increase_time
54
55
 
55
56
  @total_ticks += 1
56
57
  break if ticks_exceeded? || time_exceeded?
57
58
  end
58
59
  end
59
60
 
60
- def sleep(interval)
61
- if @tick_speed
62
- Timecop.travel(Time.now + @tick_speed)
63
- else
64
- super
65
- end
61
+ def increase_time
62
+ Timecop.travel(Time.now + @tick_speed) if @tick_speed
66
63
  end
67
64
 
68
65
  def register(period, job, block, options)
@@ -18,26 +18,15 @@ module Clockwork
18
18
  end
19
19
 
20
20
  def once
21
- @times_run = 1
22
- @exactly = true
23
-
24
- self
21
+ time(1)
25
22
  end
26
23
 
27
24
  def exactly(times)
28
- @times_run = times
29
- @exactly = true
30
-
31
- self
25
+ time(times)
32
26
  end
33
27
 
34
28
  def times(times = nil)
35
- if times
36
- @times_run = times
37
- @exactly = true
38
- end
39
-
40
- self
29
+ time(times)
41
30
  end
42
31
 
43
32
  def time(times = nil)
@@ -1,5 +1,5 @@
1
1
  module Clockwork
2
2
  module Test
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -52,9 +52,7 @@ describe "Clockwork" do
52
52
  subject(:clockwork) { Clockwork::Test }
53
53
 
54
54
  before(:each) do
55
- Time.zone = time_zone
56
-
57
- Clockwork::Test.run(clock_opts)
55
+ Time.use_zone(time_zone) { Clockwork::Test.run(clock_opts) }
58
56
  end
59
57
 
60
58
  after(:each) { Clockwork::Test.clear! }
@@ -51,7 +51,7 @@ describe Clockwork::Test::Manager do
51
51
 
52
52
  it "stops running after reaching the end time" do
53
53
  manager.run
54
- expect(Time.current).to be_within(1.second).of(end_time)
54
+ expect(Time.current).to be_within(2.seconds).of(end_time)
55
55
  expect(manager.total_ticks).to be > 0
56
56
  end
57
57
 
@@ -60,7 +60,7 @@ describe Clockwork::Test::Manager do
60
60
 
61
61
  it "stops running after reaching the end time specified in the call" do
62
62
  manager.run(end_time: method_end_time)
63
- expect(Time.current).to be_within(1.second).of(method_end_time)
63
+ expect(Time.current).to be_within(2.seconds).of(method_end_time)
64
64
  expect(manager.total_ticks).to be > 0
65
65
  end
66
66
  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.1
4
+ version: 0.2.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: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,12 +118,21 @@ files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
+ - Appraisals
121
122
  - CHANGELOG.md
122
123
  - Gemfile
123
124
  - LICENSE.txt
124
125
  - README.md
125
126
  - Rakefile
126
127
  - clockwork-test.gemspec
128
+ - gemfiles/clockwork_1_3_1.gemfile
129
+ - gemfiles/clockwork_1_3_1.gemfile.lock
130
+ - gemfiles/clockwork_2_0_0.gemfile
131
+ - gemfiles/clockwork_2_0_0.gemfile.lock
132
+ - gemfiles/clockwork_2_0_1.gemfile
133
+ - gemfiles/clockwork_2_0_1.gemfile.lock
134
+ - gemfiles/clockwork_2_0_2.gemfile
135
+ - gemfiles/clockwork_2_0_2.gemfile.lock
127
136
  - lib/clockwork/test.rb
128
137
  - lib/clockwork/test/event.rb
129
138
  - lib/clockwork/test/job_history.rb
@@ -157,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
166
  version: '0'
158
167
  requirements: []
159
168
  rubyforge_project:
160
- rubygems_version: 2.2.2
169
+ rubygems_version: 2.6.11
161
170
  signing_key:
162
171
  specification_version: 4
163
172
  summary: Test clockwork scheduled jobs