gravaty 10.0.0 → 11.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +7 -0
  3. data/Gemfile +5 -1
  4. data/README.md +219 -212
  5. data/Rakefile +9 -3
  6. data/copyright.md +33 -136
  7. data/examples/avatar.rb +70 -43
  8. data/examples/basics.rb +30 -20
  9. data/examples/profile.rb +77 -50
  10. data/examples/xmlrpc.rb +24 -10
  11. data/gravaty.gemspec +46 -25
  12. data/html/CHANGELOG.html +13 -20
  13. data/html/COPYING_md.html +8 -24
  14. data/html/Gemfile.html +7 -21
  15. data/html/Gravaty.html +49 -113
  16. data/html/Gravaty/Gravaty.html +138 -343
  17. data/html/Gravaty/ParsableDuckType.html +14 -33
  18. data/html/Gravaty/Parser.html +27 -66
  19. data/html/Gravaty/Parsers.html +3 -11
  20. data/html/Gravaty/Parsers/Avatar.html +19 -36
  21. data/html/Gravaty/Parsers/Callback.html +21 -37
  22. data/html/Gravaty/Parsers/Default.html +28 -45
  23. data/html/Gravaty/Parsers/Force.html +21 -37
  24. data/html/Gravaty/Parsers/Format.html +22 -42
  25. data/html/Gravaty/Parsers/Pixelsize.html +22 -42
  26. data/html/Gravaty/Parsers/Rating.html +22 -42
  27. data/html/Gravaty/Parsers/Secure.html +19 -36
  28. data/html/Gravaty/Parsers/Type.html +22 -42
  29. data/html/Gravaty/Utils.html +11 -13
  30. data/html/Gravaty/Utils/Downloader.html +3 -11
  31. data/html/Gravaty/Utils/Downloader/Downloader.html +25 -59
  32. data/html/Gravaty/Utils/Raisers.html +24 -55
  33. data/html/Gravaty/Utils/Rfc5322.html +12 -19
  34. data/html/Gravaty/Utils/RpcConnector.html +11 -13
  35. data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +33 -73
  36. data/html/Object.html +728 -57
  37. data/html/README_md.html +105 -100
  38. data/html/Rakefile.html +9 -23
  39. data/html/copyright_md.html +17 -119
  40. data/html/created.rid +48 -55
  41. data/html/css/rdoc.css +1 -1
  42. data/html/index.html +97 -114
  43. data/html/js/navigation.js.gz +0 -0
  44. data/html/js/search_index.js +1 -1
  45. data/html/js/search_index.js.gz +0 -0
  46. data/html/js/searcher.js.gz +0 -0
  47. data/html/table_of_contents.html +219 -651
  48. data/lib/gravaty.rb +22 -15
  49. data/lib/gravaty/application.rb +40 -25
  50. data/lib/gravaty/constants.rb +20 -11
  51. data/lib/gravaty/locales/en.yml +9 -3
  52. data/lib/gravaty/locales/it.yml +9 -3
  53. data/lib/gravaty/locales/ja.yml +7 -4
  54. data/lib/gravaty/parser.rb +16 -10
  55. data/lib/gravaty/parsers/avatar.rb +11 -3
  56. data/lib/gravaty/parsers/callback.rb +13 -4
  57. data/lib/gravaty/parsers/default.rb +24 -16
  58. data/lib/gravaty/parsers/force.rb +12 -2
  59. data/lib/gravaty/parsers/format.rb +11 -2
  60. data/lib/gravaty/parsers/pixelsize.rb +12 -3
  61. data/lib/gravaty/parsers/rating.rb +12 -3
  62. data/lib/gravaty/parsers/secure.rb +11 -2
  63. data/lib/gravaty/parsers/type.rb +11 -2
  64. data/lib/gravaty/utils/downloader.rb +98 -96
  65. data/lib/gravaty/utils/raisers.rb +19 -12
  66. data/lib/gravaty/utils/rfc5322.rb +54 -41
  67. data/lib/gravaty/utils/rpc_connector.rb +19 -11
  68. data/lib/gravaty/version.rb +10 -2
  69. data/test/gravaty/locales/en.yml +29 -0
  70. data/test/gravaty/locales/it.yml +29 -0
  71. data/test/gravaty/locales/ja.yml +27 -0
  72. data/test/gravaty/locales/test_locales.rb +17 -13
  73. data/test/gravaty/parsers/test_avatar.rb +9 -1
  74. data/test/gravaty/parsers/test_callback.rb +12 -4
  75. data/test/gravaty/parsers/test_default.rb +25 -21
  76. data/test/gravaty/parsers/test_force.rb +9 -1
  77. data/test/gravaty/parsers/test_format.rb +18 -11
  78. data/test/gravaty/parsers/test_pixelsize.rb +19 -12
  79. data/test/gravaty/parsers/test_rating.rb +18 -11
  80. data/test/gravaty/parsers/test_secure.rb +9 -1
  81. data/test/gravaty/parsers/test_type.rb +14 -5
  82. data/test/gravaty/test_application.rb +14 -6
  83. data/test/gravaty/test_avatar.rb +94 -59
  84. data/test/gravaty/test_parser.rb +11 -5
  85. data/test/gravaty/test_profile.rb +47 -25
  86. data/test/gravaty/utils/test_downloader.rb +43 -28
  87. data/test/gravaty/utils/test_raisers.rb +42 -26
  88. data/test/gravaty/utils/test_rfc5322.rb +35 -13
  89. data/test/gravaty/utils/test_rpc_connector.rb +83 -39
  90. data/test/test_gravaty.rb +12 -4
  91. data/test/test_helper.rb +15 -9
  92. metadata +54 -40
  93. data/ISSUES.md +0 -62
  94. data/acknowledgements.md +0 -66
  95. data/authors.md +0 -63
  96. data/examples/cacert.pem +0 -3466
  97. data/html/ISSUES_md.html +0 -166
  98. data/html/acknowledgements_md.html +0 -161
  99. data/html/authors_md.html +0 -174
  100. data/html/examples/cacert_pem.html +0 -1078
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,93 +20,124 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../test_helper'
22
30
 
23
- describe Gravaty::Gravaty do
24
- describe 'when created with a valid email address ' do
25
-
26
- subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
27
- Gravaty::parser) }
28
-
29
- Gravaty::AVATAR_FORMATS.each do |avatar|
30
- describe "when asked for '#{avatar}' image" do
31
- it "shall provide an URI with specified '#{avatar}' image" do
32
- _(subject.avatar(type: avatar)).must_include(".#{avatar}")
33
- end
31
+ def test_avatar_formats
32
+ Gravaty::AVATAR_FORMATS.each do |avatar|
33
+ describe "when asked for '#{avatar}' image" do
34
+ it "shall provide an URI with specified '#{avatar}' image" do
35
+ _(subject.avatar(type: avatar)).must_include(".#{avatar}")
34
36
  end
35
37
  end
38
+ end
39
+ end
36
40
 
37
- describe 'when asked for unknown image' do
38
- it 'must raise an ArgumentError' do
39
- _(-> { subject.avatar type: 'unknown' }).must_raise ArgumentError
41
+ def test_allowed_sizes
42
+ Gravaty::ALLOWED_SIZES.each do |size|
43
+ describe "when asked for a size of '#{size}' pixels" do
44
+ it "shall provide an URI with specified '#{size}' image" do
45
+ _(subject.avatar(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
40
46
  end
41
47
  end
48
+ end
49
+ end
42
50
 
43
- Gravaty::ALLOWED_SIZES.each do |size|
44
- describe "when asked for a size of '#{size}' pixels" do
45
- it "shall provide an URI with specified '#{size}' image" do
46
- _(subject.avatar(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
47
- end
51
+ def test_unallowed_sizes
52
+ [-1, 0, Gravaty::ALLOWED_SIZES.max + 1].each do |size|
53
+ describe "when asked for an invalid size of '#{size}' pixels" do
54
+ it 'must raise an argument error' do
55
+ _(-> { subject.avatar(pixelsize: size) }).must_raise ArgumentError
48
56
  end
49
57
  end
58
+ end
59
+ end
50
60
 
51
- [-1, 0, Gravaty::ALLOWED_SIZES.max + 1].each do |size|
52
- describe "when asked for an invalid size of '#{size}' pixels" do
53
- it 'must raise an argument error' do
54
- _(-> { subject.avatar(pixelsize: size) }).must_raise ArgumentError
55
- end
61
+ def test_rating_options
62
+ Gravaty::RATING_OPTIONS.each do |rating|
63
+ describe "when asked for a specific image rating '#{rating}'" do
64
+ it "shall provide an URI with specified '#{rating}'" do
65
+ _(subject.avatar(rating: rating)).must_include("rating=#{rating}")
56
66
  end
57
67
  end
68
+ end
69
+ end
58
70
 
59
- Gravaty::RATING_OPTIONS.each do |rating|
60
- describe "when asked for a specific image rating '#{rating}'" do
61
- it "shall provide an URI with specified '#{rating}'" do
62
- _(subject.avatar(rating: rating)).must_include("rating=#{rating}")
63
- end
71
+ def test_default_options
72
+ Gravaty::DEFAULT_OPTIONS.each do |options|
73
+ describe "when asked for a specific image options '#{options}'" do
74
+ it "shall provide an URI with option '#{options}'" do
75
+ _(subject.avatar(default: options)).must_include("d=#{options}")
64
76
  end
65
77
  end
78
+ end
79
+ end
66
80
 
67
- describe 'when asked for unknown rating' do
68
- it 'must raise an ArgumentError' do
69
- _(-> { subject.avatar rating: 'unknown' }).must_raise ArgumentError
70
- end
81
+ def test_own_https_image
82
+ it 'shall provide a HTTP(S) URI' do
83
+ ['', 's'].each do |type|
84
+ an_uri = "http#{type}://www.example.com/example.jpg"
85
+ _(subject.avatar(default: an_uri)).must_include CGI.escape(an_uri)
71
86
  end
87
+ end
88
+ end
72
89
 
73
- describe 'when asked for forcing default image' do
74
- it 'shall provide a forced URI' do
75
- _(subject.avatar(force: true)).must_include Gravaty::TEST_FORCED
76
- end
90
+ def test_own_default_image
91
+ describe 'when provided with a own default image' do
92
+ test_own_https_image
93
+
94
+ it 'must raise an ArgumentError when default parameter is not correct' do
95
+ _(-> { subject.avatar default: 'ftp://www.example.com/example.jpg' }).must_raise ArgumentError
96
+ _(-> { subject.avatar default: 'http://www.example.com/example.svg' }).must_raise ArgumentError
97
+ _(-> { subject.avatar default: 'http://www.example.com?image=example.jpg' }).must_raise ArgumentError
77
98
  end
99
+ end
100
+ end
78
101
 
79
- Gravaty::DEFAULT_OPTIONS.each do |options|
80
- describe "when asked for a specific image options '#{options}'" do
81
- it "shall provide an URI with option '#{options}'" do
82
- _(subject.avatar(default: options)).must_include("d=#{options}")
83
- end
84
- end
102
+ def test_unknown_parameters
103
+ describe 'when asked for unknown image' do
104
+ it 'must raise an ArgumentError' do
105
+ _(-> { subject.avatar type: 'unknown' }).must_raise ArgumentError
85
106
  end
107
+ end
86
108
 
87
- describe 'when provided with a own default image' do
88
- it 'shall provide a HTTP(S) URI' do
89
- ['', 's'].each do |type|
90
- an_uri = "http#{type}://www.example.com/example.jpg"
91
- _(subject.avatar(default: an_uri)).must_include CGI::escape(an_uri)
92
- end
93
- end
109
+ describe 'when asked for unknown rating' do
110
+ it 'must raise an ArgumentError' do
111
+ _(-> { subject.avatar rating: 'unknown' }).must_raise ArgumentError
112
+ end
113
+ end
114
+ end
94
115
 
95
- it 'must raise an ArgumentError when URI is not HTTP(S)' do
96
- _(-> { subject.avatar default: 'ftp://www.example.com/example.jpg' }).must_raise ArgumentError
97
- end
116
+ describe Gravaty::Gravaty do
117
+ describe 'when created with a valid email address ' do
118
+ subject do
119
+ Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
120
+ Gravaty.parser)
121
+ end
98
122
 
99
- it 'must raise an ArgumentError when image format is not supported' do
100
- _(-> { subject.avatar default: 'http://www.example.com/example.svg' }).must_raise ArgumentError
101
- end
123
+ test_avatar_formats
124
+
125
+ test_allowed_sizes
126
+
127
+ test_unallowed_sizes
128
+
129
+ test_rating_options
130
+
131
+ test_unknown_parameters
102
132
 
103
- it 'must raise an ArgumentError when URI contains a query string' do
104
- _(-> { subject.avatar default: 'http://www.example.com?image=example.jpg' }).must_raise ArgumentError
133
+ describe 'when asked for forcing default image' do
134
+ it 'shall provide a forced URI' do
135
+ _(subject.avatar(force: true)).must_include Gravaty::TEST_FORCED
105
136
  end
106
137
  end
138
+
139
+ test_default_options
140
+
141
+ test_own_default_image
107
142
  end
108
143
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,14 +20,17 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../test_helper'
22
30
 
23
31
  describe Gravaty::Gravaty do
24
32
  describe 'when using a parser ' do
25
-
26
- subject { Gravaty::parser }
33
+ subject { Gravaty.parser }
27
34
 
28
35
  it 'shall provide a list of parsers' do
29
36
  _(subject.parsers).wont_be_empty
@@ -40,13 +47,12 @@ describe Gravaty::Gravaty do
40
47
  Gravaty::ALLOWED_PARAMS.each do |param|
41
48
  parsable_mocks[param] = MiniTest::Mock.new
42
49
  parsable_mocks[param].expect(:parse, false, [nil])
43
- parsable_mocks[param].expect(:nil?, false)
44
50
  end
45
51
 
46
52
  my_parser = Gravaty::Parser.new(parsable_mocks)
47
53
 
48
54
  Gravaty::ALLOWED_PARAMS.each do |param|
49
- my_parser.parse(param, nil)
55
+ my_parser.parse param
50
56
  parsable_mocks[param].verify
51
57
  end
52
58
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,14 +20,52 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../test_helper'
22
30
 
31
+ def test_qrcode_sizes
32
+ Gravaty::ALLOWED_SIZES.each do |size|
33
+ it "shall provide a '#{size}' pixels URI, when size '#{size}'" do
34
+ _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP
35
+ _(subject.qrcode(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
36
+ end
37
+ end
38
+ end
39
+
40
+ def test_qrcode
41
+ describe 'when asked for QR code format ' do
42
+ it 'shall provide an URI in QR code format' do
43
+ _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP
44
+ end
45
+
46
+ test_qrcode_sizes
47
+ end
48
+ end
49
+
50
+ def test_json
51
+ describe 'when asked for JSON format ' do
52
+ it 'shall provide an URI in JSON format' do
53
+ _(subject.json).must_match Gravaty::TEST_JSON_REGEXP
54
+ end
55
+
56
+ it 'shall provide a JSON URI when callback is provided' do
57
+ _(subject.json).must_match Gravaty::TEST_JSON_REGEXP
58
+ _(subject.json(callback: Gravaty::TEST_CALLBACK)).must_match(/#{Gravaty::TEST_CALLBACK}$/)
59
+ end
60
+ end
61
+ end
62
+
23
63
  describe Gravaty::Gravaty do
24
64
  describe 'when created with a valid email address ' do
25
- subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
26
- Gravaty::parser) }
65
+ subject do
66
+ Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
67
+ Gravaty.parser)
68
+ end
27
69
 
28
70
  Gravaty::PROFILE_FORMATS.each do |format|
29
71
  describe "when asked for '#{format}' profile" do
@@ -39,28 +81,8 @@ describe Gravaty::Gravaty do
39
81
  end
40
82
  end
41
83
 
42
- describe 'when asked for JSON format ' do
43
- it 'shall provide an URI in JSON format' do
44
- _(subject.json).must_match Gravaty::TEST_JSON_REGEXP
45
- end
46
-
47
- it 'shall provide a JSON URI when callback is provided' do
48
- _(subject.json).must_match Gravaty::TEST_JSON_REGEXP
49
- _(subject.json(callback: Gravaty::TEST_CALLBACK)).must_match(/#{Gravaty::TEST_CALLBACK}$/)
50
- end
51
- end
52
-
53
- describe 'when asked for QR code format ' do
54
- it 'shall provide an URI in QR code format' do
55
- _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP
56
- end
84
+ test_json
57
85
 
58
- Gravaty::ALLOWED_SIZES.each do |size|
59
- it "shall provide a '#{size}' pixels URI, when size '#{size}'" do
60
- _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP
61
- _(subject.qrcode(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
62
- end
63
- end
64
- end
86
+ test_qrcode
65
87
  end
66
88
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,6 +20,10 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../../test_helper'
@@ -23,53 +31,60 @@ require_relative '../../test_helper'
23
31
  describe Gravaty::Utils::Downloader do
24
32
  describe 'when passed a nil uri' do
25
33
  it 'must raise a RuntimeError' do
26
- _(-> { Gravaty::Utils::Downloader::Downloader
27
- .download_file nil, 'filename' })
28
- .must_raise RuntimeError
34
+ _(lambda {
35
+ Gravaty::Utils::Downloader::Downloader
36
+ .download_file nil, 'filename'
37
+ })
38
+ .must_raise RuntimeError
29
39
  end
30
40
  end
31
41
 
32
42
  describe 'when passed an invalid uri' do
33
43
  it 'must raise a InvalidURIError' do
34
- _(-> { Gravaty::Utils::Downloader::Downloader
35
- .download_file 'http://example.com/%uABCD',
36
- 'filename' })
37
- .must_raise URI::InvalidURIError
44
+ _(lambda {
45
+ Gravaty::Utils::Downloader::Downloader
46
+ .download_file 'http://example.com/%uABCD',
47
+ 'filename'
48
+ })
49
+ .must_raise URI::InvalidURIError
38
50
  end
39
51
  end
40
52
 
41
53
  describe 'when passed a nil filename' do
42
54
  it 'must raise a TypeError' do
43
- _(-> { Gravaty::Utils::Downloader::Downloader
44
- .download_file 'http://www.example.com',
45
- nil }).must_raise TypeError
55
+ _(lambda {
56
+ Gravaty::Utils::Downloader::Downloader
57
+ .download_file 'http://www.example.com',
58
+ nil
59
+ }).must_raise TypeError
46
60
  end
47
61
  end
48
62
 
63
+ http_file = 'wget-latest.tar.gz'
64
+ download_url = 'ftp.jaist.ac.jp/pub/GNU/wget/'
65
+
49
66
  describe 'when passed a valid HTTP filename' do
50
67
  it 'must download a proper file' do
51
- DESTINATION_FILE = 'wget-latest.tar.gz'
52
68
  Gravaty::Utils::Downloader::Downloader
53
- .download_file 'http://ftp.jaist.ac.jp/pub/GNU/wget/wget-latest.tar.gz',
54
- DESTINATION_FILE
55
- _(File.exist?(DESTINATION_FILE)).must_equal(true)
56
- File.delete DESTINATION_FILE
57
- _(File.exist?(DESTINATION_FILE)).must_equal(false)
69
+ .download_file "http://#{download_url}",
70
+ http_file
71
+ _(File.exist?(http_file)).must_equal(true)
72
+ File.delete http_file
73
+ _(File.exist?(http_file)).must_equal(false)
58
74
  end
59
75
  end
60
76
 
61
77
  describe 'when passed a valid HTTPS filename' do
62
- it 'must download a proper file' do
63
- DESTINATION_FILE = 'wget-latest.tar.gz'
64
- OLD_CERT = ENV['SSL_CERT_FILE']
65
- ENV['SSL_CERT_FILE'] = 'examples/cacert.pem'
66
- Gravaty::Utils::Downloader::Downloader
67
- .download_file 'https://ftp.jaist.ac.jp/pub/GNU/wget/wget-latest.tar.gz',
68
- DESTINATION_FILE
69
- _(File.exist?(DESTINATION_FILE)).must_equal(true)
70
- File.delete DESTINATION_FILE
71
- _(File.exist?(DESTINATION_FILE)).must_equal(false)
72
- ENV['SSL_CERT_FILE'] = OLD_CERT
78
+ if ENV['SSL_CERT_FILE']
79
+ it 'must download a proper file' do
80
+ # https_file = 'wget-latest.tar.gz'
81
+ Gravaty::Utils::Downloader::Downloader
82
+ .download_file "https://#{download_url}",
83
+ https_file
84
+ _(File.exist?(https_file)).must_equal(true)
85
+ File.delete https_file
86
+ _(File.exist?(https_file)).must_equal(false)
87
+ end
73
88
  end
74
89
  end
75
90
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,10 +20,45 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../../test_helper'
22
30
 
31
+ def test_arg_error
32
+ it 'raises ArgumentError when value is not nil and not in array' do
33
+ all_methods = { raiser_downcase: ['value', ['no value']],
34
+ raiser_to_i: ['42', [47]] }
35
+
36
+ all_methods.each_key do |method_name|
37
+ a_method = method method_name
38
+ _(lambda {
39
+ a_method.call 'error.value',
40
+ all_methods[method_name.to_sym][0],
41
+ all_methods[method_name.to_sym][1]
42
+ })
43
+ .must_raise ArgumentError
44
+ end
45
+ end
46
+ end
47
+
48
+ def test_no_arg_error
49
+ it 'do not raise an ArgumentError when value is nil or in array' do
50
+ all_methods = { raiser_downcase: [[nil, nil], ['value', ['value']]],
51
+ raiser_to_i: [[nil, nil], ['42', [42]]] }
52
+
53
+ all_methods.each_key do |method_name|
54
+ a_method = method method_name
55
+ all_methods[method_name.to_sym].each do |params|
56
+ a_method.call 'error.value', params[0], params[1]
57
+ end
58
+ end
59
+ end
60
+ end
61
+
23
62
  describe Gravaty::Utils::Raisers do
24
63
  include Gravaty::Utils::Raisers
25
64
 
@@ -31,31 +70,8 @@ describe Gravaty::Utils::Raisers do
31
70
  end
32
71
 
33
72
  describe 'when running any raiser method' do
34
- it 'do not raise an ArgumentError when value is nil or in array' do
35
- all_methods = Hash.new
36
- all_methods[:raiser_downcase] = [[nil, nil], ['value', ['value']]]
37
- all_methods[:raiser_to_i] = [[nil, nil], ['42', [42]]]
38
-
39
- all_methods.each_key do |method_name|
40
- a_method = self.method method_name
41
- all_methods[method_name.to_sym].each do |params|
42
- a_method.call 'error.value', params[0], params[1]
43
- end
44
- end
45
- end
73
+ test_no_arg_error
46
74
 
47
- it 'raises ArgumentError when value is not nil and not in array' do
48
- all_methods = Hash.new
49
- all_methods[:raiser_downcase] = ['value', ['no value']]
50
- all_methods[:raiser_to_i] = ['42', [47]]
51
-
52
- all_methods.each_key do |method_name|
53
- a_method = self.method method_name
54
- _(-> { a_method.call 'error.value',
55
- all_methods[method_name.to_sym][0],
56
- all_methods[method_name.to_sym][1] })
57
- .must_raise ArgumentError
58
- end
59
- end
75
+ test_arg_error
60
76
  end
61
77
  end