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.

Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +587 -0
  3. data/COPYING.md +234 -0
  4. data/Gemfile +17 -0
  5. data/ISSUES.md +40 -0
  6. data/README.md +128 -0
  7. data/Rakefile +48 -0
  8. data/acknowledgements.md +40 -0
  9. data/authors.md +44 -0
  10. data/copyright.md +339 -0
  11. data/examples/avatar.rb +121 -0
  12. data/examples/basics.rb +60 -0
  13. data/examples/profile.rb +143 -0
  14. data/examples/xmlrpc.rb +33 -0
  15. data/gravaty.gemspec +59 -0
  16. data/gravaty.odp +0 -0
  17. data/gravaty.pdf +0 -0
  18. data/html/CHANGELOG.html +876 -0
  19. data/html/COPYING_md.html +803 -0
  20. data/html/Gemfile.html +114 -0
  21. data/html/Gravaty.html +322 -0
  22. data/html/Gravaty/Gravaty.html +997 -0
  23. data/html/Gravaty/ParsableDuckType.html +158 -0
  24. data/html/Gravaty/Parser.html +233 -0
  25. data/html/Gravaty/Parsers.html +94 -0
  26. data/html/Gravaty/Parsers/Avatar.html +166 -0
  27. data/html/Gravaty/Parsers/Callback.html +167 -0
  28. data/html/Gravaty/Parsers/Default.html +174 -0
  29. data/html/Gravaty/Parsers/Force.html +167 -0
  30. data/html/Gravaty/Parsers/Format.html +177 -0
  31. data/html/Gravaty/Parsers/Pixelsize.html +177 -0
  32. data/html/Gravaty/Parsers/Rating.html +177 -0
  33. data/html/Gravaty/Parsers/Secure.html +166 -0
  34. data/html/Gravaty/Parsers/Type.html +177 -0
  35. data/html/Gravaty/Utils.html +107 -0
  36. data/html/Gravaty/Utils/Downloader.html +106 -0
  37. data/html/Gravaty/Utils/Downloader/Downloader.html +224 -0
  38. data/html/Gravaty/Utils/Raisers.html +199 -0
  39. data/html/Gravaty/Utils/Rfc5322.html +149 -0
  40. data/html/Gravaty/Utils/RpcConnector.html +106 -0
  41. data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +241 -0
  42. data/html/ISSUES_md.html +165 -0
  43. data/html/Object.html +183 -0
  44. data/html/README_md.html +436 -0
  45. data/html/Rakefile.html +152 -0
  46. data/html/acknowledgements_md.html +172 -0
  47. data/html/authors_md.html +178 -0
  48. data/html/copyright_md.html +553 -0
  49. data/html/created.rid +59 -0
  50. data/html/css/fonts.css +167 -0
  51. data/html/css/rdoc.css +590 -0
  52. data/html/fonts/Lato-Light.ttf +0 -0
  53. data/html/fonts/Lato-LightItalic.ttf +0 -0
  54. data/html/fonts/Lato-Regular.ttf +0 -0
  55. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  56. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  57. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  58. data/html/gravaty_gemspec.html +162 -0
  59. data/html/images/add.png +0 -0
  60. data/html/images/arrow_up.png +0 -0
  61. data/html/images/brick.png +0 -0
  62. data/html/images/brick_link.png +0 -0
  63. data/html/images/bug.png +0 -0
  64. data/html/images/bullet_black.png +0 -0
  65. data/html/images/bullet_toggle_minus.png +0 -0
  66. data/html/images/bullet_toggle_plus.png +0 -0
  67. data/html/images/date.png +0 -0
  68. data/html/images/delete.png +0 -0
  69. data/html/images/find.png +0 -0
  70. data/html/images/loadingAnimation.gif +0 -0
  71. data/html/images/macFFBgHack.png +0 -0
  72. data/html/images/package.png +0 -0
  73. data/html/images/page_green.png +0 -0
  74. data/html/images/page_white_text.png +0 -0
  75. data/html/images/page_white_width.png +0 -0
  76. data/html/images/plugin.png +0 -0
  77. data/html/images/ruby.png +0 -0
  78. data/html/images/tag_blue.png +0 -0
  79. data/html/images/tag_green.png +0 -0
  80. data/html/images/transparent.png +0 -0
  81. data/html/images/wrench.png +0 -0
  82. data/html/images/wrench_orange.png +0 -0
  83. data/html/images/zoom.png +0 -0
  84. data/html/index.html +467 -0
  85. data/html/js/darkfish.js +161 -0
  86. data/html/js/jquery.js +4 -0
  87. data/html/js/navigation.js +142 -0
  88. data/html/js/navigation.js.gz +0 -0
  89. data/html/js/search.js +109 -0
  90. data/html/js/search_index.js +1 -0
  91. data/html/js/search_index.js.gz +0 -0
  92. data/html/js/searcher.js +229 -0
  93. data/html/js/searcher.js.gz +0 -0
  94. data/html/table_of_contents.html +479 -0
  95. data/lib/gravaty.rb +59 -0
  96. data/lib/gravaty/application.rb +272 -0
  97. data/lib/gravaty/constants.rb +53 -0
  98. data/lib/gravaty/locales/en.yml +34 -0
  99. data/lib/gravaty/locales/it.yml +34 -0
  100. data/lib/gravaty/locales/ja.yml +35 -0
  101. data/lib/gravaty/parser.rb +41 -0
  102. data/lib/gravaty/parsers/avatar.rb +33 -0
  103. data/lib/gravaty/parsers/callback.rb +34 -0
  104. data/lib/gravaty/parsers/default.rb +79 -0
  105. data/lib/gravaty/parsers/force.rb +33 -0
  106. data/lib/gravaty/parsers/format.rb +38 -0
  107. data/lib/gravaty/parsers/pixelsize.rb +38 -0
  108. data/lib/gravaty/parsers/rating.rb +38 -0
  109. data/lib/gravaty/parsers/secure.rb +32 -0
  110. data/lib/gravaty/parsers/type.rb +38 -0
  111. data/lib/gravaty/utils/downloader.rb +150 -0
  112. data/lib/gravaty/utils/raisers.rb +50 -0
  113. data/lib/gravaty/utils/rfc5322.rb +102 -0
  114. data/lib/gravaty/utils/rpc_connector.rb +71 -0
  115. data/lib/gravaty/version.rb +20 -0
  116. data/test/gravaty/locales/test_locales.rb +61 -0
  117. data/test/gravaty/parsers/test_avatar.rb +35 -0
  118. data/test/gravaty/parsers/test_callback.rb +37 -0
  119. data/test/gravaty/parsers/test_default.rb +69 -0
  120. data/test/gravaty/parsers/test_force.rb +35 -0
  121. data/test/gravaty/parsers/test_format.rb +48 -0
  122. data/test/gravaty/parsers/test_pixelsize.rb +50 -0
  123. data/test/gravaty/parsers/test_rating.rb +48 -0
  124. data/test/gravaty/parsers/test_secure.rb +35 -0
  125. data/test/gravaty/parsers/test_type.rb +37 -0
  126. data/test/gravaty/test_application.rb +111 -0
  127. data/test/gravaty/test_avatar.rb +115 -0
  128. data/test/gravaty/test_parsable_duck_type.rb +31 -0
  129. data/test/gravaty/test_parser.rb +55 -0
  130. data/test/gravaty/test_profile.rb +63 -0
  131. data/test/gravaty/utils/test_downloader.rb +43 -0
  132. data/test/gravaty/utils/test_raisers.rb +55 -0
  133. data/test/gravaty/utils/test_rfc5322.rb +58 -0
  134. data/test/gravaty/utils/test_rpc_connector.rb +74 -0
  135. data/test/test_gravaty.rb +44 -0
  136. data/test/test_helper.rb +77 -0
  137. metadata +315 -0
@@ -0,0 +1,35 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ @parser = subject
25
+ end
26
+
27
+ subject { Gravaty::Parsers::Avatar.new }
28
+
29
+ [['avatar/', true], ['', false]].each do |pair|
30
+ it "shall return #{pair[0]} when parameter is #{pair[1]}" do
31
+ subject.parse(pair[1]).must_equal pair[0]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ @parser = subject
25
+ end
26
+
27
+ subject { Gravaty::Parsers::Callback.new }
28
+
29
+ %w(test sample_callback).each do |value|
30
+ [[nil, ''], ['', ''], %W(#{value} callback=#{value})].each do |pair|
31
+ it "shall return #{pair[1]} when parameter is #{pair[0]}" do
32
+ subject.parse(pair[0]).must_equal pair[1]
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,69 @@
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 'cgi'
18
+
19
+ require_relative '../../test_helper'
20
+
21
+ describe Gravaty::Gravaty do
22
+ describe 'when using a parser' do
23
+ include Gravaty::ParsableDuckType
24
+
25
+ before do
26
+ I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
27
+ @parser = subject
28
+ end
29
+
30
+ subject { Gravaty::Parsers::Default.new }
31
+
32
+ Gravaty::DEFAULT_OPTIONS.each do |value|
33
+ [[nil, ''], ['', ''], %W(#{value} d=#{value})].each do |pair|
34
+ it "shall return #{pair[1]} when parameter is #{pair[0]}" do
35
+ subject.parse(pair[0]).must_equal pair[1]
36
+ end
37
+ end
38
+ end
39
+
40
+ Gravaty::IMAGES_FORMATS.each do |extension|
41
+ value = "http://www.example.com/images/example.#{extension}"
42
+ escaped = "d=#{CGI::escape(value)}"
43
+
44
+ it "shall return #{escaped} when parameter is #{value}" do
45
+ subject.parse(value).must_equal escaped
46
+ end
47
+ end
48
+
49
+ it 'shall raise an exception when provided with an invalid default URI image URI' do
50
+ begin
51
+ subject.parse('http://www.example.com/images/example.svg').must_raise ArgumentError
52
+ rescue ArgumentError => aErr
53
+ aErr.wont_be_nil
54
+ aErr.message.wont_be_nil
55
+ aErr.message.wont_be_empty
56
+ end
57
+ end
58
+
59
+ it 'shall raise an exception when provided with an invalid default URI image URI' do
60
+ begin
61
+ subject.parse('svg').must_raise ArgumentError
62
+ rescue ArgumentError => aErr
63
+ aErr.wont_be_nil
64
+ aErr.message.wont_be_nil
65
+ aErr.message.wont_be_empty
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,35 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ @parser = subject
25
+ end
26
+
27
+ subject { Gravaty::Parsers::Force.new }
28
+
29
+ [['f=y', true], ['', false]].each do |pair|
30
+ it "shall return #{pair[0]} when parameter is #{pair[1]}" do
31
+ subject.parse(pair[1]).must_equal pair[0]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,48 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
25
+ @parser = subject
26
+ end
27
+
28
+ subject { Gravaty::Parsers::Format.new }
29
+
30
+ Gravaty::PROFILE_FORMATS.each do |value|
31
+ [[nil, ''], %W(#{value} .#{value.downcase})].each do |pair|
32
+ it "shall return #{pair[1]} when parameter is #{pair[0]}" do
33
+ subject.parse(pair[0]).must_equal pair[1]
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'shall raise an exception when provided with an invalid default image extension' do
39
+ begin
40
+ subject.parse('svg').must_raise ArgumentError
41
+ rescue ArgumentError => aErr
42
+ aErr.wont_be_nil
43
+ aErr.message.wont_be_nil
44
+ aErr.message.wont_be_empty
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,50 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
25
+ @parser = subject
26
+ end
27
+
28
+ subject { Gravaty::Parsers::Pixelsize.new }
29
+
30
+ it 'shall return nothing when parameter is nil' do
31
+ subject.parse(nil).must_be_empty
32
+ end
33
+
34
+ Gravaty::ALLOWED_SIZES.each do |value|
35
+ it "shall return s=#{value.to_s} when parameter is #{value}" do
36
+ subject.parse(value).must_equal "s=#{value.to_s}"
37
+ end
38
+ end
39
+
40
+ it 'shall raise an exception when provided with an invalid rating' do
41
+ begin
42
+ subject.parse(0).must_raise ArgumentError
43
+ rescue ArgumentError => aErr
44
+ aErr.wont_be_nil
45
+ aErr.message.wont_be_nil
46
+ aErr.message.wont_be_empty
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,48 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
25
+ @parser = subject
26
+ end
27
+
28
+ subject { Gravaty::Parsers::Rating.new }
29
+
30
+ Gravaty::RATING_OPTIONS.each do |value|
31
+ [[nil, ''], %W(#{value} rating=#{value.downcase})].each do |pair|
32
+ it "shall return #{pair[1]} when parameter is #{pair[0]}" do
33
+ subject.parse(pair[0]).must_equal pair[1]
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'shall raise an exception when provided with an invalid rating' do
39
+ begin
40
+ subject.parse('xxx').must_raise ArgumentError
41
+ rescue ArgumentError => aErr
42
+ aErr.wont_be_nil
43
+ aErr.message.wont_be_nil
44
+ aErr.message.wont_be_empty
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ @parser = subject
25
+ end
26
+
27
+ subject { Gravaty::Parsers::Secure.new }
28
+
29
+ [['https://secure', true], ['http://www', false]].each do |pair|
30
+ it "shall return #{pair[0]} when parameter is #{pair[1]}" do
31
+ subject.parse(pair[1]).must_equal pair[0]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
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
+ include Gravaty::ParsableDuckType
22
+
23
+ before do
24
+ I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')]
25
+ end
26
+
27
+ subject { Gravaty::Parsers::Type.new }
28
+
29
+ Gravaty::AVATAR_FORMATS.each do |value|
30
+ [[nil, ''], %W(#{value} .#{value.downcase})].each do |pair|
31
+ it "shall return #{pair[1]} when parameter is #{pair[0]}" do
32
+ subject.parse(pair[0]).must_equal pair[1]
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,111 @@
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
+ it 'shall return the email content on demand' do
25
+ subject.email.must_equal Gravaty::TEST_MY_ADDRESS.downcase
26
+ end
27
+
28
+ it 'shall return the digest content on demand' do
29
+ subject.digest.must_equal Gravaty::TEST_MY_MD5
30
+ end
31
+
32
+ it 'shall return a valid string' do
33
+ subject.to_s.wont_be_nil
34
+ end
35
+
36
+ it 'shall return a valid JSON' do
37
+ subject.to_json.wont_be_nil
38
+ JSON.parse(subject.to_json).wont_be_nil
39
+ end
40
+
41
+ [:avatar, :profile].each do |method|
42
+ describe "when asked for #{method} " do
43
+ describe 'when no parameters are provided' do
44
+ it 'shall provide an URI' do
45
+ subject.send(method).must_match Gravaty::TEST_SIMPLE_URI_REGEXP
46
+ end
47
+
48
+ it "shall provide a #{method} URI" do
49
+ subject.send(method).must_include Gravaty::TEST_STRING[method]
50
+ end
51
+
52
+ it "shall provide a #{method} with a secure URI" do
53
+ subject.send(method).must_match Gravaty::TEST_SECURE_URI_REGEXP
54
+ subject.send(method).wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
55
+ end
56
+ end
57
+
58
+ describe 'when nil is provided' do
59
+ it 'shall provide an URI' do
60
+ subject.send(method, nil).must_match Gravaty::TEST_SIMPLE_URI_REGEXP
61
+ end
62
+
63
+ it "shall provide a #{method} URI" do
64
+ subject.send(method, nil).must_include Gravaty::TEST_STRING[method]
65
+ end
66
+
67
+ it "shall provide a #{method} with a secure URI" do
68
+ subject.send(method, nil).must_match Gravaty::TEST_SECURE_URI_REGEXP
69
+ subject.send(method, nil).wont_match Gravaty::TEST_UNSECURE_URI_REGEXP
70
+ end
71
+
72
+ end
73
+
74
+ describe 'when secure:false is provided' do
75
+ it "shall provide a #{method} with an unsecure URI" do
76
+ subject.send(method, secure: false).wont_match Gravaty::TEST_SECURE_URI_REGEXP
77
+ subject.send(method, secure: false).must_match Gravaty::TEST_UNSECURE_URI_REGEXP
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ it 'shall provide the XML-RPC API interface' do
84
+ subject.must_respond_to :xmlrpc
85
+ end
86
+
87
+ describe 'when asked for nil method' do
88
+ it 'must raise an ArgumentError' do
89
+ assert_raises ArgumentError do
90
+ subject.xmlrpc(nil)
91
+ end
92
+ end
93
+ end
94
+
95
+ describe 'when asked for an unsupported method' do
96
+ it 'must raise an ArgumentError' do
97
+ assert_raises ArgumentError do
98
+ subject.xmlrpc('my_method', 'my_password')
99
+ end
100
+ end
101
+ end
102
+
103
+ describe 'when asked for a valid method with a nil password' do
104
+ it 'must raise an ArgumentError' do
105
+ assert_raises ArgumentError do
106
+ subject.xmlrpc('my_method')
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end