attempt 0.5.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d3a19c0af424d2b75bea45b426104ce8975948ad978e71b8fb27aaad902feeb
4
- data.tar.gz: bf8d228e1f539cd01877013452dab333f2af8fc315c70cac1a016abcd7960875
3
+ metadata.gz: 50246b73fb46376da7117edb646bcf0e729f02ae64bf1282d4f352af4c738b47
4
+ data.tar.gz: 37037458bafef3d5bc310f4fb4d856af3bd4058cbdeaeaee9af6fde67bf62b5b
5
5
  SHA512:
6
- metadata.gz: 065e16dfce9c78d505a81b220e77d5ac0d5855606a4b10b90f2a8fd3dd1d12f7bd83a42268d9e2e2b43db8adaad7506a05cf7ddaba97117ba215c736c6eea3bf
7
- data.tar.gz: 29180b07080e2ee8201ef1ac29b9f266b290ee37ac06ccaa27e79c196548afcc8f8daaf3f9535d8eaeb4cc519bdff9572afa0fbee406ce8e09c37eb864cc962a
6
+ metadata.gz: b592f0a5df1a9d9a01ce5ec50661fdf4541bab52de11a1c8dff501f55035f072ad9b88c0f53ba7546d509cb4042027cf12a7ad4972b85c124e3f940d8b283b84
7
+ data.tar.gz: 0ca007e3d8bdb894e5d2991685dfc00cb3fcf5eb8f4e29205b06d0c862827495ba991d767ff49ea1656c3372d9e0186973a26b7733a8b19ccf7f52085182742d
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.6.0 - 17-Sep-2020
2
+ * Switched from test-unit to rspec and rewrote the specs.
3
+
4
+ == 0.5.1 - 28-Aug-2020
5
+ * Added a Gemfile.
6
+ * Updated Rakefile to clean .lock files.
7
+ * Bumped structured_warnings version to 0.4.0 so that it works with Ruby 2.7.
8
+ Thanks go to Alexey Zapriy for the spot.
9
+
1
10
  == 0.5.0 - 2-Jun-2020
2
11
  * Switched to Apache-2.0 license, added LICENSE file.
3
12
  * Updated cert again.
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source 'https://rubygems.org' do
3
3
  gem 'structured_warnings', '~> 0.4.0'
4
4
  gem 'safe_timeout', '~> 0.0.5'
5
5
  group 'test' do
6
- gem 'test-unit', '~> 3.0'
6
+ gem 'rspec', '~> 3.9'
7
7
  end
8
8
  end
data/MANIFEST CHANGED
@@ -7,4 +7,4 @@
7
7
  * attempt.gemspec
8
8
  * certs/djberg96_pub.pem
9
9
  * lib/attempt.rb
10
- * test/test_attempt.rb
10
+ * spec/attempt_spec.rb
data/README CHANGED
@@ -62,7 +62,7 @@
62
62
  warranties of merchantability and fitness for a particular purpose.
63
63
 
64
64
  == License
65
- Artistic 2.0
65
+ Apache-2.0
66
66
 
67
67
  == Copyright
68
68
  (C) 2006-2020, Daniel J. Berger
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
 
5
5
  CLEAN.include('**/*.gem', '**/*.rbc', '**/*.lock')
6
6
 
@@ -10,7 +10,7 @@ namespace :gem do
10
10
  require 'rubygems/package'
11
11
  spec = eval(IO.read('attempt.gemspec'))
12
12
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
- Gem::Package.build(spec, true)
13
+ Gem::Package.build(spec)
14
14
  end
15
15
 
16
16
  desc "Install the attempt gem"
@@ -20,10 +20,7 @@ namespace :gem do
20
20
  end
21
21
  end
22
22
 
23
- Rake::TestTask.new do |t|
24
- task :test => :clean
25
- t.warning = true
26
- t.verbose = true
27
- end
23
+ desc "Run the test suite"
24
+ RSpec::Core::RakeTask.new(:spec)
28
25
 
29
- task :default => :test
26
+ task :default => :spec
@@ -2,13 +2,13 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'attempt'
5
- spec.version = '0.5.1'
5
+ spec.version = '0.6.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/attempt'
10
10
  spec.summary = 'A thin wrapper for begin + rescue + sleep + retry'
11
- spec.test_file = 'test/test_attempt.rb'
11
+ spec.test_file = 'spec/attempt_spec.rb'
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = Dir['certs/*']
14
14
 
@@ -23,8 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency('structured_warnings', '~> 0.4.0')
25
25
  spec.add_dependency('safe_timeout', '~> 0.0.5')
26
-
27
- spec.add_development_dependency('test-unit')
26
+ spec.add_dependency('rspec', '~> 3.9')
28
27
 
29
28
  spec.description = <<-EOF
30
29
  The attempt library provides a thin wrapper for the typical
@@ -6,7 +6,7 @@ require 'structured_warnings'
6
6
  class Attempt
7
7
 
8
8
  # The version of the attempt library.
9
- VERSION = '0.5.1'.freeze
9
+ VERSION = '0.6.0'.freeze
10
10
 
11
11
  # Warning raised if an attempt fails before the maximum number of tries
12
12
  # has been reached.
@@ -0,0 +1,67 @@
1
+ #####################################################################
2
+ # attempt_spec.rb
3
+ #
4
+ # Tests for the attempt library. You should run this test case via
5
+ # the 'rake test' Rakefile task (or just 'rake').
6
+ #
7
+ # TODO: Test that an Attempt::Warning is raised.
8
+ #####################################################################
9
+ require 'rspec'
10
+ require 'attempt'
11
+ require 'stringio'
12
+
13
+ RSpec.describe Attempt do
14
+ before(:all) do
15
+ $stderr = StringIO.new
16
+ end
17
+
18
+ before do
19
+ @tries = 2
20
+ @interval = 0.1
21
+ @timeout = 0.1
22
+ $value = 0
23
+ end
24
+
25
+ example "version constant is set to expected value" do
26
+ expect(Attempt::VERSION).to eq('0.6.0')
27
+ expect(Attempt::VERSION).to be_frozen
28
+ end
29
+
30
+ example "attempt works as expected without arguments" do
31
+ expect{ attempt{ 2 + 2 } }.not_to raise_error
32
+ end
33
+
34
+ example "attempt retries the number of times specified" do
35
+ expect{ attempt(tries: @tries){ $value += 1; raise if $value < 2 } }.not_to raise_error
36
+ expect($value).to eq(2)
37
+ end
38
+
39
+ example "attempt retries the number of times specified with interval" do
40
+ expect{
41
+ attempt(tries: @tries, interval: @interval){ $value += 1; raise if $value < 2 }
42
+ }.not_to raise_error
43
+ expect($value).to eq(2)
44
+ end
45
+
46
+ example "attempt retries the number of times specified with interval and timeout" do
47
+ expect{
48
+ attempt(tries: @tries, interval: @interval, timeout: @timeout){ $value += 1; raise if $value < 2 }
49
+ }.not_to raise_error
50
+ end
51
+
52
+ example "attempt raises a timeout error if timeout value is exceeded" do
53
+ expect{ attempt(tries: 1, interval: 1, timeout: @timeout){ sleep 5 } }.to raise_error(Timeout::Error)
54
+ end
55
+
56
+ example "attempt raises exception as expected" do
57
+ expect{ attempt(tries: 2, interval: 2){ raise } }.to raise_error(RuntimeError)
58
+ end
59
+
60
+ after do
61
+ $after = 0
62
+ end
63
+
64
+ after(:all) do
65
+ $stderr = STDERR
66
+ end
67
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attempt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date:
38
+ date: 2020-09-17 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: structured_warnings
@@ -66,19 +66,19 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: 0.0.5
68
68
  - !ruby/object:Gem::Dependency
69
- name: test-unit
69
+ name: rspec
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
75
- type: :development
74
+ version: '3.9'
75
+ type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: '3.9'
82
82
  description: |2
83
83
  The attempt library provides a thin wrapper for the typical
84
84
  begin/rescue/sleep/retry dance. Use this in order to robustly
@@ -93,19 +93,16 @@ extra_rdoc_files:
93
93
  - CHANGES
94
94
  - MANIFEST
95
95
  files:
96
- - LICENSE
97
- - test
98
- - test/test_attempt.rb
99
96
  - CHANGES
97
+ - Gemfile
98
+ - LICENSE
100
99
  - MANIFEST
101
100
  - README
102
101
  - Rakefile
103
- - certs
102
+ - attempt.gemspec
104
103
  - certs/djberg96_pub.pem
105
- - lib
106
104
  - lib/attempt.rb
107
- - Gemfile
108
- - attempt.gemspec
105
+ - spec/attempt_spec.rb
109
106
  homepage: https://github.com/djberg96/attempt
110
107
  licenses:
111
108
  - Apache-2.0
@@ -134,4 +131,4 @@ signing_key:
134
131
  specification_version: 4
135
132
  summary: A thin wrapper for begin + rescue + sleep + retry
136
133
  test_files:
137
- - test/test_attempt.rb
134
+ - spec/attempt_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,69 +0,0 @@
1
- #####################################################################
2
- # test_attempt.rb
3
- #
4
- # Test case for the attempt library. You should run this test case
5
- # via the 'rake test' Rakefile task.
6
- #
7
- # TODO: Test that an Attempt::Warning is raised.
8
- #####################################################################
9
- require 'test-unit'
10
- require 'attempt'
11
- require 'stringio'
12
-
13
- class TC_Attempt < Test::Unit::TestCase
14
- def self.startup
15
- $stderr = StringIO.new
16
- end
17
-
18
- def setup
19
- @tries = 2
20
- @interval = 0.1
21
- @timeout = 0.1
22
- $value = 0
23
- end
24
-
25
- test "version constant is set to expected value" do
26
- assert_equal('0.5.1', Attempt::VERSION)
27
- assert_true(Attempt::VERSION.frozen?)
28
- end
29
-
30
- test "attempt works as expected without arguments" do
31
- assert_nothing_raised{ attempt{ 2 + 2 } }
32
- end
33
-
34
- test "attempt retries the number of times specified" do
35
- assert_nothing_raised{ attempt(tries: @tries){ $value += 1; raise if $value < 2 } }
36
- assert_equal(2, $value)
37
- end
38
-
39
- test "attempt retries the number of times specified with interval" do
40
- assert_nothing_raised{
41
- attempt(tries: @tries, interval: @interval){ $value += 1; raise if $value < 2 }
42
- }
43
- end
44
-
45
- test "attempt retries the number of times specified with interval and timeout" do
46
- assert_nothing_raised{
47
- attempt(tries: @tries, interval: @interval, timeout: @timeout){ $value += 1; raise if $value < 2 }
48
- }
49
- end
50
-
51
- test "attempt raises a timeout error if timeout value is exceeded" do
52
- assert_raises(Timeout::Error){ attempt(tries: 1, interval: 1, timeout: @timeout){ sleep 5 } }
53
- end
54
-
55
- test "attempt raises exception as expected" do
56
- assert_raises(RuntimeError){ attempt(tries: 2, interval: 2){ raise } }
57
- end
58
-
59
- def teardown
60
- @tries = nil
61
- @interval = nil
62
- @timeout = nil
63
- $value = 0
64
- end
65
-
66
- def self.shutdown
67
- $stderr = STDERR
68
- end
69
- end