gravaty 9.0.1 → 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/Gemfile +1 -1
- data/ISSUES.md +2 -2
- data/README.md +119 -105
- data/Rakefile +1 -1
- data/acknowledgements.md +2 -2
- data/authors.md +2 -2
- data/copyright.md +4 -4
- data/examples/avatar.rb +1 -1
- data/examples/basics.rb +1 -1
- data/examples/cacert.pem +142 -77
- data/examples/profile.rb +1 -1
- data/examples/xmlrpc.rb +3 -3
- data/gravaty.gemspec +9 -9
- data/html/CHANGELOG.html +19 -6
- data/html/COPYING_md.html +7 -6
- data/html/Gemfile.html +8 -7
- data/html/Gravaty.html +12 -12
- data/html/Gravaty/Gravaty.html +121 -121
- data/html/Gravaty/ParsableDuckType.html +8 -5
- data/html/Gravaty/Parser.html +21 -21
- data/html/Gravaty/Parsers.html +7 -4
- data/html/Gravaty/Parsers/Avatar.html +12 -12
- data/html/Gravaty/Parsers/Callback.html +13 -13
- data/html/Gravaty/Parsers/Default.html +21 -21
- data/html/Gravaty/Parsers/Force.html +13 -13
- data/html/Gravaty/Parsers/Format.html +13 -13
- data/html/Gravaty/Parsers/Pixelsize.html +13 -13
- data/html/Gravaty/Parsers/Rating.html +13 -13
- data/html/Gravaty/Parsers/Secure.html +12 -12
- data/html/Gravaty/Parsers/Type.html +13 -13
- data/html/Gravaty/Utils.html +9 -9
- data/html/Gravaty/Utils/Downloader.html +7 -4
- data/html/Gravaty/Utils/Downloader/Downloader.html +7 -4
- data/html/Gravaty/Utils/Raisers.html +21 -21
- data/html/Gravaty/Utils/Rfc5322.html +7 -4
- data/html/Gravaty/Utils/RpcConnector.html +9 -9
- data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +29 -26
- data/html/ISSUES_md.html +9 -8
- data/html/Object.html +17 -4
- data/html/README_md.html +18 -18
- data/html/Rakefile.html +9 -8
- data/html/acknowledgements_md.html +9 -8
- data/html/authors_md.html +9 -8
- data/html/copyright_md.html +226 -202
- data/html/created.rid +55 -56
- data/html/css/rdoc.css +35 -6
- data/html/examples/cacert_pem.html +47 -25
- data/html/index.html +18 -18
- data/html/js/darkfish.js +22 -99
- data/html/js/navigation.js +4 -40
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +32 -31
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +6 -6
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +16 -10
- data/lib/gravaty.rb +4 -3
- data/lib/gravaty/application.rb +4 -5
- data/lib/gravaty/constants.rb +1 -1
- data/lib/gravaty/locales/en.yml +1 -1
- data/lib/gravaty/locales/it.yml +1 -1
- data/lib/gravaty/locales/ja.yml +1 -1
- data/lib/gravaty/parser.rb +2 -3
- data/lib/gravaty/parsers/avatar.rb +2 -3
- data/lib/gravaty/parsers/callback.rb +2 -3
- data/lib/gravaty/parsers/default.rb +4 -5
- data/lib/gravaty/parsers/force.rb +2 -3
- data/lib/gravaty/parsers/format.rb +2 -3
- data/lib/gravaty/parsers/pixelsize.rb +2 -3
- data/lib/gravaty/parsers/rating.rb +2 -3
- data/lib/gravaty/parsers/secure.rb +2 -3
- data/lib/gravaty/parsers/type.rb +2 -3
- data/lib/gravaty/utils/downloader.rb +4 -4
- data/lib/gravaty/utils/raisers.rb +3 -5
- data/lib/gravaty/utils/rfc5322.rb +1 -1
- data/lib/gravaty/utils/rpc_connector.rb +2 -3
- data/lib/gravaty/version.rb +2 -2
- data/test/gravaty/locales/test_locales.rb +11 -11
- data/test/gravaty/parsers/test_avatar.rb +3 -3
- data/test/gravaty/parsers/test_callback.rb +3 -3
- data/test/gravaty/parsers/test_default.rb +10 -10
- data/test/gravaty/parsers/test_force.rb +3 -3
- data/test/gravaty/parsers/test_format.rb +6 -6
- data/test/gravaty/parsers/test_pixelsize.rb +7 -7
- data/test/gravaty/parsers/test_rating.rb +6 -6
- data/test/gravaty/parsers/test_secure.rb +3 -3
- data/test/gravaty/parsers/test_type.rb +3 -3
- data/test/gravaty/test_application.rb +22 -38
- data/test/gravaty/test_avatar.rb +15 -29
- data/test/gravaty/test_parser.rb +5 -5
- data/test/gravaty/test_profile.rb +11 -15
- data/test/gravaty/utils/test_downloader.rb +38 -14
- data/test/gravaty/utils/test_raisers.rb +5 -6
- data/test/gravaty/utils/test_rfc5322.rb +4 -4
- data/test/gravaty/utils/test_rpc_connector.rb +10 -13
- data/test/test_gravaty.rb +5 -9
- data/test/test_helper.rb +1 -1
- metadata +26 -28
- data/html/gravaty_gemspec.html +0 -169
- data/html/js/jquery.js +0 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -28,11 +28,11 @@ describe Gravaty::Gravaty do
|
|
28
28
|
@parser = subject
|
29
29
|
end
|
30
30
|
|
31
|
-
subject {Gravaty::Parsers::Avatar.new}
|
31
|
+
subject { Gravaty::Parsers::Avatar.new }
|
32
32
|
|
33
33
|
[['avatar/', true], ['', false]].each do |pair|
|
34
34
|
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
-
subject.parse(pair[1]).must_equal pair[0]
|
35
|
+
_(subject.parse(pair[1])).must_equal pair[0]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -28,13 +28,13 @@ describe Gravaty::Gravaty do
|
|
28
28
|
@parser = subject
|
29
29
|
end
|
30
30
|
|
31
|
-
subject {Gravaty::Parsers::Callback.new}
|
31
|
+
subject { Gravaty::Parsers::Callback.new }
|
32
32
|
|
33
33
|
%w(test sample_callback).each do |value|
|
34
34
|
[[nil, ''], ['', ''], %W(#{value} callback=#{value})]
|
35
35
|
.each do |pair|
|
36
36
|
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
37
|
-
subject.parse(pair[0]).must_equal pair[1]
|
37
|
+
_(subject.parse(pair[0])).must_equal pair[1]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -33,12 +33,12 @@ describe Gravaty::Gravaty do
|
|
33
33
|
@parser = subject
|
34
34
|
end
|
35
35
|
|
36
|
-
subject {Gravaty::Parsers::Default.new}
|
36
|
+
subject { Gravaty::Parsers::Default.new }
|
37
37
|
|
38
38
|
Gravaty::DEFAULT_OPTIONS.each do |value|
|
39
39
|
[[nil, ''], ['', ''], %W(#{value} d=#{value})].each do |pair|
|
40
40
|
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
41
|
-
subject.parse(pair[0]).must_equal pair[1]
|
41
|
+
_(subject.parse(pair[0])).must_equal pair[1]
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -48,7 +48,7 @@ describe Gravaty::Gravaty do
|
|
48
48
|
escaped = "d=#{CGI::escape(value)}"
|
49
49
|
|
50
50
|
it "shall return '#{escaped}' when parameter is '#{value}'" do
|
51
|
-
subject.parse(value).must_equal escaped
|
51
|
+
_(subject.parse(value)).must_equal escaped
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -58,9 +58,9 @@ describe Gravaty::Gravaty do
|
|
58
58
|
subject.parse('http://www.example.com/images/example.svg')
|
59
59
|
.must_raise ArgumentError
|
60
60
|
rescue ArgumentError => aErr
|
61
|
-
aErr.wont_be_nil
|
62
|
-
aErr.message.wont_be_nil
|
63
|
-
aErr.message.wont_be_empty
|
61
|
+
_(aErr).wont_be_nil
|
62
|
+
_(aErr.message).wont_be_nil
|
63
|
+
_(aErr.message).wont_be_empty
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,9 +68,9 @@ describe Gravaty::Gravaty do
|
|
68
68
|
begin
|
69
69
|
subject.parse('svg').must_raise ArgumentError
|
70
70
|
rescue ArgumentError => aErr
|
71
|
-
aErr.wont_be_nil
|
72
|
-
aErr.message.wont_be_nil
|
73
|
-
aErr.message.wont_be_empty
|
71
|
+
_(aErr).wont_be_nil
|
72
|
+
_(aErr.message).wont_be_nil
|
73
|
+
_(aErr.message).wont_be_empty
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -28,11 +28,11 @@ describe Gravaty::Gravaty do
|
|
28
28
|
@parser = subject
|
29
29
|
end
|
30
30
|
|
31
|
-
subject {Gravaty::Parsers::Force.new}
|
31
|
+
subject { Gravaty::Parsers::Force.new }
|
32
32
|
|
33
33
|
[['f=y', true], ['', false]].each do |pair|
|
34
34
|
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
-
subject.parse(pair[1]).must_equal pair[0]
|
35
|
+
_(subject.parse(pair[1])).must_equal pair[0]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -31,12 +31,12 @@ describe Gravaty::Gravaty do
|
|
31
31
|
@parser = subject
|
32
32
|
end
|
33
33
|
|
34
|
-
subject {Gravaty::Parsers::Format.new}
|
34
|
+
subject { Gravaty::Parsers::Format.new }
|
35
35
|
|
36
36
|
Gravaty::PROFILE_FORMATS.each do |value|
|
37
37
|
[[nil, ''], %W(#{value} .#{value.downcase})].each do |pair|
|
38
38
|
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
39
|
-
subject.parse(pair[0]).must_equal pair[1]
|
39
|
+
_(subject.parse(pair[0])).must_equal pair[1]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -45,9 +45,9 @@ describe Gravaty::Gravaty do
|
|
45
45
|
begin
|
46
46
|
subject.parse('svg').must_raise ArgumentError
|
47
47
|
rescue ArgumentError => aErr
|
48
|
-
aErr.wont_be_nil
|
49
|
-
aErr.message.wont_be_nil
|
50
|
-
aErr.message.wont_be_empty
|
48
|
+
_(aErr).wont_be_nil
|
49
|
+
_(aErr.message).wont_be_nil
|
50
|
+
_(aErr.message).wont_be_empty
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -31,15 +31,15 @@ describe Gravaty::Gravaty do
|
|
31
31
|
@parser = subject
|
32
32
|
end
|
33
33
|
|
34
|
-
subject {Gravaty::Parsers::Pixelsize.new}
|
34
|
+
subject { Gravaty::Parsers::Pixelsize.new }
|
35
35
|
|
36
36
|
it 'shall return nothing when parameter is nil' do
|
37
|
-
subject.parse(nil).must_be_empty
|
37
|
+
_(subject.parse(nil)).must_be_empty
|
38
38
|
end
|
39
39
|
|
40
40
|
Gravaty::ALLOWED_SIZES.each do |value|
|
41
41
|
it "shall return s='#{value.to_s}' when parameter is '#{value}'" do
|
42
|
-
subject.parse(value).must_equal "s=#{value.to_s}"
|
42
|
+
_(subject.parse(value)).must_equal "s=#{value.to_s}"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -47,9 +47,9 @@ describe Gravaty::Gravaty do
|
|
47
47
|
begin
|
48
48
|
subject.parse(0).must_raise ArgumentError
|
49
49
|
rescue ArgumentError => aErr
|
50
|
-
aErr.wont_be_nil
|
51
|
-
aErr.message.wont_be_nil
|
52
|
-
aErr.message.wont_be_empty
|
50
|
+
_(aErr).wont_be_nil
|
51
|
+
_(aErr.message).wont_be_nil
|
52
|
+
_(aErr.message).wont_be_empty
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -31,12 +31,12 @@ describe Gravaty::Gravaty do
|
|
31
31
|
@parser = subject
|
32
32
|
end
|
33
33
|
|
34
|
-
subject {Gravaty::Parsers::Rating.new}
|
34
|
+
subject { Gravaty::Parsers::Rating.new }
|
35
35
|
|
36
36
|
Gravaty::RATING_OPTIONS.each do |value|
|
37
37
|
[[nil, ''], %W(#{value} rating=#{value.downcase})].each do |pair|
|
38
38
|
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
39
|
-
subject.parse(pair[0]).must_equal pair[1]
|
39
|
+
_(subject.parse(pair[0])).must_equal pair[1]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -45,9 +45,9 @@ describe Gravaty::Gravaty do
|
|
45
45
|
begin
|
46
46
|
subject.parse('xxx').must_raise ArgumentError
|
47
47
|
rescue ArgumentError => aErr
|
48
|
-
aErr.wont_be_nil
|
49
|
-
aErr.message.wont_be_nil
|
50
|
-
aErr.message.wont_be_empty
|
48
|
+
_(aErr).wont_be_nil
|
49
|
+
_(aErr.message).wont_be_nil
|
50
|
+
_(aErr.message).wont_be_empty
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -28,11 +28,11 @@ describe Gravaty::Gravaty do
|
|
28
28
|
@parser = subject
|
29
29
|
end
|
30
30
|
|
31
|
-
subject {Gravaty::Parsers::Secure.new}
|
31
|
+
subject { Gravaty::Parsers::Secure.new }
|
32
32
|
|
33
33
|
[['https://secure', true], ['http://www', false]].each do |pair|
|
34
34
|
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
-
subject.parse(pair[1]).must_equal pair[0]
|
35
|
+
_(subject.parse(pair[1])).must_equal pair[0]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -31,12 +31,12 @@ describe Gravaty::Gravaty do
|
|
31
31
|
'*.yml')]
|
32
32
|
end
|
33
33
|
|
34
|
-
subject {Gravaty::Parsers::Type.new}
|
34
|
+
subject { Gravaty::Parsers::Type.new }
|
35
35
|
|
36
36
|
Gravaty::AVATAR_FORMATS.each do |value|
|
37
37
|
[[nil, ''], %W(#{value} .#{value.downcase})].each do |pair|
|
38
38
|
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
39
|
-
subject.parse(pair[0]).must_equal pair[1]
|
39
|
+
_(subject.parse(pair[0])).must_equal pair[1]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -23,103 +23,87 @@ require_relative '../test_helper'
|
|
23
23
|
describe Gravaty::Gravaty do
|
24
24
|
describe 'when created with a valid email address' do
|
25
25
|
|
26
|
-
subject {Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
|
27
|
-
|
26
|
+
subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
|
27
|
+
Gravaty::parser) }
|
28
28
|
|
29
29
|
it 'shall return the email content on demand' do
|
30
|
-
subject.email.must_equal Gravaty::TEST_MY_ADDRESS.downcase
|
30
|
+
_(subject.email).must_equal Gravaty::TEST_MY_ADDRESS.downcase
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'shall return the digest content on demand' do
|
34
|
-
subject.digest.must_equal Gravaty::TEST_MY_MD5
|
34
|
+
_(subject.digest).must_equal Gravaty::TEST_MY_MD5
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'shall return a valid string' do
|
38
|
-
subject.to_s.wont_be_nil
|
38
|
+
_(subject.to_s).wont_be_nil
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'shall return a valid JSON' do
|
42
|
-
subject.to_json.wont_be_nil
|
43
|
-
JSON.parse(subject.to_json).wont_be_nil
|
42
|
+
_(subject.to_json).wont_be_nil
|
43
|
+
_(JSON.parse(subject.to_json)).wont_be_nil
|
44
44
|
end
|
45
45
|
|
46
46
|
[:avatar, :profile].each do |method|
|
47
47
|
describe "when asked for '#{method}'" do
|
48
48
|
describe 'when no parameters are provided' do
|
49
49
|
it 'shall provide an URI' do
|
50
|
-
subject.send(method)
|
51
|
-
.must_match Gravaty::TEST_SIMPLE_URI_REGEXP
|
50
|
+
_(subject.send(method)).must_match Gravaty::TEST_SIMPLE_URI_REGEXP
|
52
51
|
end
|
53
52
|
|
54
53
|
it "shall provide a '#{method}' URI" do
|
55
|
-
subject.send(method)
|
56
|
-
.must_include Gravaty::TEST_STRING[method]
|
54
|
+
_(subject.send(method)).must_include Gravaty::TEST_STRING[method]
|
57
55
|
end
|
58
56
|
|
59
57
|
it "shall provide a '#{method}' with a secure URI" do
|
60
|
-
subject.send(method)
|
61
|
-
|
62
|
-
subject.send(method)
|
63
|
-
.wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
58
|
+
_(subject.send(method)).must_match Gravaty::TEST_SECURE_URI_REGEXP
|
59
|
+
_(subject.send(method)).wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
63
|
describe 'when nil is provided' do
|
68
64
|
it 'shall provide an URI' do
|
69
|
-
subject.send(method, nil)
|
70
|
-
.must_match Gravaty::TEST_SIMPLE_URI_REGEXP
|
65
|
+
_(subject.send(method, nil)).must_match Gravaty::TEST_SIMPLE_URI_REGEXP
|
71
66
|
end
|
72
67
|
|
73
68
|
it "shall provide a '#{method}' URI" do
|
74
|
-
subject.send(method, nil)
|
75
|
-
.must_include Gravaty::TEST_STRING[method]
|
69
|
+
_(subject.send(method, nil)).must_include Gravaty::TEST_STRING[method]
|
76
70
|
end
|
77
71
|
|
78
72
|
it "shall provide a '#{method}' with a secure URI" do
|
79
|
-
subject.send(method, nil)
|
80
|
-
|
81
|
-
subject.send(method, nil)
|
82
|
-
.wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
73
|
+
_(subject.send(method, nil)).must_match Gravaty::TEST_SECURE_URI_REGEXP
|
74
|
+
_(subject.send(method, nil)).wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
83
75
|
end
|
84
76
|
|
85
77
|
end
|
86
78
|
|
87
79
|
describe 'when secure:false is provided' do
|
88
80
|
it "shall provide a '#{method}' with an unsecure URI" do
|
89
|
-
subject.send(method, secure: false)
|
90
|
-
|
91
|
-
subject.send(method, secure: false)
|
92
|
-
.must_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
81
|
+
_(subject.send(method, secure: false)).wont_match Gravaty::TEST_SECURE_URI_REGEXP
|
82
|
+
_(subject.send(method, secure: false)).must_match Gravaty::TEST_UNSECURE_URI_REGEXP
|
93
83
|
end
|
94
84
|
end
|
95
85
|
end
|
96
86
|
end
|
97
87
|
|
98
88
|
it 'shall provide the XML-RPC API interface' do
|
99
|
-
subject.must_respond_to :xmlrpc
|
89
|
+
_(subject).must_respond_to :xmlrpc
|
100
90
|
end
|
101
91
|
|
102
92
|
describe 'when asked for nil method' do
|
103
93
|
it 'must raise an ArgumentError' do
|
104
|
-
|
105
|
-
subject.xmlrpc(nil)
|
106
|
-
end
|
94
|
+
_(-> { subject.xmlrpc(nil) }).must_raise ArgumentError
|
107
95
|
end
|
108
96
|
end
|
109
97
|
|
110
98
|
describe 'when asked for an unsupported method' do
|
111
99
|
it 'must raise an ArgumentError' do
|
112
|
-
|
113
|
-
subject.xmlrpc('my_method', 'my_password')
|
114
|
-
end
|
100
|
+
_(-> { subject.xmlrpc('my_method', 'my_password') }).must_raise ArgumentError
|
115
101
|
end
|
116
102
|
end
|
117
103
|
|
118
104
|
describe 'when asked for a valid method with a nil password' do
|
119
105
|
it 'must raise an ArgumentError' do
|
120
|
-
|
121
|
-
subject.xmlrpc('my_method')
|
122
|
-
end
|
106
|
+
_(-> { subject.xmlrpc('my_method') }).must_raise ArgumentError
|
123
107
|
end
|
124
108
|
end
|
125
109
|
end
|
data/test/gravaty/test_avatar.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# gravaty
|
3
|
-
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of gravaty.
|
6
6
|
#
|
@@ -23,30 +23,27 @@ require_relative '../test_helper'
|
|
23
23
|
describe Gravaty::Gravaty do
|
24
24
|
describe 'when created with a valid email address ' do
|
25
25
|
|
26
|
-
subject {Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
|
27
|
-
|
26
|
+
subject { Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS,
|
27
|
+
Gravaty::parser) }
|
28
28
|
|
29
29
|
Gravaty::AVATAR_FORMATS.each do |avatar|
|
30
30
|
describe "when asked for '#{avatar}' image" do
|
31
31
|
it "shall provide an URI with specified '#{avatar}' image" do
|
32
|
-
subject.avatar(type: avatar).must_include(".#{avatar}")
|
32
|
+
_(subject.avatar(type: avatar)).must_include(".#{avatar}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'when asked for unknown image' do
|
38
38
|
it 'must raise an ArgumentError' do
|
39
|
-
|
40
|
-
subject.avatar type: 'unknown'
|
41
|
-
end
|
39
|
+
_(-> { subject.avatar type: 'unknown' }).must_raise ArgumentError
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
43
|
Gravaty::ALLOWED_SIZES.each do |size|
|
46
44
|
describe "when asked for a size of '#{size}' pixels" do
|
47
45
|
it "shall provide an URI with specified '#{size}' image" do
|
48
|
-
subject.avatar(pixelsize: size)
|
49
|
-
.must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
|
46
|
+
_(subject.avatar(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/)
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
@@ -54,9 +51,7 @@ describe Gravaty::Gravaty do
|
|
54
51
|
[-1, 0, Gravaty::ALLOWED_SIZES.max + 1].each do |size|
|
55
52
|
describe "when asked for an invalid size of '#{size}' pixels" do
|
56
53
|
it 'must raise an argument error' do
|
57
|
-
|
58
|
-
subject.avatar(pixelsize: size)
|
59
|
-
end
|
54
|
+
_(-> { subject.avatar(pixelsize: size) }).must_raise ArgumentError
|
60
55
|
end
|
61
56
|
end
|
62
57
|
end
|
@@ -64,30 +59,27 @@ describe Gravaty::Gravaty do
|
|
64
59
|
Gravaty::RATING_OPTIONS.each do |rating|
|
65
60
|
describe "when asked for a specific image rating '#{rating}'" do
|
66
61
|
it "shall provide an URI with specified '#{rating}'" do
|
67
|
-
subject.avatar(rating: rating)
|
68
|
-
.must_include("rating=#{rating}")
|
62
|
+
_(subject.avatar(rating: rating)).must_include("rating=#{rating}")
|
69
63
|
end
|
70
64
|
end
|
71
65
|
end
|
72
66
|
|
73
67
|
describe 'when asked for unknown rating' do
|
74
68
|
it 'must raise an ArgumentError' do
|
75
|
-
|
76
|
-
subject.avatar rating: 'unknown'
|
77
|
-
end
|
69
|
+
_(-> { subject.avatar rating: 'unknown' }).must_raise ArgumentError
|
78
70
|
end
|
79
71
|
end
|
80
72
|
|
81
73
|
describe 'when asked for forcing default image' do
|
82
74
|
it 'shall provide a forced URI' do
|
83
|
-
subject.avatar(force: true).must_include Gravaty::TEST_FORCED
|
75
|
+
_(subject.avatar(force: true)).must_include Gravaty::TEST_FORCED
|
84
76
|
end
|
85
77
|
end
|
86
78
|
|
87
79
|
Gravaty::DEFAULT_OPTIONS.each do |options|
|
88
80
|
describe "when asked for a specific image options '#{options}'" do
|
89
81
|
it "shall provide an URI with option '#{options}'" do
|
90
|
-
subject.avatar(default: options).must_include("d=#{options}")
|
82
|
+
_(subject.avatar(default: options)).must_include("d=#{options}")
|
91
83
|
end
|
92
84
|
end
|
93
85
|
end
|
@@ -96,26 +88,20 @@ describe Gravaty::Gravaty do
|
|
96
88
|
it 'shall provide a HTTP(S) URI' do
|
97
89
|
['', 's'].each do |type|
|
98
90
|
an_uri = "http#{type}://www.example.com/example.jpg"
|
99
|
-
subject.avatar(default: an_uri).must_include CGI::escape(an_uri)
|
91
|
+
_(subject.avatar(default: an_uri)).must_include CGI::escape(an_uri)
|
100
92
|
end
|
101
93
|
end
|
102
94
|
|
103
95
|
it 'must raise an ArgumentError when URI is not HTTP(S)' do
|
104
|
-
|
105
|
-
subject.avatar default: 'ftp://www.example.com/example.jpg'
|
106
|
-
end
|
96
|
+
_(-> { subject.avatar default: 'ftp://www.example.com/example.jpg' }).must_raise ArgumentError
|
107
97
|
end
|
108
98
|
|
109
99
|
it 'must raise an ArgumentError when image format is not supported' do
|
110
|
-
|
111
|
-
subject.avatar default: 'http://www.example.com/example.svg'
|
112
|
-
end
|
100
|
+
_(-> { subject.avatar default: 'http://www.example.com/example.svg' }).must_raise ArgumentError
|
113
101
|
end
|
114
102
|
|
115
103
|
it 'must raise an ArgumentError when URI contains a query string' do
|
116
|
-
|
117
|
-
subject.avatar default: 'http://www.example.com?image=example.jpg'
|
118
|
-
end
|
104
|
+
_(-> { subject.avatar default: 'http://www.example.com?image=example.jpg' }).must_raise ArgumentError
|
119
105
|
end
|
120
106
|
end
|
121
107
|
end
|