gravaty 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gravaty might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG +587 -0
- data/COPYING.md +234 -0
- data/Gemfile +17 -0
- data/ISSUES.md +40 -0
- data/README.md +128 -0
- data/Rakefile +48 -0
- data/acknowledgements.md +40 -0
- data/authors.md +44 -0
- data/copyright.md +339 -0
- data/examples/avatar.rb +121 -0
- data/examples/basics.rb +60 -0
- data/examples/profile.rb +143 -0
- data/examples/xmlrpc.rb +33 -0
- data/gravaty.gemspec +59 -0
- data/gravaty.odp +0 -0
- data/gravaty.pdf +0 -0
- data/html/CHANGELOG.html +876 -0
- data/html/COPYING_md.html +803 -0
- data/html/Gemfile.html +114 -0
- data/html/Gravaty.html +322 -0
- data/html/Gravaty/Gravaty.html +997 -0
- data/html/Gravaty/ParsableDuckType.html +158 -0
- data/html/Gravaty/Parser.html +233 -0
- data/html/Gravaty/Parsers.html +94 -0
- data/html/Gravaty/Parsers/Avatar.html +166 -0
- data/html/Gravaty/Parsers/Callback.html +167 -0
- data/html/Gravaty/Parsers/Default.html +174 -0
- data/html/Gravaty/Parsers/Force.html +167 -0
- data/html/Gravaty/Parsers/Format.html +177 -0
- data/html/Gravaty/Parsers/Pixelsize.html +177 -0
- data/html/Gravaty/Parsers/Rating.html +177 -0
- data/html/Gravaty/Parsers/Secure.html +166 -0
- data/html/Gravaty/Parsers/Type.html +177 -0
- data/html/Gravaty/Utils.html +107 -0
- data/html/Gravaty/Utils/Downloader.html +106 -0
- data/html/Gravaty/Utils/Downloader/Downloader.html +224 -0
- data/html/Gravaty/Utils/Raisers.html +199 -0
- data/html/Gravaty/Utils/Rfc5322.html +149 -0
- data/html/Gravaty/Utils/RpcConnector.html +106 -0
- data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +241 -0
- data/html/ISSUES_md.html +165 -0
- data/html/Object.html +183 -0
- data/html/README_md.html +436 -0
- data/html/Rakefile.html +152 -0
- data/html/acknowledgements_md.html +172 -0
- data/html/authors_md.html +178 -0
- data/html/copyright_md.html +553 -0
- data/html/created.rid +59 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +590 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/gravaty_gemspec.html +162 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +467 -0
- data/html/js/darkfish.js +161 -0
- data/html/js/jquery.js +4 -0
- data/html/js/navigation.js +142 -0
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +229 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +479 -0
- data/lib/gravaty.rb +59 -0
- data/lib/gravaty/application.rb +272 -0
- data/lib/gravaty/constants.rb +53 -0
- data/lib/gravaty/locales/en.yml +34 -0
- data/lib/gravaty/locales/it.yml +34 -0
- data/lib/gravaty/locales/ja.yml +35 -0
- data/lib/gravaty/parser.rb +41 -0
- data/lib/gravaty/parsers/avatar.rb +33 -0
- data/lib/gravaty/parsers/callback.rb +34 -0
- data/lib/gravaty/parsers/default.rb +79 -0
- data/lib/gravaty/parsers/force.rb +33 -0
- data/lib/gravaty/parsers/format.rb +38 -0
- data/lib/gravaty/parsers/pixelsize.rb +38 -0
- data/lib/gravaty/parsers/rating.rb +38 -0
- data/lib/gravaty/parsers/secure.rb +32 -0
- data/lib/gravaty/parsers/type.rb +38 -0
- data/lib/gravaty/utils/downloader.rb +150 -0
- data/lib/gravaty/utils/raisers.rb +50 -0
- data/lib/gravaty/utils/rfc5322.rb +102 -0
- data/lib/gravaty/utils/rpc_connector.rb +71 -0
- data/lib/gravaty/version.rb +20 -0
- data/test/gravaty/locales/test_locales.rb +61 -0
- data/test/gravaty/parsers/test_avatar.rb +35 -0
- data/test/gravaty/parsers/test_callback.rb +37 -0
- data/test/gravaty/parsers/test_default.rb +69 -0
- data/test/gravaty/parsers/test_force.rb +35 -0
- data/test/gravaty/parsers/test_format.rb +48 -0
- data/test/gravaty/parsers/test_pixelsize.rb +50 -0
- data/test/gravaty/parsers/test_rating.rb +48 -0
- data/test/gravaty/parsers/test_secure.rb +35 -0
- data/test/gravaty/parsers/test_type.rb +37 -0
- data/test/gravaty/test_application.rb +111 -0
- data/test/gravaty/test_avatar.rb +115 -0
- data/test/gravaty/test_parsable_duck_type.rb +31 -0
- data/test/gravaty/test_parser.rb +55 -0
- data/test/gravaty/test_profile.rb +63 -0
- data/test/gravaty/utils/test_downloader.rb +43 -0
- data/test/gravaty/utils/test_raisers.rb +55 -0
- data/test/gravaty/utils/test_rfc5322.rb +58 -0
- data/test/gravaty/utils/test_rpc_connector.rb +74 -0
- data/test/test_gravaty.rb +44 -0
- data/test/test_helper.rb +77 -0
- metadata +315 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Gravaty do
|
20
|
+
describe 'when created with a valid email address' do
|
21
|
+
|
22
|
+
subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS, Gravaty::parser) }
|
23
|
+
|
24
|
+
Gravaty::AVATAR_FORMATS.each do |avatar|
|
25
|
+
describe "when asked for #{avatar} image " do
|
26
|
+
it "shall provide an URI with specified #{avatar} image" do
|
27
|
+
subject.avatar(type: avatar).must_include(".#{avatar}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'when asked for unknown image' do
|
33
|
+
it 'must raise an ArgumentError' do
|
34
|
+
assert_raises ArgumentError do
|
35
|
+
subject.avatar type: 'unknown'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Gravaty::ALLOWED_SIZES.each do |size|
|
41
|
+
describe "when asked for a size of #{size} pixels " do
|
42
|
+
it "shall provide an URI with specified #{size} image" do
|
43
|
+
subject.avatar(pixelsize: size).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
[-1, 0, Gravaty::ALLOWED_SIZES.max + 1].each do |size|
|
49
|
+
describe "when asked for an invalid size of #{size} pixels " do
|
50
|
+
it 'must raise an argument error' do
|
51
|
+
assert_raises ArgumentError do
|
52
|
+
subject.avatar(pixelsize: size)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Gravaty::RATING_OPTIONS.each do |rating|
|
59
|
+
describe "when asked for a specific image rating #{rating}" do
|
60
|
+
it "shall provide an URI with specified #{rating}" do
|
61
|
+
subject.avatar(rating: rating).must_include("rating=#{rating}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'when asked for unknown rating' do
|
67
|
+
it 'must raise an ArgumentError' do
|
68
|
+
assert_raises ArgumentError do
|
69
|
+
subject.avatar rating: 'unknown'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'when asked for forcing default image' do
|
75
|
+
it 'shall provide a forced URI' do
|
76
|
+
subject.avatar(force: true).must_include Gravaty::TEST_FORCED
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
Gravaty::DEFAULT_OPTIONS.each do |options|
|
81
|
+
describe "when asked for a specific image options #{options} " do
|
82
|
+
it "shall provide an URI with option #{options}" do
|
83
|
+
subject.avatar(default: options).must_include("d=#{options}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'when provided with a own default image' do
|
89
|
+
it 'shall provide a HTTP(S) URI' do
|
90
|
+
['', 's'].each do |type|
|
91
|
+
an_uri = "http#{type}://www.example.com/example.jpg"
|
92
|
+
subject.avatar(default: an_uri).must_include CGI::escape(an_uri)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'must raise an ArgumentError when URI is not HTTP(S)' do
|
97
|
+
assert_raises ArgumentError do
|
98
|
+
subject.avatar default: 'ftp://www.example.com/example.jpg'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'must raise an ArgumentError when image format is not supported' do
|
103
|
+
assert_raises ArgumentError do
|
104
|
+
subject.avatar default: 'http://www.example.com/example.svg'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'must raise an ArgumentError when URI contains a query string' do
|
109
|
+
assert_raises ArgumentError do
|
110
|
+
subject.avatar default: 'http://www.example.com?image=example.jpg'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module Gravaty
|
18
|
+
|
19
|
+
# This module represents the parsable duck type element for testing purposes.
|
20
|
+
#
|
21
|
+
# Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
|
22
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
23
|
+
# License:: GNU General Public License version 3
|
24
|
+
module ParsableDuckType
|
25
|
+
|
26
|
+
# The method that tests the parsable duck type interface and its +parse+ method.
|
27
|
+
def test_parsable_duck_type
|
28
|
+
subject.must_respond_to :parse unless subject.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Gravaty do
|
20
|
+
describe 'when using a parser' do
|
21
|
+
|
22
|
+
subject { Gravaty::parser }
|
23
|
+
|
24
|
+
it 'shall provide a list of parsers' do
|
25
|
+
subject.parsers.wont_be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'shall provide all needed parsers' do
|
29
|
+
subject.parsers.length.must_equal Gravaty::ALLOWED_PARAMS.length
|
30
|
+
subject.parsers.keys.must_equal Gravaty::ALLOWED_PARAMS
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'shall use the parsable duck type' do
|
34
|
+
parsable_mocks = {}
|
35
|
+
|
36
|
+
Gravaty::ALLOWED_PARAMS.each do |param|
|
37
|
+
parsable_mocks[param] = MiniTest::Mock.new
|
38
|
+
parsable_mocks[param].expect(:parse, false, [nil])
|
39
|
+
parsable_mocks[param].expect(:nil?, false)
|
40
|
+
end
|
41
|
+
|
42
|
+
my_parser = Gravaty::Parser.new(parsable_mocks)
|
43
|
+
|
44
|
+
Gravaty::ALLOWED_PARAMS.each do |param|
|
45
|
+
my_parser.parse(param, nil)
|
46
|
+
parsable_mocks[param].verify
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'shall die gracefully whether parameters are not valid' do
|
51
|
+
a_parser = Gravaty::Parser.new(nil)
|
52
|
+
a_parser.parse
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Gravaty do
|
20
|
+
describe 'when created with a valid email address' do
|
21
|
+
subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS, Gravaty::parser) }
|
22
|
+
|
23
|
+
Gravaty::PROFILE_FORMATS.each do |format|
|
24
|
+
describe "when asked for #{format} profile " do
|
25
|
+
it "shall provide an URI with required #{format} format" do
|
26
|
+
subject.profile(format: format).must_include(".#{format}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'when asked for unknown profile format' do
|
32
|
+
it 'must raise an ArgumentError' do
|
33
|
+
assert_raises ArgumentError do
|
34
|
+
subject.profile format: 'unknown'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'when asked for JSON format' do
|
40
|
+
it 'shall provide an URI in JSON format' do
|
41
|
+
subject.json.must_match Gravaty::TEST_JSON_REGEXP
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'shall provide a JSON URI with callback, when callback is provided' do
|
45
|
+
subject.json.must_match Gravaty::TEST_JSON_REGEXP
|
46
|
+
subject.json(callback: Gravaty::TEST_CALLBACK).must_match(/#{Gravaty::TEST_CALLBACK}$/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'when asked for QR code format' do
|
51
|
+
it 'shall provide an URI in QR code format' do
|
52
|
+
subject.qrcode.must_match Gravaty::TEST_QR_REGEXP
|
53
|
+
end
|
54
|
+
|
55
|
+
Gravaty::ALLOWED_SIZES.each do |size|
|
56
|
+
it "shall provide a #{size} pixels sized URI, when size #{size} is provided" do
|
57
|
+
subject.qrcode.must_match Gravaty::TEST_QR_REGEXP
|
58
|
+
subject.qrcode(pixelsize: size).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Utils::Downloader do
|
20
|
+
describe 'when passed a nil uri' do
|
21
|
+
it 'must raise a RuntimeError' do
|
22
|
+
assert_raises RuntimeError do
|
23
|
+
Gravaty::Utils::Downloader::Downloader.download_file nil, 'filename'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when passed an invalid uri' do
|
29
|
+
it 'must raise a InvalidURIError' do
|
30
|
+
assert_raises URI::InvalidURIError do
|
31
|
+
Gravaty::Utils::Downloader::Downloader.download_file 'http://example.com/%uABCD', 'filename'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when passed a nil filename' do
|
37
|
+
it 'must raise a TypeError' do
|
38
|
+
assert_raises TypeError do
|
39
|
+
Gravaty::Utils::Downloader::Downloader.download_file 'http://www.example.com', nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../../test_helper'
|
18
|
+
|
19
|
+
|
20
|
+
describe Gravaty::Utils::Raisers do
|
21
|
+
include Gravaty::Utils::Raisers
|
22
|
+
|
23
|
+
before do
|
24
|
+
I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
|
25
|
+
I18n.locale = 'it'
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when running any raiser method' do
|
29
|
+
it 'does not raise an ArgumentError when value is nil or in the array' do
|
30
|
+
all_methods = Hash.new
|
31
|
+
all_methods[:raiser_downcase] = [[nil, nil], ['value', ['value']]]
|
32
|
+
all_methods[:raiser_to_i] = [[nil, nil], ['42', [42]]]
|
33
|
+
|
34
|
+
all_methods.each_key do |method_name|
|
35
|
+
a_method = self.method method_name
|
36
|
+
all_methods[method_name.to_sym].each do |params|
|
37
|
+
a_method.call 'error.value', params[0], params[1]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raises ArgumentError when value is not nil and not in the array' do
|
43
|
+
all_methods = Hash.new
|
44
|
+
all_methods[:raiser_downcase] = ['value', ['no value']]
|
45
|
+
all_methods[:raiser_to_i] = ['42', [47]]
|
46
|
+
|
47
|
+
all_methods.each_key do |method_name|
|
48
|
+
a_method = self.method method_name
|
49
|
+
assert_raises ArgumentError do
|
50
|
+
a_method.call 'error.value', all_methods[method_name.to_sym][0], all_methods[method_name.to_sym][1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Utils::Rfc5322 do
|
20
|
+
describe 'when passed a nil email address' do
|
21
|
+
it 'must return nil' do
|
22
|
+
Gravaty::Utils::Rfc5322::EMAIL.match(nil).must_be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'when passed an invalid email address, according to RF5322' do
|
27
|
+
|
28
|
+
# This test does not pass with 'Joe Q. Public <john.q.public@example.com>' email: see <https://tools.ietf.org/html/rfc5322#appendix-A.1.2>
|
29
|
+
#
|
30
|
+
# Note that the display names for Joe Q. Public and Giant; "Big" Box needed to be enclosed in double-quotes because
|
31
|
+
# the former contains the period and the latter contains both semicolon and double-quote characters (the
|
32
|
+
# double-quote characters appearing as quoted-pair constructs).
|
33
|
+
['-.', 'Joe Q. Public <john.q.public@example.com>'].each do |invalid_address|
|
34
|
+
it "must return nil for #{invalid_address} invalid address" do
|
35
|
+
assert_nil Gravaty::Utils::Rfc5322::EMAIL.match invalid_address
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'when passed a valid email address, according to RF5322' do
|
41
|
+
|
42
|
+
# This test shall pass... see <https://tools.ietf.org/html/rfc5322#appendix-A.5>
|
43
|
+
#
|
44
|
+
# The above example is aesthetically displeasing, but perfectly legal. Note particularly (1) the comments in the
|
45
|
+
# "From:" field (including one that has a ")" character appearing as part of a quoted-pair); (2) the white space
|
46
|
+
# absent after the ":" in the "To:" field as well as the comment and folding white space after the group name, the
|
47
|
+
# special character (".") in the comment in Chris Jones's address, and the folding white space before and after
|
48
|
+
# "joe@example.org,"; (3) the multiple and nested comments in the "Cc:" field as well as the comment immediately
|
49
|
+
# following the ":" after "Cc"; (4) the folding white space (but no comments except at the end) and the missing
|
50
|
+
# seconds in the time of the date field; and (5) the white space before (but not within) the identifier in the
|
51
|
+
# "Message-ID:" field.
|
52
|
+
['John Doe <jdoe@machine.example>', 'Mary Smith <mary@example.net>', 'Mary Smith <mary@example.net>', "A Group(Some people)\n :Chris Jones <c@(Chris's host.)public.example>,\n joe@example.org,\n John <jdoe@one.test> (my dear friend);", 'Who? <one@y.test>', '"Giant; \"Big\" Box" <sysservices@example.net>', 'A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;', 'Pete(A nice \) chap) <pete(his account)@silly.test(his host)>'].each do |address|
|
53
|
+
it "must match the valid #{address} email address" do
|
54
|
+
refute_nil Gravaty::Utils::Rfc5322::EMAIL.match address
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../../test_helper'
|
18
|
+
|
19
|
+
|
20
|
+
describe Gravaty::Utils::RpcConnector do
|
21
|
+
before do
|
22
|
+
I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
|
23
|
+
I18n.locale = 'it'
|
24
|
+
end
|
25
|
+
|
26
|
+
digest = Digest::MD5.hexdigest('[YOUR EMAIL HERE]'.downcase)
|
27
|
+
password = '[YOUR PASSWORD HERE]'
|
28
|
+
|
29
|
+
subject { Gravaty::Utils::RpcConnector::RpcConnector.new digest, password }
|
30
|
+
|
31
|
+
describe 'when receiving an invalid parameter' do
|
32
|
+
[nil, ''].each do |param|
|
33
|
+
it "shall raise an ArgumentError when digest is #{param}" do
|
34
|
+
assert_raises ArgumentError do
|
35
|
+
Gravaty::Utils::RpcConnector::RpcConnector.new param, password
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shall raise an ArgumentError when password is #{param}" do
|
40
|
+
assert_raises ArgumentError do
|
41
|
+
Gravaty::Utils::RpcConnector::RpcConnector.new digest, param
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "shall raise an ArgumentError when both parameters are #{param}" do
|
46
|
+
assert_raises ArgumentError do
|
47
|
+
Gravaty::Utils::RpcConnector::RpcConnector.new param, param
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'when created with valid parameters' do
|
54
|
+
it 'shall provide an useable connector' do
|
55
|
+
subject.wont_be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'shall provide information through test method' do
|
59
|
+
result = subject.call(Gravaty::RPC_TEST_METHOD)
|
60
|
+
|
61
|
+
result.wont_be_nil
|
62
|
+
result.wont_be_empty
|
63
|
+
result['response'].wont_be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'shall provide information through exists method' do
|
67
|
+
result = subject.call('grav.exists', hashes: [digest])
|
68
|
+
|
69
|
+
result.wont_be_nil
|
70
|
+
result.wont_be_empty
|
71
|
+
result[digest].wont_be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|