benschwarz-smoke 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/Rakefile +6 -0
  2. data/VERSION.yml +1 -1
  3. metadata +65 -196
  4. data/Gemfile +0 -10
  5. data/bin/edit_json.rb +0 -3
  6. data/bin/restclient +0 -3
  7. data/vendor/gems/cache/crack-0.1.1.gem +0 -0
  8. data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
  9. data/vendor/gems/cache/json-1.1.3.gem +0 -0
  10. data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
  11. data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
  12. data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
  13. data/vendor/gems/environment.rb +0 -83
  14. data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
  15. data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
  16. data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
  17. data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
  18. data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
  19. data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
  20. data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
  21. data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
  22. data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
  23. data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
  24. data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
  25. data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
  26. data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
  27. data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
  28. data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
  29. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
  30. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
  31. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
  32. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
  33. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
  34. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
  35. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
  36. data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
  37. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
  38. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
  39. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
  40. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
  41. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
  42. data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
  43. data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
  44. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
  45. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
  46. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
  47. data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
  48. data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
  49. data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
  50. data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
  51. data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
  52. data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
  53. data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
  54. data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
  55. data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
  56. data/vendor/gems/gems/json-1.1.3/GPL +0 -340
  57. data/vendor/gems/gems/json-1.1.3/README +0 -78
  58. data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
  59. data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
  60. data/vendor/gems/gems/json-1.1.3/TODO +0 -1
  61. data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
  62. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
  63. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
  64. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
  65. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
  66. data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
  67. data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
  68. data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
  69. data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
  70. data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
  71. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
  72. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
  73. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
  74. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
  75. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
  76. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
  77. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
  78. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
  79. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
  80. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
  81. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
  82. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
  83. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
  84. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
  85. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
  86. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
  87. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
  88. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
  89. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
  90. data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
  91. data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
  92. data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
  93. data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
  94. data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
  95. data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
  96. data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
  97. data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
  98. data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
  99. data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
  100. data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
  101. data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
  102. data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
  103. data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
  104. data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
  105. data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
  106. data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
  107. data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
  108. data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
  109. data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
  110. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
  111. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
  112. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
  113. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
  114. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
  115. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
  116. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
  117. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
  118. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
  119. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
  120. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
  121. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
  122. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
  123. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
  124. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
  125. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
  126. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
  127. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
  128. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
  129. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
  130. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
  131. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
  132. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
  133. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
  134. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
  135. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
  136. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
  137. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
  138. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
  139. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
  140. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
  141. data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
  142. data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
  143. data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
  144. data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
  145. data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
  146. data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
  147. data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
  148. data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
  149. data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
  150. data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
  151. data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
  152. data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
  153. data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
  154. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
  155. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
  156. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
  157. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
  158. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
  159. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
  160. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
  161. data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
  162. data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
  163. data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
  164. data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
  165. data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
  166. data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
  167. data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
  168. data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
  169. data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
  170. data/vendor/gems/gems/simple-rss-1.2/README +0 -43
  171. data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
  172. data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
  173. data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
  174. data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
  175. data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
  176. data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
  177. data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
  178. data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
  179. data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
  180. data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
  181. data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
  182. data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
  183. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
  184. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
  185. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
  186. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
  187. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
  188. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
  189. data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
  190. data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
  191. data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
  192. data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
  193. data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
  194. data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class JsonTest < Test::Unit::TestCase
4
- TESTS = {
5
- %q({"data": "G\u00fcnter"}) => {"data" => "Günter"},
6
- %q({"returnTo":{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}},
7
- %q({returnTo:{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}},
8
- %q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}},
9
- %q({"returnTo":{"\/categories":1}}) => {"returnTo" => {"/categories" => 1}},
10
- %({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]},
11
- %({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]},
12
- %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"},
13
- %({a: "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"},
14
- %({a: "2007-01-01"}) => {'a' => Date.new(2007, 1, 1)},
15
- %({a: "2007-01-01 01:12:34 Z"}) => {'a' => Time.utc(2007, 1, 1, 1, 12, 34)},
16
- # no time zone
17
- %({a: "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"},
18
- %([]) => [],
19
- %({}) => {},
20
- %(1) => 1,
21
- %("") => "",
22
- %("\\"") => "\"",
23
- %(null) => nil,
24
- %(true) => true,
25
- %(false) => false,
26
- %q("http:\/\/test.host\/posts\/1") => "http://test.host/posts/1"
27
- }
28
-
29
- TESTS.each do |json, expected|
30
- should "should decode json (#{json})" do
31
- lambda {
32
- Crack::JSON.parse(json).should == expected
33
- }.should_not raise_error
34
- end
35
- end
36
-
37
- should "should raise error for failed decoding" do
38
- lambda {
39
- Crack::JSON.parse(%({: 1}))
40
- }.should raise_error(Crack::ParseError)
41
- end
42
- end
@@ -1,12 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- gem 'jnunemaker-matchy', '>= 0.4.0'
5
- require 'matchy'
6
-
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- $LOAD_PATH.unshift(File.dirname(__FILE__))
9
- require 'crack'
10
-
11
- class Test::Unit::TestCase
12
- end
@@ -1,451 +0,0 @@
1
- require 'test_helper'
2
-
3
- class XmlTest < Test::Unit::TestCase
4
- should "should transform a simple tag with content" do
5
- xml = "<tag>This is the contents</tag>"
6
- Crack::XML.parse(xml).should == { 'tag' => 'This is the contents' }
7
- end
8
-
9
- should "should work with cdata tags" do
10
- xml = <<-END
11
- <tag>
12
- <![CDATA[
13
- text inside cdata
14
- ]]>
15
- </tag>
16
- END
17
- Crack::XML.parse(xml)["tag"].strip.should == "text inside cdata"
18
- end
19
-
20
- should "should transform a simple tag with attributes" do
21
- xml = "<tag attr1='1' attr2='2'></tag>"
22
- hash = { 'tag' => { 'attr1' => '1', 'attr2' => '2' } }
23
- Crack::XML.parse(xml).should == hash
24
- end
25
-
26
- should "should transform repeating siblings into an array" do
27
- xml =<<-XML
28
- <opt>
29
- <user login="grep" fullname="Gary R Epstein" />
30
- <user login="stty" fullname="Simon T Tyson" />
31
- </opt>
32
- XML
33
-
34
- Crack::XML.parse(xml)['opt']['user'].class.should == Array
35
-
36
- hash = {
37
- 'opt' => {
38
- 'user' => [{
39
- 'login' => 'grep',
40
- 'fullname' => 'Gary R Epstein'
41
- },{
42
- 'login' => 'stty',
43
- 'fullname' => 'Simon T Tyson'
44
- }]
45
- }
46
- }
47
-
48
- Crack::XML.parse(xml).should == hash
49
- end
50
-
51
- should "should not transform non-repeating siblings into an array" do
52
- xml =<<-XML
53
- <opt>
54
- <user login="grep" fullname="Gary R Epstein" />
55
- </opt>
56
- XML
57
-
58
- Crack::XML.parse(xml)['opt']['user'].class.should == Hash
59
-
60
- hash = {
61
- 'opt' => {
62
- 'user' => {
63
- 'login' => 'grep',
64
- 'fullname' => 'Gary R Epstein'
65
- }
66
- }
67
- }
68
-
69
- Crack::XML.parse(xml).should == hash
70
- end
71
-
72
- should "should typecast an integer" do
73
- xml = "<tag type='integer'>10</tag>"
74
- Crack::XML.parse(xml)['tag'].should == 10
75
- end
76
-
77
- should "should typecast a true boolean" do
78
- xml = "<tag type='boolean'>true</tag>"
79
- Crack::XML.parse(xml)['tag'].should be(true)
80
- end
81
-
82
- should "should typecast a false boolean" do
83
- ["false"].each do |w|
84
- Crack::XML.parse("<tag type='boolean'>#{w}</tag>")['tag'].should be(false)
85
- end
86
- end
87
-
88
- should "should typecast a datetime" do
89
- xml = "<tag type='datetime'>2007-12-31 10:32</tag>"
90
- Crack::XML.parse(xml)['tag'].should == Time.parse( '2007-12-31 10:32' ).utc
91
- end
92
-
93
- should "should typecast a date" do
94
- xml = "<tag type='date'>2007-12-31</tag>"
95
- Crack::XML.parse(xml)['tag'].should == Date.parse('2007-12-31')
96
- end
97
-
98
- should "should unescape html entities" do
99
- values = {
100
- "<" => "&lt;",
101
- ">" => "&gt;",
102
- '"' => "&quot;",
103
- "'" => "&apos;",
104
- "&" => "&amp;"
105
- }
106
- values.each do |k,v|
107
- xml = "<tag>Some content #{v}</tag>"
108
- Crack::XML.parse(xml)['tag'].should =~ Regexp.new(k)
109
- end
110
- end
111
-
112
- should "should undasherize keys as tags" do
113
- xml = "<tag-1>Stuff</tag-1>"
114
- Crack::XML.parse(xml).keys.should include( 'tag_1' )
115
- end
116
-
117
- should "should undasherize keys as attributes" do
118
- xml = "<tag1 attr-1='1'></tag1>"
119
- Crack::XML.parse(xml)['tag1'].keys.should include( 'attr_1')
120
- end
121
-
122
- should "should undasherize keys as tags and attributes" do
123
- xml = "<tag-1 attr-1='1'></tag-1>"
124
- Crack::XML.parse(xml).keys.should include( 'tag_1' )
125
- Crack::XML.parse(xml)['tag_1'].keys.should include( 'attr_1')
126
- end
127
-
128
- should "should render nested content correctly" do
129
- xml = "<root><tag1>Tag1 Content <em><strong>This is strong</strong></em></tag1></root>"
130
- Crack::XML.parse(xml)['root']['tag1'].should == "Tag1 Content <em><strong>This is strong</strong></em>"
131
- end
132
-
133
- should "should render nested content with splshould text nodes correctly" do
134
- xml = "<root>Tag1 Content<em>Stuff</em> Hi There</root>"
135
- Crack::XML.parse(xml)['root'].should == "Tag1 Content<em>Stuff</em> Hi There"
136
- end
137
-
138
- should "should ignore attributes when a child is a text node" do
139
- xml = "<root attr1='1'>Stuff</root>"
140
- Crack::XML.parse(xml).should == { "root" => "Stuff" }
141
- end
142
-
143
- should "should ignore attributes when any child is a text node" do
144
- xml = "<root attr1='1'>Stuff <em>in italics</em></root>"
145
- Crack::XML.parse(xml).should == { "root" => "Stuff <em>in italics</em>" }
146
- end
147
-
148
- should "should correctly transform multiple children" do
149
- xml = <<-XML
150
- <user gender='m'>
151
- <age type='integer'>35</age>
152
- <name>Home Simpson</name>
153
- <dob type='date'>1988-01-01</dob>
154
- <joined-at type='datetime'>2000-04-28 23:01</joined-at>
155
- <is-cool type='boolean'>true</is-cool>
156
- </user>
157
- XML
158
-
159
- hash = {
160
- "user" => {
161
- "gender" => "m",
162
- "age" => 35,
163
- "name" => "Home Simpson",
164
- "dob" => Date.parse('1988-01-01'),
165
- "joined_at" => Time.parse("2000-04-28 23:01"),
166
- "is_cool" => true
167
- }
168
- }
169
-
170
- Crack::XML.parse(xml).should == hash
171
- end
172
-
173
- should "should properly handle nil values (ActiveSupport Compatible)" do
174
- topic_xml = <<-EOT
175
- <topic>
176
- <title></title>
177
- <id type="integer"></id>
178
- <approved type="boolean"></approved>
179
- <written-on type="date"></written-on>
180
- <viewed-at type="datetime"></viewed-at>
181
- <content type="yaml"></content>
182
- <parent-id></parent-id>
183
- </topic>
184
- EOT
185
-
186
- expected_topic_hash = {
187
- 'title' => nil,
188
- 'id' => nil,
189
- 'approved' => nil,
190
- 'written_on' => nil,
191
- 'viewed_at' => nil,
192
- 'content' => nil,
193
- 'parent_id' => nil
194
- }
195
- Crack::XML.parse(topic_xml)["topic"].should == expected_topic_hash
196
- end
197
-
198
- should "should handle a single record from xml (ActiveSupport Compatible)" do
199
- topic_xml = <<-EOT
200
- <topic>
201
- <title>The First Topic</title>
202
- <author-name>David</author-name>
203
- <id type="integer">1</id>
204
- <approved type="boolean"> true </approved>
205
- <replies-count type="integer">0</replies-count>
206
- <replies-close-in type="integer">2592000000</replies-close-in>
207
- <written-on type="date">2003-07-16</written-on>
208
- <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
209
- <content type="yaml">--- \n1: should be an integer\n:message: Have a nice day\narray: \n- should-have-dashes: true\n should_have_underscores: true\n</content>
210
- <author-email-address>david@loudthinking.com</author-email-address>
211
- <parent-id></parent-id>
212
- <ad-revenue type="decimal">1.5</ad-revenue>
213
- <optimum-viewing-angle type="float">135</optimum-viewing-angle>
214
- <resident type="symbol">yes</resident>
215
- </topic>
216
- EOT
217
-
218
- expected_topic_hash = {
219
- 'title' => "The First Topic",
220
- 'author_name' => "David",
221
- 'id' => 1,
222
- 'approved' => true,
223
- 'replies_count' => 0,
224
- 'replies_close_in' => 2592000000,
225
- 'written_on' => Date.new(2003, 7, 16),
226
- 'viewed_at' => Time.utc(2003, 7, 16, 9, 28),
227
- # Changed this line where the key is :message. The yaml specifies this as a symbol, and who am I to change what you specify
228
- # The line in ActiveSupport is
229
- # 'content' => { 'message' => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
230
- 'content' => { :message => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
231
- 'author_email_address' => "david@loudthinking.com",
232
- 'parent_id' => nil,
233
- 'ad_revenue' => BigDecimal("1.50"),
234
- 'optimum_viewing_angle' => 135.0,
235
- 'resident' => :yes
236
- }
237
-
238
- Crack::XML.parse(topic_xml)["topic"].each do |k,v|
239
- v.should == expected_topic_hash[k]
240
- end
241
- end
242
-
243
- should "should handle multiple records (ActiveSupport Compatible)" do
244
- topics_xml = <<-EOT
245
- <topics type="array">
246
- <topic>
247
- <title>The First Topic</title>
248
- <author-name>David</author-name>
249
- <id type="integer">1</id>
250
- <approved type="boolean">false</approved>
251
- <replies-count type="integer">0</replies-count>
252
- <replies-close-in type="integer">2592000000</replies-close-in>
253
- <written-on type="date">2003-07-16</written-on>
254
- <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
255
- <content>Have a nice day</content>
256
- <author-email-address>david@loudthinking.com</author-email-address>
257
- <parent-id nil="true"></parent-id>
258
- </topic>
259
- <topic>
260
- <title>The Second Topic</title>
261
- <author-name>Jason</author-name>
262
- <id type="integer">1</id>
263
- <approved type="boolean">false</approved>
264
- <replies-count type="integer">0</replies-count>
265
- <replies-close-in type="integer">2592000000</replies-close-in>
266
- <written-on type="date">2003-07-16</written-on>
267
- <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
268
- <content>Have a nice day</content>
269
- <author-email-address>david@loudthinking.com</author-email-address>
270
- <parent-id></parent-id>
271
- </topic>
272
- </topics>
273
- EOT
274
-
275
- expected_topic_hash = {
276
- 'title' => "The First Topic",
277
- 'author_name' => "David",
278
- 'id' => 1,
279
- 'approved' => false,
280
- 'replies_count' => 0,
281
- 'replies_close_in' => 2592000000,
282
- 'written_on' => Date.new(2003, 7, 16),
283
- 'viewed_at' => Time.utc(2003, 7, 16, 9, 28),
284
- 'content' => "Have a nice day",
285
- 'author_email_address' => "david@loudthinking.com",
286
- 'parent_id' => nil
287
- }
288
- # puts Crack::XML.parse(topics_xml)['topics'].first.inspect
289
- Crack::XML.parse(topics_xml)["topics"].first.each do |k,v|
290
- v.should == expected_topic_hash[k]
291
- end
292
- end
293
-
294
- should "should handle a single record from_xml with attributes other than type (ActiveSupport Compatible)" do
295
- topic_xml = <<-EOT
296
- <rsp stat="ok">
297
- <photos page="1" pages="1" perpage="100" total="16">
298
- <photo id="175756086" owner="55569174@N00" secret="0279bf37a1" server="76" title="Colored Pencil PhotoBooth Fun" ispublic="1" isfriend="0" isfamily="0"/>
299
- </photos>
300
- </rsp>
301
- EOT
302
-
303
- expected_topic_hash = {
304
- 'id' => "175756086",
305
- 'owner' => "55569174@N00",
306
- 'secret' => "0279bf37a1",
307
- 'server' => "76",
308
- 'title' => "Colored Pencil PhotoBooth Fun",
309
- 'ispublic' => "1",
310
- 'isfriend' => "0",
311
- 'isfamily' => "0",
312
- }
313
- Crack::XML.parse(topic_xml)["rsp"]["photos"]["photo"].each do |k,v|
314
- v.should == expected_topic_hash[k]
315
- end
316
- end
317
-
318
- should "should handle an emtpy array (ActiveSupport Compatible)" do
319
- blog_xml = <<-XML
320
- <blog>
321
- <posts type="array"></posts>
322
- </blog>
323
- XML
324
- expected_blog_hash = {"blog" => {"posts" => []}}
325
- Crack::XML.parse(blog_xml).should == expected_blog_hash
326
- end
327
-
328
- should "should handle empty array with whitespace from xml (ActiveSupport Compatible)" do
329
- blog_xml = <<-XML
330
- <blog>
331
- <posts type="array">
332
- </posts>
333
- </blog>
334
- XML
335
- expected_blog_hash = {"blog" => {"posts" => []}}
336
- Crack::XML.parse(blog_xml).should == expected_blog_hash
337
- end
338
-
339
- should "should handle array with one entry from_xml (ActiveSupport Compatible)" do
340
- blog_xml = <<-XML
341
- <blog>
342
- <posts type="array">
343
- <post>a post</post>
344
- </posts>
345
- </blog>
346
- XML
347
- expected_blog_hash = {"blog" => {"posts" => ["a post"]}}
348
- Crack::XML.parse(blog_xml).should == expected_blog_hash
349
- end
350
-
351
- should "should handle array with multiple entries from xml (ActiveSupport Compatible)" do
352
- blog_xml = <<-XML
353
- <blog>
354
- <posts type="array">
355
- <post>a post</post>
356
- <post>another post</post>
357
- </posts>
358
- </blog>
359
- XML
360
- expected_blog_hash = {"blog" => {"posts" => ["a post", "another post"]}}
361
- Crack::XML.parse(blog_xml).should == expected_blog_hash
362
- end
363
-
364
- should "should handle file types (ActiveSupport Compatible)" do
365
- blog_xml = <<-XML
366
- <blog>
367
- <logo type="file" name="logo.png" content_type="image/png">
368
- </logo>
369
- </blog>
370
- XML
371
- hash = Crack::XML.parse(blog_xml)
372
- hash.keys.should include('blog')
373
- hash['blog'].keys.should include('logo')
374
-
375
- file = hash['blog']['logo']
376
- file.original_filename.should == 'logo.png'
377
- file.content_type.should == 'image/png'
378
- end
379
-
380
- should "should handle file from xml with defaults (ActiveSupport Compatible)" do
381
- blog_xml = <<-XML
382
- <blog>
383
- <logo type="file">
384
- </logo>
385
- </blog>
386
- XML
387
- file = Crack::XML.parse(blog_xml)['blog']['logo']
388
- file.original_filename.should == 'untitled'
389
- file.content_type.should == 'application/octet-stream'
390
- end
391
-
392
- should "should handle xsd like types from xml (ActiveSupport Compatible)" do
393
- bacon_xml = <<-EOT
394
- <bacon>
395
- <weight type="double">0.5</weight>
396
- <price type="decimal">12.50</price>
397
- <chunky type="boolean"> 1 </chunky>
398
- <expires-at type="dateTime">2007-12-25T12:34:56+0000</expires-at>
399
- <notes type="string"></notes>
400
- <illustration type="base64Binary">YmFiZS5wbmc=</illustration>
401
- </bacon>
402
- EOT
403
-
404
- expected_bacon_hash = {
405
- 'weight' => 0.5,
406
- 'chunky' => true,
407
- 'price' => BigDecimal("12.50"),
408
- 'expires_at' => Time.utc(2007,12,25,12,34,56),
409
- 'notes' => "",
410
- 'illustration' => "babe.png"
411
- }
412
-
413
- Crack::XML.parse(bacon_xml)["bacon"].should == expected_bacon_hash
414
- end
415
-
416
- should "should let type trickle through when unknown (ActiveSupport Compatible)" do
417
- product_xml = <<-EOT
418
- <product>
419
- <weight type="double">0.5</weight>
420
- <image type="ProductImage"><filename>image.gif</filename></image>
421
-
422
- </product>
423
- EOT
424
-
425
- expected_product_hash = {
426
- 'weight' => 0.5,
427
- 'image' => {'type' => 'ProductImage', 'filename' => 'image.gif' },
428
- }
429
-
430
- Crack::XML.parse(product_xml)["product"].should == expected_product_hash
431
- end
432
-
433
- should "should handle unescaping from xml (ActiveResource Compatible)" do
434
- xml_string = '<person><bare-string>First &amp; Last Name</bare-string><pre-escaped-string>First &amp;amp; Last Name</pre-escaped-string></person>'
435
- expected_hash = {
436
- 'bare_string' => 'First & Last Name',
437
- 'pre_escaped_string' => 'First &amp; Last Name'
438
- }
439
-
440
- Crack::XML.parse(xml_string)['person'].should == expected_hash
441
- end
442
-
443
- should "handle an empty xml string" do
444
- Crack::XML.parse('').should == {}
445
- end
446
-
447
- # As returned in the response body by the unfuddle XML API when creating objects
448
- should "handle an xml string containing a single space" do
449
- Crack::XML.parse(' ').should == {}
450
- end
451
- end