Skip to content

Commit cb471f1

Browse files
committed
make the tests pass with Ruby 2.4.2
1 parent dce6803 commit cb471f1

8 files changed

Lines changed: 81 additions & 80 deletions

Rakefile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require 'rubygems'
2-
require 'rake'
1+
# require 'rubygems'
2+
# require 'rake'
33
require 'rake/testtask'
4-
require 'rake/rdoctask'
4+
# require 'rake/rdoctask'
55

66
desc 'Default: run all tests.'
77
task :default => :test
@@ -13,24 +13,24 @@ Rake::TestTask.new(:test) do |t|
1313
t.verbose = true
1414
end
1515

16-
begin
17-
require 'rcov/rcovtask'
18-
namespace :test do
19-
desc "Test encrypted_strings with Rcov."
20-
Rcov::RcovTask.new(:rcov) do |t|
21-
t.libs << 'lib'
22-
t.test_files = Dir['test/**/*_test.rb']
23-
t.rcov_opts << '--exclude="^(?!lib/)"'
24-
t.verbose = true
25-
end
26-
end
27-
rescue LoadError
28-
end
16+
# begin
17+
# require 'rcov/rcovtask'
18+
# namespace :test do
19+
# desc "Test encrypted_strings with Rcov."
20+
# Rcov::RcovTask.new(:rcov) do |t|
21+
# t.libs << 'lib'
22+
# t.test_files = Dir['test/**/*_test.rb']
23+
# t.rcov_opts << '--exclude="^(?!lib/)"'
24+
# t.verbose = true
25+
# end
26+
# end
27+
# rescue LoadError
28+
# end
2929

30-
desc "Generate documentation for encrypted_strings."
31-
Rake::RDocTask.new(:rdoc) do |rdoc|
32-
rdoc.rdoc_dir = 'rdoc'
33-
rdoc.title = 'encrypted_strings'
34-
rdoc.options << '--line-numbers' << '--inline-source' << '--main=README.rdoc'
35-
rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
36-
end
30+
# desc "Generate documentation for encrypted_strings."
31+
# Rake::RDocTask.new(:rdoc) do |rdoc|
32+
# rdoc.rdoc_dir = 'rdoc'
33+
# rdoc.title = 'encrypted_strings'
34+
# rdoc.options << '--line-numbers' << '--inline-source' << '--main=README.rdoc'
35+
# rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
36+
# end

encrypted_strings.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ Gem::Specification.new do |s|
1515
s.rdoc_options = %w(--line-numbers --inline-source --title encrypted_strings --main README.rdoc)
1616
s.extra_rdoc_files = %w(README.rdoc CHANGELOG.rdoc LICENSE)
1717

18+
s.add_development_dependency("minitest")
1819
s.add_development_dependency("rake")
1920
end

test/asymmetric_cipher_test.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
require File.dirname(__FILE__) + '/test_helper'
22

3-
class NoPrivateKeyErrorTest < Test::Unit::TestCase
3+
class NoPrivateKeyErrorTest < Minitest::Test
44
def test_should_exist
5-
assert_not_nil EncryptedStrings::NoPrivateKeyError
5+
refute_nil EncryptedStrings::NoPrivateKeyError
66
end
77
end
88

9-
class NoPublicKeyErrorTest < Test::Unit::TestCase
9+
class NoPublicKeyErrorTest < Minitest::Test
1010
def test_should_exist
11-
assert_not_nil EncryptedStrings::NoPublicKeyError
11+
refute_nil EncryptedStrings::NoPublicKeyError
1212
end
1313
end
1414

15-
class AsymmetricCipherByDefaultTest < Test::Unit::TestCase
15+
class AsymmetricCipherByDefaultTest < Minitest::Test
1616
def setup
1717
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:public_key_file => File.dirname(__FILE__) + '/keys/public')
1818
end
1919

2020
def test_should_raise_an_exception
21-
assert_raise(ArgumentError) {EncryptedStrings::AsymmetricCipher.new}
21+
assert_raises(ArgumentError) {EncryptedStrings::AsymmetricCipher.new}
2222
end
2323

2424
def test_should_not_have_a_public_key_file
@@ -39,7 +39,7 @@ def test_should_not_have_a_password
3939
end
4040
end
4141

42-
class AsymmetricCipherWithCustomDefaultsTest < Test::Unit::TestCase
42+
class AsymmetricCipherWithCustomDefaultsTest < Minitest::Test
4343
def setup
4444
@original_default_public_key_file = EncryptedStrings::AsymmetricCipher.default_public_key_file
4545
@original_default_private_key_file = EncryptedStrings::AsymmetricCipher.default_private_key_file
@@ -72,13 +72,13 @@ def teardown
7272
end
7373
end
7474

75-
class AsymmetricCipherWithInvalidOptionsTest < Test::Unit::TestCase
75+
class AsymmetricCipherWithInvalidOptionsTest < Minitest::Test
7676
def test_should_throw_an_exception
77-
assert_raise(ArgumentError) {EncryptedStrings::AsymmetricCipher.new(:invalid => true)}
77+
assert_raises(ArgumentError) {EncryptedStrings::AsymmetricCipher.new(:invalid => true)}
7878
end
7979
end
8080

81-
class AsymmetricCipherTest < Test::Unit::TestCase
81+
class AsymmetricCipherTest < Minitest::Test
8282
def setup
8383
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:public_key_file => File.dirname(__FILE__) + '/keys/public')
8484
end
@@ -88,7 +88,7 @@ def test_should_be_able_to_decrypt
8888
end
8989
end
9090

91-
class AsymmetricCipherWithoutPublicKeyTest < Test::Unit::TestCase
91+
class AsymmetricCipherWithoutPublicKeyTest < Minitest::Test
9292
def setup
9393
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:public_key_file => nil, :private_key_file => File.dirname(__FILE__) + '/keys/private')
9494
end
@@ -98,11 +98,11 @@ def test_should_not_be_public
9898
end
9999

100100
def test_should_not_be_able_to_encrypt
101-
assert_raise(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
101+
assert_raises(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
102102
end
103103
end
104104

105-
class AsymmetricCipherWithPublicKeyTest < Test::Unit::TestCase
105+
class AsymmetricCipherWithPublicKeyTest < Minitest::Test
106106
def setup
107107
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:public_key_file => File.dirname(__FILE__) + '/keys/public')
108108
end
@@ -120,11 +120,11 @@ def test_should_be_able_to_encrypt
120120
end
121121

122122
def test_should_not_be_able_to_decrypt
123-
assert_raise(EncryptedStrings::NoPrivateKeyError) {@asymmetric_cipher.decrypt("HbEh0Hwri26S7SWYqO26DBbzfhR1h/0pXYLjSKUpxF5DOaOCtD9oRN748+Na\nrfNaVN5Eg7RUhbRFZE+UnNHo6Q==\n")}
123+
assert_raises(EncryptedStrings::NoPrivateKeyError) {@asymmetric_cipher.decrypt("HbEh0Hwri26S7SWYqO26DBbzfhR1h/0pXYLjSKUpxF5DOaOCtD9oRN748+Na\nrfNaVN5Eg7RUhbRFZE+UnNHo6Q==\n")}
124124
end
125125
end
126126

127-
class AsymmetricCipherWithoutPrivateKeyTest < Test::Unit::TestCase
127+
class AsymmetricCipherWithoutPrivateKeyTest < Minitest::Test
128128
def setup
129129
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:private_key_file => nil, :public_key_file => File.dirname(__FILE__) + '/keys/public')
130130
end
@@ -134,11 +134,11 @@ def test_should_not_be_private
134134
end
135135

136136
def test_should_not_be_able_to_decrypt
137-
assert_raise(EncryptedStrings::NoPrivateKeyError) {@asymmetric_cipher.decrypt("HbEh0Hwri26S7SWYqO26DBbzfhR1h/0pXYLjSKUpxF5DOaOCtD9oRN748+Na\nrfNaVN5Eg7RUhbRFZE+UnNHo6Q==\n")}
137+
assert_raises(EncryptedStrings::NoPrivateKeyError) {@asymmetric_cipher.decrypt("HbEh0Hwri26S7SWYqO26DBbzfhR1h/0pXYLjSKUpxF5DOaOCtD9oRN748+Na\nrfNaVN5Eg7RUhbRFZE+UnNHo6Q==\n")}
138138
end
139139
end
140140

141-
class AsymmetricCipherWithPrivateKeyTest < Test::Unit::TestCase
141+
class AsymmetricCipherWithPrivateKeyTest < Minitest::Test
142142
def setup
143143
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:private_key_file => File.dirname(__FILE__) + '/keys/private')
144144
end
@@ -152,15 +152,15 @@ def test_should_be_private
152152
end
153153

154154
def test_not_should_be_able_to_encrypt
155-
assert_raise(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
155+
assert_raises(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
156156
end
157157

158158
def test_should_be_able_to_decrypt
159159
assert_equal 'test', @asymmetric_cipher.decrypt("HbEh0Hwri26S7SWYqO26DBbzfhR1h/0pXYLjSKUpxF5DOaOCtD9oRN748+Na\nrfNaVN5Eg7RUhbRFZE+UnNHo6Q==\n")
160160
end
161161
end
162162

163-
class AsymmetricCipherWithEncryptedPrivateKeyTest < Test::Unit::TestCase
163+
class AsymmetricCipherWithEncryptedPrivateKeyTest < Minitest::Test
164164
def setup
165165
@asymmetric_cipher = EncryptedStrings::AsymmetricCipher.new(:private_key_file => File.dirname(__FILE__) + '/keys/encrypted_private', :algorithm => 'DES-EDE3-CBC', :password => 'secret')
166166
end
@@ -174,7 +174,7 @@ def test_should_be_private
174174
end
175175

176176
def test_should_not_be_able_to_encrypt
177-
assert_raise(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
177+
assert_raises(EncryptedStrings::NoPublicKeyError) {@asymmetric_cipher.encrypt('test')}
178178
end
179179

180180
def test_should_be_able_to_decrypt

test/cipher_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.dirname(__FILE__) + '/test_helper'
22

3-
class CipherByDefaultTest < Test::Unit::TestCase
3+
class CipherByDefaultTest < Minitest::Test
44
def setup
55
@cipher = EncryptedStrings::Cipher.new
66
end

test/sha_cipher_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.dirname(__FILE__) + '/test_helper'
22

3-
class ShaCipherByDefaulTest < Test::Unit::TestCase
3+
class ShaCipherByDefaulTest < Minitest::Test
44
def setup
55
@sha_cipher = EncryptedStrings::ShaCipher.new
66
end
@@ -14,7 +14,7 @@ def test_should_encrypt_using_default_salt
1414
end
1515
end
1616

17-
class ShaCipherWithCustomDefaultsTest < Test::Unit::TestCase
17+
class ShaCipherWithCustomDefaultsTest < Minitest::Test
1818
def setup
1919
@original_default_algorithm = EncryptedStrings::ShaCipher.default_algorithm
2020
@original_default_salt = EncryptedStrings::ShaCipher.default_salt
@@ -42,13 +42,13 @@ def teardown
4242
end
4343
end
4444

45-
class ShaCipherWithInvalidOptionsTest < Test::Unit::TestCase
45+
class ShaCipherWithInvalidOptionsTest < Minitest::Test
4646
def test_should_throw_an_exception
47-
assert_raise(ArgumentError) {EncryptedStrings::ShaCipher.new(:invalid => true)}
47+
assert_raises(ArgumentError) {EncryptedStrings::ShaCipher.new(:invalid => true)}
4848
end
4949
end
5050

51-
class ShaCipherTest < Test::Unit::TestCase
51+
class ShaCipherTest < Minitest::Test
5252
def setup
5353
@sha_cipher = EncryptedStrings::ShaCipher.new
5454
end
@@ -62,7 +62,7 @@ def test_should_raise_exception_if_trying_to_decrypt
6262
end
6363
end
6464

65-
class ShaCipherWithCustomOptionsTest < Test::Unit::TestCase
65+
class ShaCipherWithCustomOptionsTest < Minitest::Test
6666
def setup
6767
@sha_cipher = EncryptedStrings::ShaCipher.new(:algorithm => 'sha512', :salt => 'different salt')
6868
end
@@ -80,7 +80,7 @@ def test_should_encrypt_using_custom_salt
8080
end
8181
end
8282

83-
class ShaCipherWithNonStringSaltTest < Test::Unit::TestCase
83+
class ShaCipherWithNonStringSaltTest < Minitest::Test
8484
require 'time'
8585

8686
def setup
@@ -93,7 +93,7 @@ def test_should_stringify_salt
9393
end
9494
end
9595

96-
class ShaCipherWithProcSaltTest < Test::Unit::TestCase
96+
class ShaCipherWithProcSaltTest < Minitest::Test
9797
def setup
9898
@sha_cipher = EncryptedStrings::ShaCipher.new(:salt => lambda {|*args| @args = args; 'val'})
9999
end
@@ -107,7 +107,7 @@ def test_should_use_return_value_from_proc
107107
end
108108
end
109109

110-
class ShaCipherWithObjectSaltTest < Test::Unit::TestCase
110+
class ShaCipherWithObjectSaltTest < Minitest::Test
111111
def setup
112112
@object = Object.new
113113
class << @object
@@ -124,7 +124,7 @@ def test_should_use_salt_method
124124
end
125125
end
126126

127-
class ShaCipherWithProcBuilderTest < Test::Unit::TestCase
127+
class ShaCipherWithProcBuilderTest < Minitest::Test
128128
def setup
129129
@sha_cipher = EncryptedStrings::ShaCipher.new(:builder => lambda {|data, salt| "#{data}|#{salt}"})
130130
end
@@ -134,7 +134,7 @@ def test_should_encrypt_based_on_custom_builder
134134
end
135135
end
136136

137-
class ShaCipherWithObjectBuilderTest < Test::Unit::TestCase
137+
class ShaCipherWithObjectBuilderTest < Minitest::Test
138138
def setup
139139
@object = Object.new
140140
class << @object

0 commit comments

Comments
 (0)