multi_xml 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
+ --fail-fast
2
3
  --order random
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
- matrix:
3
- allow_failures:
4
- - rvm: ruby-head
5
2
  rvm:
6
3
  - 1.8.7
7
4
  - 1.9.2
8
5
  - 1.9.3
9
6
  - ruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
@@ -0,0 +1,49 @@
1
+ ## Contributing
2
+ In the spirit of [free software][free-sw] , **everyone** is encouraged to help
3
+ improve this project.
4
+
5
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
6
+
7
+ Here are some ways *you* can contribute:
8
+
9
+ * by using alpha, beta, and prerelease versions
10
+ * by reporting bugs
11
+ * by suggesting new features
12
+ * by writing or editing documentation
13
+ * by writing specifications
14
+ * by writing code (**no patch is too small**: fix typos, add comments, clean up
15
+ inconsistent whitespace)
16
+ * by refactoring code
17
+ * by resolving [issues][]
18
+ * by reviewing patches
19
+
20
+ [issues]: https://github.com/sferik/multi_xml/issues
21
+
22
+ ## Submitting an Issue
23
+ We use the [GitHub issue tracker][issues] to track bugs and features. Before
24
+ submitting a bug report or feature request, check to make sure it hasn't
25
+ already been submitted. When submitting a bug report, please include a [Gist][]
26
+ that includes a stack trace and any details that may be necessary to reproduce
27
+ the bug, including your gem version, Ruby version, and operating system.
28
+ Ideally, a bug report should include a pull request with failing specs.
29
+
30
+ [gist]: https://gist.github.com/
31
+
32
+ ## Submitting a Pull Request
33
+ 1. [Fork the repository.][fork]
34
+ 2. [Create a topic branch.][branch]
35
+ 3. Add specs for your unimplemented feature or bug fix.
36
+ 4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
37
+ 5. Implement your feature or bug fix.
38
+ 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
39
+ 7. Run `open coverage/index.html`. If your changes are not completely covered
40
+ by your tests, return to step 3.
41
+ 8. Add documentation for your feature or bug fix.
42
+ 9. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
43
+ back to step 8.
44
+ 10. Add, commit, and push your changes.
45
+ 11. [Submit a pull request.][pr]
46
+
47
+ [fork]: http://help.github.com/fork-a-repo/
48
+ [branch]: http://learn.github.com/p/branching.html
49
+ [pr]: http://help.github.com/send-pull-requests/
data/README.md CHANGED
@@ -17,24 +17,25 @@ Lots of Ruby libraries utilize XML parsing in some form, and everyone has their
17
17
  favorite XML library. In order to best support multiple XML parsers and
18
18
  libraries, `multi_xml` is a general-purpose swappable XML backend library. You
19
19
  use it like so:
20
+ ```ruby
21
+ require 'multi_xml'
20
22
 
21
- require 'multi_xml'
23
+ MultiXml.parser = :ox
24
+ MultiXml.parser = MultiXml::Parsers::Ox # Same as above
25
+ MultiXml.parse('<tag>This is the contents</tag>') # Parsed using Ox
22
26
 
23
- MultiXml.parser = :ox MultiXml.parser = MultiXml::Parsers::Ox # Same as
24
- above MultiXml.parse('<tag>This is the contents</tag>') # Parsed using Ox
27
+ MultiXml.parser = :libxml
28
+ MultiXml.parser = MultiXml::Parsers::Libxml # Same as above
29
+ MultiXml.parse('<tag>This is the contents</tag>') # Parsed using LibXML
25
30
 
26
- MultiXml.parser = :libxml MultiXml.parser = MultiXml::Parsers::Libxml #
27
- Same as above MultiXml.parse('<tag>This is the contents</tag>') # Parsed
28
- using LibXML
29
-
30
- MultiXml.parser = :nokogiri MultiXml.parser = MultiXml::Parsers::Nokogiri #
31
- Same as above MultiXml.parse('<tag>This is the contents</tag>') # Parsed
32
- using Nokogiri
33
-
34
- MultiXml.parser = :rexml MultiXml.parser = MultiXml::Parsers::Rexml # Same
35
- as above MultiXml.parse('<tag>This is the contents</tag>') # Parsed using
36
- REXML
31
+ MultiXml.parser = :nokogiri
32
+ MultiXml.parser = MultiXml::Parsers::Nokogiri # Same as above
33
+ MultiXml.parse('<tag>This is the contents</tag>') # Parsed using Nokogiri
37
34
 
35
+ MultiXml.parser = :rexml
36
+ MultiXml.parser = MultiXml::Parsers::Rexml # Same as above
37
+ MultiXml.parse('<tag>This is the contents</tag>') # Parsed using REXML
38
+ ```
38
39
  The `parser` setter takes either a symbol or a class (to allow for custom XML
39
40
  parsers) that responds to `.parse` at the class level.
40
41
 
@@ -43,56 +44,6 @@ supported parsers already loaded, it will utilize them before attempting to
43
44
  load any. When loading, libraries are ordered by speed: first Ox, then LibXML,
44
45
  then Nokogiri, and finally REXML.
45
46
 
46
- ## Contributing
47
- In the spirit of [free software][free-sw] , **everyone** is encouraged to help
48
- improve this project.
49
-
50
- [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
51
-
52
- Here are some ways *you* can contribute:
53
-
54
- * by using alpha, beta, and prerelease versions
55
- * by reporting bugs
56
- * by suggesting new features
57
- * by writing or editing documentation
58
- * by writing specifications
59
- * by writing code (**no patch is too small**: fix typos, add comments, clean up
60
- inconsistent whitespace)
61
- * by refactoring code
62
- * by resolving [issues][]
63
- * by reviewing patches
64
-
65
- [issues]: https://github.com/sferik/multi_xml/issues
66
-
67
- ## Submitting an Issue
68
- We use the [GitHub issue tracker][issues] to track bugs and features. Before
69
- submitting a bug report or feature request, check to make sure it hasn't
70
- already been submitted. When submitting a bug report, please include a [Gist][]
71
- that includes a stack trace and any details that may be necessary to reproduce
72
- the bug, including your gem version, Ruby version, and operating system.
73
- Ideally, a bug report should include a pull request with failing specs.
74
-
75
- [gist]: https://gist.github.com/
76
-
77
- ## Submitting a Pull Request
78
- 1. [Fork the repository.][fork]
79
- 2. [Create a topic branch.][branch]
80
- 3. Add specs for your unimplemented feature or bug fix.
81
- 4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
82
- 5. Implement your feature or bug fix.
83
- 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
84
- 7. Run `open coverage/index.html`. If your changes are not completely covered
85
- by your tests, return to step 3.
86
- 8. Add documentation for your feature or bug fix.
87
- 9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
88
- back to step 8.
89
- 10. Add, commit, and push your changes.
90
- 11. [Submit a pull request.][pr]
91
-
92
- [fork]: http://help.github.com/fork-a-repo/
93
- [branch]: http://learn.github.com/p/branching.html
94
- [pr]: http://help.github.com/send-pull-requests/
95
-
96
47
  ## Supported Ruby Versions
97
48
  This library aims to support and is [tested against][travis] the following Ruby
98
49
  implementations:
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ task :default => :spec
10
10
  namespace :doc do
11
11
  require 'yard'
12
12
  YARD::Rake::YardocTask.new do |task|
13
- task.files = ['LICENSE.md', 'lib/**/*.rb']
13
+ task.files = ['lib/**/*.rb', '-', 'LICENSE.md']
14
14
  task.options = [
15
15
  '--no-private',
16
16
  '--protected',
@@ -7,6 +7,11 @@ require 'yaml'
7
7
 
8
8
  module MultiXml
9
9
  class ParseError < StandardError; end
10
+ class DisallowedTypeError < StandardError
11
+ def initialize(type)
12
+ super "Disallowed type attribute: #{type.inspect}"
13
+ end
14
+ end
10
15
 
11
16
  REQUIREMENT_MAP = [
12
17
  ['ox', :ox],
@@ -54,6 +59,8 @@ module MultiXml
54
59
  'Hash' => 'hash'
55
60
  } unless defined?(TYPE_NAMES)
56
61
 
62
+ DISALLOWED_XML_TYPES = %w(symbol yaml)
63
+
57
64
  class << self
58
65
  # Get the current parser class.
59
66
  def parser
@@ -105,6 +112,8 @@ module MultiXml
105
112
  # <b>Options</b>
106
113
  #
107
114
  # <tt>:symbolize_keys</tt> :: If true, will use symbols instead of strings for the keys.
115
+ #
116
+ # <tt>:disallowed_types</tt> :: Types to disallow from being typecasted. Defaults to `['yaml', 'symbol']`. Use `[]` to allow all types.
108
117
  def parse(xml, options={})
109
118
  xml ||= ''
110
119
 
@@ -116,7 +125,9 @@ module MultiXml
116
125
  return {} if char.nil?
117
126
  xml.ungetc(char)
118
127
 
119
- hash = typecast_xml_value(undasherize_keys(parser.parse(xml))) || {}
128
+ hash = typecast_xml_value(undasherize_keys(parser.parse(xml)), options[:disallowed_types]) || {}
129
+ rescue DisallowedTypeError
130
+ raise
120
131
  rescue parser.parse_error => error
121
132
  raise ParseError, error.to_s, error.backtrace
122
133
  end
@@ -191,9 +202,15 @@ module MultiXml
191
202
  end
192
203
  end
193
204
 
194
- def typecast_xml_value(value)
205
+ def typecast_xml_value(value, disallowed_types=nil)
206
+ disallowed_types ||= DISALLOWED_XML_TYPES
207
+
195
208
  case value
196
209
  when Hash
210
+ if value.include?('type') && !value['type'].is_a?(Hash) && disallowed_types.include?(value['type'])
211
+ raise DisallowedTypeError, value['type']
212
+ end
213
+
197
214
  if value['type'] == 'array'
198
215
 
199
216
  # this commented-out suggestion helps to avoid the multiple attribute
@@ -216,9 +233,9 @@ module MultiXml
216
233
  else
217
234
  case entries
218
235
  when Array
219
- entries.map {|entry| typecast_xml_value(entry)}
236
+ entries.map {|entry| typecast_xml_value(entry, disallowed_types)}
220
237
  when Hash
221
- [typecast_xml_value(entries)]
238
+ [typecast_xml_value(entries, disallowed_types)]
222
239
  else
223
240
  raise "can't typecast #{entries.class.name}: #{entries.inspect}"
224
241
  end
@@ -252,7 +269,7 @@ module MultiXml
252
269
  nil
253
270
  else
254
271
  xml_value = value.inject({}) do |hash, (k, v)|
255
- hash[k] = typecast_xml_value(v)
272
+ hash[k] = typecast_xml_value(v, disallowed_types)
256
273
  hash
257
274
  end
258
275
 
@@ -261,7 +278,7 @@ module MultiXml
261
278
  xml_value['file'].is_a?(StringIO) ? xml_value['file'] : xml_value
262
279
  end
263
280
  when Array
264
- value.map!{|i| typecast_xml_value(i)}
281
+ value.map!{|i| typecast_xml_value(i, disallowed_types)}
265
282
  value.length > 1 ? value : value.first
266
283
  when String
267
284
  value
@@ -1,3 +1,3 @@
1
1
  module MultiXml
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -1,21 +1,22 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path('../lib/multi_xml/version', __FILE__)
3
3
 
4
- Gem::Specification.new do |gem|
5
- gem.add_development_dependency 'maruku'
6
- gem.add_development_dependency 'rake'
7
- gem.add_development_dependency 'rspec'
8
- gem.add_development_dependency 'simplecov'
9
- gem.add_development_dependency 'yard'
10
- gem.author = "Erik Michaels-Ober"
11
- gem.description = %q{A gem to provide swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML.}
12
- gem.email = 'sferik@gmail.com'
13
- gem.files = `git ls-files`.split("\n")
14
- gem.homepage = 'https://github.com/sferik/multi_xml'
15
- gem.name = 'multi_xml'
16
- gem.platform = Gem::Platform::RUBY
17
- gem.require_paths = ['lib']
18
- gem.summary = %q{A generic swappable back-end for XML parsing}
19
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- gem.version = MultiXml::VERSION
4
+ Gem::Specification.new do |spec|
5
+ spec.add_development_dependency 'kramdown'
6
+ spec.add_development_dependency 'rake'
7
+ spec.add_development_dependency 'rspec'
8
+ spec.add_development_dependency 'simplecov'
9
+ spec.add_development_dependency 'yard'
10
+ spec.author = "Erik Michaels-Ober"
11
+ spec.description = %q{Provides swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML.}
12
+ spec.email = 'sferik@gmail.com'
13
+ spec.files = `git ls-files`.split("\n")
14
+ spec.homepage = 'https://github.com/sferik/multi_xml'
15
+ spec.licenses = ['MIT']
16
+ spec.name = 'multi_xml'
17
+ spec.platform = Gem::Platform::RUBY
18
+ spec.require_paths = ['lib']
19
+ spec.summary = %q{A generic swappable back-end for XML parsing}
20
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ spec.version = MultiXml::VERSION
21
22
  end
@@ -4,4 +4,12 @@ unless ENV['CI']
4
4
  add_filter 'spec'
5
5
  end
6
6
  end
7
+
7
8
  require 'multi_xml'
9
+ require 'rspec'
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
@@ -5,28 +5,28 @@ class MockDecoder; end
5
5
 
6
6
  describe "MultiXml" do
7
7
  context "Parsers" do
8
- it "should pick a default parser" do
9
- MultiXml.parser.should be_kind_of(Module)
10
- MultiXml.parser.should respond_to(:parse)
8
+ it "picks a default parser" do
9
+ expect(MultiXml.parser).to be_kind_of(Module)
10
+ expect(MultiXml.parser).to respond_to(:parse)
11
11
  end
12
12
 
13
- it "should default to the best available gem" do
13
+ it "defaults to the best available gem" do
14
14
  pending
15
- MultiXml.parser.name.should be == 'MultiXml::Parsers::Rexml'
15
+ expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Rexml')
16
16
  require 'nokogiri'
17
- MultiXml.parser.name.should be == 'MultiXml::Parsers::Nokogiri'
17
+ expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Nokogiri')
18
18
  require 'libxml'
19
- MultiXml.parser.name.should == 'MultiXml::Parsers::Libxml'
19
+ expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Libxml')
20
20
  end
21
21
 
22
- it "should be settable via a symbol" do
22
+ it "is settable via a symbol" do
23
23
  MultiXml.parser = :nokogiri
24
- MultiXml.parser.name.should == 'MultiXml::Parsers::Nokogiri'
24
+ expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Nokogiri')
25
25
  end
26
26
 
27
- it "should be settable via a class" do
27
+ it "is settable via a class" do
28
28
  MultiXml.parser = MockDecoder
29
- MultiXml.parser.name.should == 'MockDecoder'
29
+ expect(MultiXml.parser.name).to eq('MockDecoder')
30
30
  end
31
31
  end
32
32
 
@@ -37,7 +37,7 @@ describe "MultiXml" do
37
37
  begin
38
38
  require parser.last
39
39
  context "#{parser.first} parser" do
40
- it_should_behave_like "a parser", parser.first
40
+ it_behaves_like "a parser", parser.first
41
41
  end
42
42
  rescue LoadError => e
43
43
  puts "Tests not run for #{parser.first} due to a LoadError"
@@ -14,8 +14,8 @@ shared_examples_for "a parser" do |parser|
14
14
  @xml = ''
15
15
  end
16
16
 
17
- it "should return an empty Hash" do
18
- MultiXml.parse(@xml).should == {}
17
+ it "returns an empty Hash" do
18
+ expect(MultiXml.parse(@xml)).to eq({})
19
19
  end
20
20
  end
21
21
 
@@ -24,8 +24,8 @@ shared_examples_for "a parser" do |parser|
24
24
  @xml = ' '
25
25
  end
26
26
 
27
- it "should return an empty Hash" do
28
- MultiXml.parse(@xml).should == {}
27
+ it "returns an empty Hash" do
28
+ expect(MultiXml.parse(@xml)).to eq({})
29
29
  end
30
30
  end
31
31
 
@@ -34,10 +34,8 @@ shared_examples_for "a parser" do |parser|
34
34
  @xml = '<open></close>'
35
35
  end
36
36
 
37
- it "should raise MultiXml::ParseError" do
38
- lambda do
39
- MultiXml.parse(@xml)
40
- end.should raise_error(MultiXml::ParseError)
37
+ it "raises MultiXml::ParseError" do
38
+ expect{MultiXml.parse(@xml)}.to raise_error(MultiXml::ParseError)
41
39
  end
42
40
  end
43
41
 
@@ -46,8 +44,8 @@ shared_examples_for "a parser" do |parser|
46
44
  @xml = '<user/>'
47
45
  end
48
46
 
49
- it "should parse correctly" do
50
- MultiXml.parse(@xml).should == {'user' => nil}
47
+ it "parses correctly" do
48
+ expect(MultiXml.parse(@xml)).to eq({'user' => nil})
51
49
  end
52
50
 
53
51
  context "with CDATA" do
@@ -55,8 +53,8 @@ shared_examples_for "a parser" do |parser|
55
53
  @xml = '<user><![CDATA[Erik Michaels-Ober]]></user>'
56
54
  end
57
55
 
58
- it "should return the correct CDATA" do
59
- MultiXml.parse(@xml)['user'].should == "Erik Michaels-Ober"
56
+ it "returns the correct CDATA" do
57
+ expect(MultiXml.parse(@xml)['user']).to eq("Erik Michaels-Ober")
60
58
  end
61
59
  end
62
60
 
@@ -65,8 +63,8 @@ shared_examples_for "a parser" do |parser|
65
63
  @xml = '<user>Erik Michaels-Ober</user>'
66
64
  end
67
65
 
68
- it "should return the correct content" do
69
- MultiXml.parse(@xml)['user'].should == "Erik Michaels-Ober"
66
+ it "returns the correct content" do
67
+ expect(MultiXml.parse(@xml)['user']).to eq("Erik Michaels-Ober")
70
68
  end
71
69
  end
72
70
 
@@ -75,8 +73,8 @@ shared_examples_for "a parser" do |parser|
75
73
  @xml = '<user name="Erik Michaels-Ober"/>'
76
74
  end
77
75
 
78
- it "should return the correct attribute" do
79
- MultiXml.parse(@xml)['user']['name'].should == "Erik Michaels-Ober"
76
+ it "returns the correct attribute" do
77
+ expect(MultiXml.parse(@xml)['user']['name']).to eq("Erik Michaels-Ober")
80
78
  end
81
79
  end
82
80
 
@@ -85,9 +83,9 @@ shared_examples_for "a parser" do |parser|
85
83
  @xml = '<user name="Erik Michaels-Ober" screen_name="sferik"/>'
86
84
  end
87
85
 
88
- it "should return the correct attributes" do
89
- MultiXml.parse(@xml)['user']['name'].should be == "Erik Michaels-Ober"
90
- MultiXml.parse(@xml)['user']['screen_name'].should be == "sferik"
86
+ it "returns the correct attributes" do
87
+ expect(MultiXml.parse(@xml)['user']['name']).to eq("Erik Michaels-Ober")
88
+ expect(MultiXml.parse(@xml)['user']['screen_name']).to eq("sferik")
91
89
  end
92
90
  end
93
91
 
@@ -96,8 +94,8 @@ shared_examples_for "a parser" do |parser|
96
94
  @xml = '<user><name>Erik Michaels-Ober</name></user>'
97
95
  end
98
96
 
99
- it "should symbolize keys" do
100
- MultiXml.parse(@xml, :symbolize_keys => true).should == {:user => {:name => "Erik Michaels-Ober"}}
97
+ it "symbolizes keys" do
98
+ expect(MultiXml.parse(@xml, :symbolize_keys => true)).to eq({:user => {:name => "Erik Michaels-Ober"}})
101
99
  end
102
100
  end
103
101
 
@@ -107,8 +105,8 @@ shared_examples_for "a parser" do |parser|
107
105
  @xml = '<tag>true</tag>'
108
106
  end
109
107
 
110
- it "should return true" do
111
- MultiXml.parse(@xml)['tag'].should be_true
108
+ it "returns true" do
109
+ expect(MultiXml.parse(@xml)['tag']).to be_true
112
110
  end
113
111
  end
114
112
 
@@ -118,8 +116,8 @@ shared_examples_for "a parser" do |parser|
118
116
  @xml = '<tag>false</tag>'
119
117
  end
120
118
 
121
- it "should return false" do
122
- MultiXml.parse(@xml)['tag'].should be_false
119
+ it "returns false" do
120
+ expect(MultiXml.parse(@xml)['tag']).to be_false
123
121
  end
124
122
  end
125
123
 
@@ -129,12 +127,12 @@ shared_examples_for "a parser" do |parser|
129
127
  @xml = '<id>1</id>'
130
128
  end
131
129
 
132
- it "should return a Fixnum" do
133
- MultiXml.parse(@xml)['id'].should be_a(Fixnum)
130
+ it "returns a Fixnum" do
131
+ expect(MultiXml.parse(@xml)['id']).to be_a(Fixnum)
134
132
  end
135
133
 
136
- it "should return the correct number" do
137
- MultiXml.parse(@xml)['id'].should == 1
134
+ it "returns the correct number" do
135
+ expect(MultiXml.parse(@xml)['id']).to eq(1)
138
136
  end
139
137
  end
140
138
 
@@ -144,21 +142,21 @@ shared_examples_for "a parser" do |parser|
144
142
  @xml = '<tag_id>1</tag_id>'
145
143
  end
146
144
 
147
- it "should return a Fixnum" do
148
- MultiXml.parse(@xml)['tag_id'].should be_a(Fixnum)
145
+ it "returns a Fixnum" do
146
+ expect(MultiXml.parse(@xml)['tag_id']).to be_a(Fixnum)
149
147
  end
150
148
 
151
- it "should return the correct number" do
152
- MultiXml.parse(@xml)['tag_id'].should == 1
149
+ it "returns the correct number" do
150
+ expect(MultiXml.parse(@xml)['tag_id']).to eq(1)
153
151
  end
154
152
  end
155
153
 
156
154
  context "with an attribute type=\"boolean\"" do
157
155
  %w(true false).each do |boolean|
158
156
  context "when #{boolean}" do
159
- it "should return #{boolean}" do
157
+ it "returns #{boolean}" do
160
158
  xml = "<tag type=\"boolean\">#{boolean}</tag>"
161
- MultiXml.parse(xml)['tag'].should instance_eval("be_#{boolean}")
159
+ expect(MultiXml.parse(xml)['tag']).to instance_eval("be_#{boolean}")
162
160
  end
163
161
  end
164
162
  end
@@ -168,8 +166,8 @@ shared_examples_for "a parser" do |parser|
168
166
  @xml = '<tag type="boolean">1</tag>'
169
167
  end
170
168
 
171
- it "should return true" do
172
- MultiXml.parse(@xml)['tag'].should be_true
169
+ it "returns true" do
170
+ expect(MultiXml.parse(@xml)['tag']).to be_true
173
171
  end
174
172
  end
175
173
 
@@ -178,8 +176,8 @@ shared_examples_for "a parser" do |parser|
178
176
  @xml = '<tag type="boolean">0</tag>'
179
177
  end
180
178
 
181
- it "should return false" do
182
- MultiXml.parse(@xml)['tag'].should be_false
179
+ it "returns false" do
180
+ expect(MultiXml.parse(@xml)['tag']).to be_false
183
181
  end
184
182
  end
185
183
  end
@@ -190,16 +188,16 @@ shared_examples_for "a parser" do |parser|
190
188
  @xml = '<tag type="integer">1</tag>'
191
189
  end
192
190
 
193
- it "should return a Fixnum" do
194
- MultiXml.parse(@xml)['tag'].should be_a(Fixnum)
191
+ it "returns a Fixnum" do
192
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Fixnum)
195
193
  end
196
194
 
197
- it "should return a positive number" do
198
- MultiXml.parse(@xml)['tag'].should > 0
195
+ it "returns a positive number" do
196
+ expect(MultiXml.parse(@xml)['tag']).to be > 0
199
197
  end
200
198
 
201
- it "should return the correct number" do
202
- MultiXml.parse(@xml)['tag'].should == 1
199
+ it "returns the correct number" do
200
+ expect(MultiXml.parse(@xml)['tag']).to eq(1)
203
201
  end
204
202
  end
205
203
 
@@ -208,16 +206,16 @@ shared_examples_for "a parser" do |parser|
208
206
  @xml = '<tag type="integer">-1</tag>'
209
207
  end
210
208
 
211
- it "should return a Fixnum" do
212
- MultiXml.parse(@xml)['tag'].should be_a(Fixnum)
209
+ it "returns a Fixnum" do
210
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Fixnum)
213
211
  end
214
212
 
215
- it "should return a negative number" do
216
- MultiXml.parse(@xml)['tag'].should < 0
213
+ it "returns a negative number" do
214
+ expect(MultiXml.parse(@xml)['tag']).to be < 0
217
215
  end
218
216
 
219
- it "should return the correct number" do
220
- MultiXml.parse(@xml)['tag'].should == -1
217
+ it "returns the correct number" do
218
+ expect(MultiXml.parse(@xml)['tag']).to eq(-1)
221
219
  end
222
220
  end
223
221
  end
@@ -227,12 +225,12 @@ shared_examples_for "a parser" do |parser|
227
225
  @xml = '<tag type="string"></tag>'
228
226
  end
229
227
 
230
- it "should return a String" do
231
- MultiXml.parse(@xml)['tag'].should be_a(String)
228
+ it "returns a String" do
229
+ expect(MultiXml.parse(@xml)['tag']).to be_a(String)
232
230
  end
233
231
 
234
- it "should return the correct string" do
235
- MultiXml.parse(@xml)['tag'].should == ""
232
+ it "returns the correct string" do
233
+ expect(MultiXml.parse(@xml)['tag']).to eq("")
236
234
  end
237
235
  end
238
236
 
@@ -241,12 +239,12 @@ shared_examples_for "a parser" do |parser|
241
239
  @xml = '<tag type="date">1970-01-01</tag>'
242
240
  end
243
241
 
244
- it "should return a Date" do
245
- MultiXml.parse(@xml)['tag'].should be_a(Date)
242
+ it "returns a Date" do
243
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Date)
246
244
  end
247
245
 
248
- it "should return the correct date" do
249
- MultiXml.parse(@xml)['tag'].should == Date.parse('1970-01-01')
246
+ it "returns the correct date" do
247
+ expect(MultiXml.parse(@xml)['tag']).to eq(Date.parse('1970-01-01'))
250
248
  end
251
249
  end
252
250
 
@@ -255,12 +253,12 @@ shared_examples_for "a parser" do |parser|
255
253
  @xml = '<tag type="datetime">1970-01-01 00:00</tag>'
256
254
  end
257
255
 
258
- it "should return a Time" do
259
- MultiXml.parse(@xml)['tag'].should be_a(Time)
256
+ it "returns a Time" do
257
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Time)
260
258
  end
261
259
 
262
- it "should return the correct time" do
263
- MultiXml.parse(@xml)['tag'].should == Time.parse('1970-01-01 00:00')
260
+ it "returns the correct time" do
261
+ expect(MultiXml.parse(@xml)['tag']).to eq(Time.parse('1970-01-01 00:00'))
264
262
  end
265
263
  end
266
264
 
@@ -269,12 +267,12 @@ shared_examples_for "a parser" do |parser|
269
267
  @xml = '<tag type="datetime">1970-01-01 00:00</tag>'
270
268
  end
271
269
 
272
- it "should return a Time" do
273
- MultiXml.parse(@xml)['tag'].should be_a(Time)
270
+ it "returns a Time" do
271
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Time)
274
272
  end
275
273
 
276
- it "should return the correct time" do
277
- MultiXml.parse(@xml)['tag'].should == Time.parse('1970-01-01 00:00')
274
+ it "returns the correct time" do
275
+ expect(MultiXml.parse(@xml)['tag']).to eq(Time.parse('1970-01-01 00:00'))
278
276
  end
279
277
  end
280
278
 
@@ -283,12 +281,12 @@ shared_examples_for "a parser" do |parser|
283
281
  @xml = '<tag type="double">3.14159265358979</tag>'
284
282
  end
285
283
 
286
- it "should return a Float" do
287
- MultiXml.parse(@xml)['tag'].should be_a(Float)
284
+ it "returns a Float" do
285
+ expect(MultiXml.parse(@xml)['tag']).to be_a(Float)
288
286
  end
289
287
 
290
- it "should return the correct number" do
291
- MultiXml.parse(@xml)['tag'].should == 3.14159265358979
288
+ it "returns the correct number" do
289
+ expect(MultiXml.parse(@xml)['tag']).to eq(3.14159265358979)
292
290
  end
293
291
  end
294
292
 
@@ -297,12 +295,12 @@ shared_examples_for "a parser" do |parser|
297
295
  @xml = '<tag type="decimal">3.14159265358979</tag>'
298
296
  end
299
297
 
300
- it "should return a BigDecimal" do
301
- MultiXml.parse(@xml)['tag'].should be_a(BigDecimal)
298
+ it "returns a BigDecimal" do
299
+ expect(MultiXml.parse(@xml)['tag']).to be_a(BigDecimal)
302
300
  end
303
301
 
304
- it "should return the correct number" do
305
- MultiXml.parse(@xml)['tag'].should == 3.14159265358979
302
+ it "returns the correct number" do
303
+ expect(MultiXml.parse(@xml)['tag']).to eq(3.14159265358979)
306
304
  end
307
305
  end
308
306
 
@@ -311,26 +309,40 @@ shared_examples_for "a parser" do |parser|
311
309
  @xml = '<tag type="base64Binary">aW1hZ2UucG5n</tag>'
312
310
  end
313
311
 
314
- it "should return a String" do
315
- MultiXml.parse(@xml)['tag'].should be_a(String)
312
+ it "returns a String" do
313
+ expect(MultiXml.parse(@xml)['tag']).to be_a(String)
316
314
  end
317
315
 
318
- it "should return the correct string" do
319
- MultiXml.parse(@xml)['tag'].should == "image.png"
316
+ it "returns the correct string" do
317
+ expect(MultiXml.parse(@xml)['tag']).to eq("image.png")
320
318
  end
321
319
  end
322
320
 
323
321
  context "with an attribute type=\"yaml\"" do
324
322
  before do
325
- @xml = "<tag type=\"yaml\">--- \n1: should return an integer\n:message: Have a nice day\narray: \n- should-have-dashes: true\n should_have_underscores: true\n</tag>"
323
+ @xml = "<tag type=\"yaml\">--- \n1: returns an integer\n:message: Have a nice day\narray: \n- has-dashes: true\n has_underscores: true\n</tag>"
326
324
  end
327
325
 
328
- it "should return a Hash" do
329
- MultiXml.parse(@xml)['tag'].should be_a(Hash)
326
+ it "raises MultiXML::DisallowedTypeError by default" do
327
+ expect{ MultiXml.parse(@xml)['tag'] }.to raise_error(MultiXml::DisallowedTypeError)
330
328
  end
331
329
 
332
- it "should return the correctly parsed YAML" do
333
- MultiXml.parse(@xml)['tag'].should == {:message => "Have a nice day", 1 => "should return an integer", "array" => [{"should-have-dashes" => true, "should_have_underscores" => true}]}
330
+ it "returns the correctly parsed YAML when the type is allowed" do
331
+ expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq({:message => "Have a nice day", 1 => "returns an integer", "array" => [{"has-dashes" => true, "has_underscores" => true}]})
332
+ end
333
+ end
334
+
335
+ context "with an attribute type=\"symbol\"" do
336
+ before do
337
+ @xml = "<tag type=\"symbol\">my_symbol</tag>"
338
+ end
339
+
340
+ it "raises MultiXML::DisallowedTypeError" do
341
+ expect{ MultiXml.parse(@xml)['tag'] }.to raise_error(MultiXml::DisallowedTypeError)
342
+ end
343
+
344
+ it "returns the correctly parsed Symbol when the type is allowed" do
345
+ expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq(:my_symbol)
334
346
  end
335
347
  end
336
348
 
@@ -339,20 +351,20 @@ shared_examples_for "a parser" do |parser|
339
351
  @xml = '<tag type="file" name="data.txt" content_type="text/plain">ZGF0YQ==</tag>'
340
352
  end
341
353
 
342
- it "should return a StringIO" do
343
- MultiXml.parse(@xml)['tag'].should be_a(StringIO)
354
+ it "returns a StringIO" do
355
+ expect(MultiXml.parse(@xml)['tag']).to be_a(StringIO)
344
356
  end
345
357
 
346
- it "should be decoded correctly" do
347
- MultiXml.parse(@xml)['tag'].string.should == 'data'
358
+ it "is decoded correctly" do
359
+ expect(MultiXml.parse(@xml)['tag'].string).to eq('data')
348
360
  end
349
361
 
350
- it "should have the correct file name" do
351
- MultiXml.parse(@xml)['tag'].original_filename.should == 'data.txt'
362
+ it "has the correct file name" do
363
+ expect(MultiXml.parse(@xml)['tag'].original_filename).to eq('data.txt')
352
364
  end
353
365
 
354
- it "should have the correct content type" do
355
- MultiXml.parse(@xml)['tag'].content_type.should == 'text/plain'
366
+ it "has the correct content type" do
367
+ expect(MultiXml.parse(@xml)['tag'].content_type).to eq('text/plain')
356
368
  end
357
369
 
358
370
  context "with missing name and content type" do
@@ -360,20 +372,20 @@ shared_examples_for "a parser" do |parser|
360
372
  @xml = '<tag type="file">ZGF0YQ==</tag>'
361
373
  end
362
374
 
363
- it "should return a StringIO" do
364
- MultiXml.parse(@xml)['tag'].should be_a(StringIO)
375
+ it "returns a StringIO" do
376
+ expect(MultiXml.parse(@xml)['tag']).to be_a(StringIO)
365
377
  end
366
378
 
367
- it "should be decoded correctly" do
368
- MultiXml.parse(@xml)['tag'].string.should == 'data'
379
+ it "is decoded correctly" do
380
+ expect(MultiXml.parse(@xml)['tag'].string).to eq('data')
369
381
  end
370
382
 
371
- it "should have the default file name" do
372
- MultiXml.parse(@xml)['tag'].original_filename.should == 'untitled'
383
+ it "has the default file name" do
384
+ expect(MultiXml.parse(@xml)['tag'].original_filename).to eq('untitled')
373
385
  end
374
386
 
375
- it "should have the default content type" do
376
- MultiXml.parse(@xml)['tag'].content_type.should == 'application/octet-stream'
387
+ it "has the default content type" do
388
+ expect(MultiXml.parse(@xml)['tag'].content_type).to eq('application/octet-stream')
377
389
  end
378
390
  end
379
391
  end
@@ -383,12 +395,12 @@ shared_examples_for "a parser" do |parser|
383
395
  @xml = '<users type="array"><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>'
384
396
  end
385
397
 
386
- it "should return an Array" do
387
- MultiXml.parse(@xml)['users'].should be_a(Array)
398
+ it "returns an Array" do
399
+ expect(MultiXml.parse(@xml)['users']).to be_a(Array)
388
400
  end
389
401
 
390
- it "should return the correct array" do
391
- MultiXml.parse(@xml)['users'].should == ["Erik Michaels-Ober", "Wynn Netherland"]
402
+ it "returns the correct array" do
403
+ expect(MultiXml.parse(@xml)['users']).to eq(["Erik Michaels-Ober", "Wynn Netherland"])
392
404
  end
393
405
  end
394
406
 
@@ -397,12 +409,12 @@ shared_examples_for "a parser" do |parser|
397
409
  @xml = '<users type="array" foo="bar"><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>'
398
410
  end
399
411
 
400
- it "should return an Array" do
401
- MultiXml.parse(@xml)['users'].should be_a(Array)
412
+ it "returns an Array" do
413
+ expect(MultiXml.parse(@xml)['users']).to be_a(Array)
402
414
  end
403
415
 
404
- it "should return the correct array" do
405
- MultiXml.parse(@xml)['users'].should == ["Erik Michaels-Ober", "Wynn Netherland"]
416
+ it "returns the correct array" do
417
+ expect(MultiXml.parse(@xml)['users']).to eq(["Erik Michaels-Ober", "Wynn Netherland"])
406
418
  end
407
419
  end
408
420
 
@@ -411,23 +423,39 @@ shared_examples_for "a parser" do |parser|
411
423
  @xml = '<users type="array"><user>Erik Michaels-Ober</user></users>'
412
424
  end
413
425
 
414
- it "should return an Array" do
415
- MultiXml.parse(@xml)['users'].should be_a(Array)
426
+ it "returns an Array" do
427
+ expect(MultiXml.parse(@xml)['users']).to be_a(Array)
416
428
  end
417
429
 
418
- it "should return the correct array" do
419
- MultiXml.parse(@xml)['users'].should == ["Erik Michaels-Ober"]
430
+ it "returns the correct array" do
431
+ expect(MultiXml.parse(@xml)['users']).to eq(["Erik Michaels-Ober"])
420
432
  end
421
433
  end
422
434
 
423
- %w(integer boolean date datetime yaml file).each do |type|
435
+ %w(integer boolean date datetime file).each do |type|
424
436
  context "with an empty attribute type=\"#{type}\"" do
425
437
  before do
426
438
  @xml = "<tag type=\"#{type}\"/>"
427
439
  end
428
440
 
429
- it "should return nil" do
430
- MultiXml.parse(@xml)['tag'].should be_nil
441
+ it "returns nil" do
442
+ expect(MultiXml.parse(@xml)['tag']).to be_nil
443
+ end
444
+ end
445
+ end
446
+
447
+ %w{yaml symbol}.each do |type|
448
+ context "with an empty attribute type=\"#{type}\"" do
449
+ before do
450
+ @xml = "<tag type=\"#{type}\"/>"
451
+ end
452
+
453
+ it "raises MultiXml::DisallowedTypeError by default" do
454
+ expect{ MultiXml.parse(@xml)['tag']}.to raise_error(MultiXml::DisallowedTypeError)
455
+ end
456
+
457
+ it "returns nil when the type is allowed" do
458
+ expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to be_nil
431
459
  end
432
460
  end
433
461
  end
@@ -437,8 +465,8 @@ shared_examples_for "a parser" do |parser|
437
465
  @xml = '<tag type="array"/>'
438
466
  end
439
467
 
440
- it "should return an empty Array" do
441
- MultiXml.parse(@xml)['tag'].should == []
468
+ it "returns an empty Array" do
469
+ expect(MultiXml.parse(@xml)['tag']).to eq([])
442
470
  end
443
471
 
444
472
  context "with whitespace" do
@@ -446,8 +474,8 @@ shared_examples_for "a parser" do |parser|
446
474
  @xml = '<tag type="array"> </tag>'
447
475
  end
448
476
 
449
- it "should return an empty Array" do
450
- MultiXml.parse(@xml)['tag'].should == []
477
+ it "returns an empty Array" do
478
+ expect(MultiXml.parse(@xml)['tag']).to eq([])
451
479
  end
452
480
  end
453
481
  end
@@ -464,19 +492,19 @@ shared_examples_for "a parser" do |parser|
464
492
  end
465
493
 
466
494
  context "in content" do
467
- it "should return unescaped XML entities" do
495
+ it "returns unescaped XML entities" do
468
496
  @xml_entities.each do |key, value|
469
497
  xml = "<tag>#{value}</tag>"
470
- MultiXml.parse(xml)['tag'].should == key
498
+ expect(MultiXml.parse(xml)['tag']).to eq(key)
471
499
  end
472
500
  end
473
501
  end
474
502
 
475
503
  context "in attribute" do
476
- it "should return unescaped XML entities" do
504
+ it "returns unescaped XML entities" do
477
505
  @xml_entities.each do |key, value|
478
506
  xml = "<tag attribute=\"#{value}\"/>"
479
- MultiXml.parse(xml)['tag']['attribute'].should == key
507
+ expect(MultiXml.parse(xml)['tag']['attribute']).to eq(key)
480
508
  end
481
509
  end
482
510
  end
@@ -488,8 +516,8 @@ shared_examples_for "a parser" do |parser|
488
516
  @xml = '<tag-1/>'
489
517
  end
490
518
 
491
- it "should return undasherize tag" do
492
- MultiXml.parse(@xml).keys.should include('tag_1')
519
+ it "returns undasherize tag" do
520
+ expect(MultiXml.parse(@xml).keys).to include('tag_1')
493
521
  end
494
522
  end
495
523
 
@@ -498,8 +526,8 @@ shared_examples_for "a parser" do |parser|
498
526
  @xml = '<tag attribute-1="1"></tag>'
499
527
  end
500
528
 
501
- it "should return undasherize attribute" do
502
- MultiXml.parse(@xml)['tag'].keys.should include('attribute_1')
529
+ it "returns undasherize attribute" do
530
+ expect(MultiXml.parse(@xml)['tag'].keys).to include('attribute_1')
503
531
  end
504
532
  end
505
533
 
@@ -509,8 +537,8 @@ shared_examples_for "a parser" do |parser|
509
537
  @xml = '<users><user name="Erik Michaels-Ober"/></users>'
510
538
  end
511
539
 
512
- it "should return the correct attributes" do
513
- MultiXml.parse(@xml)['users']['user']['name'].should == "Erik Michaels-Ober"
540
+ it "returns the correct attributes" do
541
+ expect(MultiXml.parse(@xml)['users']['user']['name']).to eq("Erik Michaels-Ober")
514
542
  end
515
543
  end
516
544
 
@@ -519,8 +547,8 @@ shared_examples_for "a parser" do |parser|
519
547
  @xml = '<user><name>Erik Michaels-Ober</name></user>'
520
548
  end
521
549
 
522
- it "should return the correct text" do
523
- MultiXml.parse(@xml)['user']['name'].should == "Erik Michaels-Ober"
550
+ it "returns the correct text" do
551
+ expect(MultiXml.parse(@xml)['user']['name']).to eq("Erik Michaels-Ober")
524
552
  end
525
553
  end
526
554
 
@@ -529,8 +557,8 @@ shared_examples_for "a parser" do |parser|
529
557
  @xml = '<user type="admin"><name>Erik Michaels-Ober</name></user>'
530
558
  end
531
559
 
532
- it "should pass through the type" do
533
- MultiXml.parse(@xml)['user']['type'].should == 'admin'
560
+ it "passes through the type" do
561
+ expect(MultiXml.parse(@xml)['user']['type']).to eq('admin')
534
562
  end
535
563
  end
536
564
 
@@ -546,11 +574,11 @@ shared_examples_for "a parser" do |parser|
546
574
  @parsed_xml = MultiXml.parse(@xml)
547
575
  end
548
576
 
549
- it "should add the attributes to the value hash" do
550
- @parsed_xml['options']['value'][0]['__content__'].should == '123'
551
- @parsed_xml['options']['value'][0]['currency'].should == 'USD'
552
- @parsed_xml['options']['value'][1]['__content__'].should == '0.123'
553
- @parsed_xml['options']['value'][1]['number'].should == 'percent'
577
+ it "adds the attributes to the value hash" do
578
+ expect(@parsed_xml['options']['value'][0]['__content__']).to eq('123')
579
+ expect(@parsed_xml['options']['value'][0]['currency']).to eq('USD')
580
+ expect(@parsed_xml['options']['value'][1]['__content__']).to eq('0.123')
581
+ expect(@parsed_xml['options']['value'][1]['number']).to eq('percent')
554
582
  end
555
583
  end
556
584
 
@@ -566,13 +594,13 @@ shared_examples_for "a parser" do |parser|
566
594
  @parsed_xml = MultiXml.parse(@xml)
567
595
  end
568
596
 
569
- it "should add the attributes to the value hash passing through the type" do
570
- @parsed_xml['options']['value'][0]['__content__'].should == '123'
571
- @parsed_xml['options']['value'][0]['type'].should == 'USD'
572
- @parsed_xml['options']['value'][1]['__content__'].should == '0.123'
573
- @parsed_xml['options']['value'][1]['type'].should == 'percent'
574
- @parsed_xml['options']['value'][2]['__content__'].should == '123'
575
- @parsed_xml['options']['value'][2]['currency'].should == 'USD'
597
+ it "adds the attributes to the value hash passing through the type" do
598
+ expect(@parsed_xml['options']['value'][0]['__content__']).to eq('123')
599
+ expect(@parsed_xml['options']['value'][0]['type']).to eq('USD')
600
+ expect(@parsed_xml['options']['value'][1]['__content__']).to eq('0.123')
601
+ expect(@parsed_xml['options']['value'][1]['type']).to eq('percent')
602
+ expect(@parsed_xml['options']['value'][2]['__content__']).to eq('123')
603
+ expect(@parsed_xml['options']['value'][2]['currency']).to eq('USD')
576
604
  end
577
605
  end
578
606
 
@@ -588,12 +616,12 @@ shared_examples_for "a parser" do |parser|
588
616
  @parsed_xml = MultiXml.parse(@xml)
589
617
  end
590
618
 
591
- it "should add the attributes to the value hash passing through the type" do
592
- @parsed_xml['options']['value'][0]['__content__'].should == '123'
593
- @parsed_xml['options']['value'][0]['type'].should == 'USD'
594
- @parsed_xml['options']['value'][1]['__content__'].should == '0.123'
595
- @parsed_xml['options']['value'][1]['type'].should == 'percent'
596
- @parsed_xml['options']['value'][2].should == '123'
619
+ it "adds the attributes to the value hash passing through the type" do
620
+ expect(@parsed_xml['options']['value'][0]['__content__']).to eq('123')
621
+ expect(@parsed_xml['options']['value'][0]['type']).to eq('USD')
622
+ expect(@parsed_xml['options']['value'][1]['__content__']).to eq('0.123')
623
+ expect(@parsed_xml['options']['value'][1]['type']).to eq('percent')
624
+ expect(@parsed_xml['options']['value'][2]).to eq('123')
597
625
  end
598
626
  end
599
627
 
@@ -607,9 +635,9 @@ shared_examples_for "a parser" do |parser|
607
635
  @parsed_xml = MultiXml.parse(@xml)
608
636
  end
609
637
 
610
- it "should add the the non-type attribute and remove the recognized type attribute and do the typecast" do
611
- @parsed_xml['options']['value']['__content__'].should == 123
612
- @parsed_xml['options']['value']['number'].should == 'USD'
638
+ it "adds the the non-type attribute and remove the recognized type attribute and do the typecast" do
639
+ expect(@parsed_xml['options']['value']['__content__']).to eq(123)
640
+ expect(@parsed_xml['options']['value']['number']).to eq('USD')
613
641
  end
614
642
  end
615
643
 
@@ -623,10 +651,10 @@ shared_examples_for "a parser" do |parser|
623
651
  @parsed_xml = MultiXml.parse(@xml)
624
652
  end
625
653
 
626
- it "should add the the non-type attributes and type attribute to the value hash" do
627
- @parsed_xml['options']['value']['__content__'].should == '123'
628
- @parsed_xml['options']['value']['number'].should == 'USD'
629
- @parsed_xml['options']['value']['type'].should == 'currency'
654
+ it "adds the the non-type attributes and type attribute to the value hash" do
655
+ expect(@parsed_xml['options']['value']['__content__']).to eq('123')
656
+ expect(@parsed_xml['options']['value']['number']).to eq('USD')
657
+ expect(@parsed_xml['options']['value']['type']).to eq('currency')
630
658
  end
631
659
  end
632
660
  end
@@ -640,8 +668,8 @@ shared_examples_for "a parser" do |parser|
640
668
  XML
641
669
  end
642
670
 
643
- it "should parse correctly" do
644
- MultiXml.parse(@xml).should == {"user" => {"name" => "Erik Michaels-Ober"}}
671
+ it "parses correctly" do
672
+ expect(MultiXml.parse(@xml)).to eq({"user" => {"name" => "Erik Michaels-Ober"}})
645
673
  end
646
674
  end
647
675
 
@@ -651,8 +679,8 @@ shared_examples_for "a parser" do |parser|
651
679
  @xml = '<users><user name="Erik Michaels-Ober"><status text="Hello"/></user></users>'
652
680
  end
653
681
 
654
- it "should parse correctly" do
655
- MultiXml.parse(@xml).should == {"users" => {"user" => {"name" => "Erik Michaels-Ober", "status" => {"text" => "Hello"}}}}
682
+ it "parses correctly" do
683
+ expect(MultiXml.parse(@xml)).to eq({"users" => {"user" => {"name" => "Erik Michaels-Ober", "status" => {"text" => "Hello"}}}})
656
684
  end
657
685
  end
658
686
  end
@@ -662,12 +690,12 @@ shared_examples_for "a parser" do |parser|
662
690
  @xml = '<users><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>'
663
691
  end
664
692
 
665
- it "should return an Array" do
666
- MultiXml.parse(@xml)['users']['user'].should be_a(Array)
693
+ it "returns an Array" do
694
+ expect(MultiXml.parse(@xml)['users']['user']).to be_a(Array)
667
695
  end
668
696
 
669
- it "should parse correctly" do
670
- MultiXml.parse(@xml).should == {"users" => {"user" => ["Erik Michaels-Ober", "Wynn Netherland"]}}
697
+ it "parses correctly" do
698
+ expect(MultiXml.parse(@xml)).to eq({"users" => {"user" => ["Erik Michaels-Ober", "Wynn Netherland"]}})
671
699
  end
672
700
  end
673
701