xmlmapper 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -4
  3. data/README.md +35 -35
  4. data/lib/xmlmapper.rb +776 -1
  5. data/lib/{happymapper → xmlmapper}/anonymous_mapper.rb +23 -23
  6. data/lib/{happymapper → xmlmapper}/attribute.rb +1 -1
  7. data/lib/{happymapper → xmlmapper}/element.rb +1 -1
  8. data/lib/{happymapper → xmlmapper}/item.rb +1 -1
  9. data/lib/{happymapper → xmlmapper}/supported_types.rb +2 -2
  10. data/lib/{happymapper → xmlmapper}/text_node.rb +1 -1
  11. data/lib/xmlmapper/version.rb +3 -0
  12. data/spec/attribute_default_value_spec.rb +1 -1
  13. data/spec/attributes_spec.rb +2 -2
  14. data/spec/fixtures/unformatted_address.xml +1 -0
  15. data/spec/has_many_empty_array_spec.rb +2 -2
  16. data/spec/ignay_spec.rb +5 -5
  17. data/spec/inheritance_spec.rb +6 -6
  18. data/spec/mixed_namespaces_spec.rb +2 -2
  19. data/spec/parse_with_object_to_update_spec.rb +4 -4
  20. data/spec/spec_helper.rb +1 -1
  21. data/spec/to_xml_spec.rb +5 -5
  22. data/spec/to_xml_with_namespaces_spec.rb +6 -6
  23. data/spec/wilcard_tag_name_spec.rb +8 -8
  24. data/spec/wrap_spec.rb +5 -5
  25. data/spec/{happymapper → xmlmapper}/attribute_spec.rb +1 -1
  26. data/spec/{happymapper → xmlmapper}/element_spec.rb +2 -2
  27. data/spec/{happymapper → xmlmapper}/item_spec.rb +16 -16
  28. data/spec/xmlmapper/text_node_spec.rb +9 -0
  29. data/spec/{happymapper_parse_spec.rb → xmlmapper_parse_spec.rb} +3 -3
  30. data/spec/{happymapper_spec.rb → xmlmapper_spec.rb} +87 -66
  31. data/spec/xpath_spec.rb +5 -5
  32. metadata +22 -21
  33. data/lib/happymapper.rb +0 -776
  34. data/lib/happymapper/version.rb +0 -3
  35. data/spec/happymapper/text_node_spec.rb +0 -9
data/spec/wrap_spec.rb CHANGED
@@ -4,13 +4,13 @@ describe "wrap which allows you to specify a wrapper element" do
4
4
 
5
5
  module Wrap
6
6
  class SubClass
7
- include HappyMapper
7
+ include XmlMapper
8
8
  tag 'subclass'
9
9
  attribute :myattr, String
10
10
  has_many :items, String, :tag => 'item'
11
11
  end
12
12
  class Root
13
- include HappyMapper
13
+ include XmlMapper
14
14
  tag 'root'
15
15
  attribute :attr1, String
16
16
  element :name, String
@@ -31,7 +31,7 @@ describe "wrap which allows you to specify a wrapper element" do
31
31
  expect(subject.name).to eq 'myname'
32
32
  expect(subject.description).to eq 'some description'
33
33
  expect(subject.subclass.myattr).to eq 'attrvalue'
34
- expect(subject.subclass.items).to have(2).items
34
+ expect(subject.subclass.items.size).to eq 2
35
35
  expect(subject.subclass.items[0]).to eq 'item1'
36
36
  expect(subject.subclass.items[1]).to eq 'item2'
37
37
  expect(subject.number).to eq 12345
@@ -72,11 +72,11 @@ describe "wrap which allows you to specify a wrapper element" do
72
72
  expect(xml.xpath('/root/name').text).to eq 'myname'
73
73
  expect(xml.xpath('/root/mywraptag/description').text).to eq 'some description'
74
74
  expect(xml.xpath('/root/mywraptag/subclass/@myattr').text).to eq 'attrvalue'
75
- expect(xml.xpath('/root/mywraptag/subclass/item')).to have(2).items
75
+ expect(xml.xpath('/root/mywraptag/subclass/item').size).to eq 2
76
76
  expect(xml.xpath('/root/mywraptag/subclass/item[1]').text).to eq 'item1'
77
77
  expect(xml.xpath('/root/mywraptag/subclass/item[2]').text).to eq 'item2'
78
78
  expect(xml.xpath('/root/number').text).to eq '12345'
79
79
  end
80
80
 
81
81
  end
82
- end
82
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HappyMapper::Attribute do
3
+ describe XmlMapper::Attribute do
4
4
 
5
5
  describe "initialization" do
6
6
  it 'accepts :default option' do
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HappyMapper::Element do
3
+ describe XmlMapper::Element do
4
4
  describe "initialization" do
5
5
  before do
6
- @attr = HappyMapper::Element.new(:foo, String)
6
+ @attr = XmlMapper::Element.new(:foo, String)
7
7
  end
8
8
  end
9
9
  end
@@ -4,11 +4,11 @@ module Foo
4
4
  class Bar; end
5
5
  end
6
6
 
7
- describe HappyMapper::Item do
7
+ describe XmlMapper::Item do
8
8
 
9
9
  describe "new instance" do
10
10
  before do
11
- @item = HappyMapper::Item.new(:foo, String, :tag => 'foobar')
11
+ @item = XmlMapper::Item.new(:foo, String, :tag => 'foobar')
12
12
  end
13
13
 
14
14
  it "should accept a name" do
@@ -30,41 +30,41 @@ describe HappyMapper::Item do
30
30
 
31
31
  describe "#constant" do
32
32
  it "should just use type if constant" do
33
- item = HappyMapper::Item.new(:foo, String)
33
+ item = XmlMapper::Item.new(:foo, String)
34
34
  item.constant.should == String
35
35
  end
36
36
 
37
37
  it "should convert string type to constant" do
38
- item = HappyMapper::Item.new(:foo, 'String')
38
+ item = XmlMapper::Item.new(:foo, 'String')
39
39
  item.constant.should == String
40
40
  end
41
41
 
42
42
  it "should convert string with :: to constant" do
43
- item = HappyMapper::Item.new(:foo, 'Foo::Bar')
43
+ item = XmlMapper::Item.new(:foo, 'Foo::Bar')
44
44
  item.constant.should == Foo::Bar
45
45
  end
46
46
  end
47
47
 
48
48
  describe "#method_name" do
49
49
  it "should convert dashes to underscores" do
50
- item = HappyMapper::Item.new(:'foo-bar', String, :tag => 'foobar')
50
+ item = XmlMapper::Item.new(:'foo-bar', String, :tag => 'foobar')
51
51
  item.method_name.should == 'foo_bar'
52
52
  end
53
53
  end
54
54
 
55
55
  describe "#xpath" do
56
56
  it "should default to tag" do
57
- item = HappyMapper::Item.new(:foo, String, :tag => 'foobar')
57
+ item = XmlMapper::Item.new(:foo, String, :tag => 'foobar')
58
58
  item.xpath.should == 'foobar'
59
59
  end
60
60
 
61
61
  it "should prepend with .// if options[:deep] true" do
62
- item = HappyMapper::Item.new(:foo, String, :tag => 'foobar', :deep => true)
62
+ item = XmlMapper::Item.new(:foo, String, :tag => 'foobar', :deep => true)
63
63
  item.xpath.should == './/foobar'
64
64
  end
65
65
 
66
66
  it "should prepend namespace if namespace exists" do
67
- item = HappyMapper::Item.new(:foo, String, :tag => 'foobar')
67
+ item = XmlMapper::Item.new(:foo, String, :tag => 'foobar')
68
68
  item.namespace = 'v2'
69
69
  item.xpath.should == 'v2:foobar'
70
70
  end
@@ -72,43 +72,43 @@ describe HappyMapper::Item do
72
72
 
73
73
  describe "typecasting" do
74
74
  it "should work with Strings" do
75
- item = HappyMapper::Item.new(:foo, String)
75
+ item = XmlMapper::Item.new(:foo, String)
76
76
  [21, '21'].each do |a|
77
77
  item.typecast(a).should == '21'
78
78
  end
79
79
  end
80
80
 
81
81
  it "should work with Integers" do
82
- item = HappyMapper::Item.new(:foo, Integer)
82
+ item = XmlMapper::Item.new(:foo, Integer)
83
83
  [21, 21.0, '21'].each do |a|
84
84
  item.typecast(a).should == 21
85
85
  end
86
86
  end
87
87
 
88
88
  it "should work with Floats" do
89
- item = HappyMapper::Item.new(:foo, Float)
89
+ item = XmlMapper::Item.new(:foo, Float)
90
90
  [21, 21.0, '21'].each do |a|
91
91
  item.typecast(a).should == 21.0
92
92
  end
93
93
  end
94
94
 
95
95
  it "should work with Times" do
96
- item = HappyMapper::Item.new(:foo, Time)
96
+ item = XmlMapper::Item.new(:foo, Time)
97
97
  item.typecast('2000-01-01 01:01:01.123456').should == Time.local(2000, 1, 1, 1, 1, 1, 123456)
98
98
  end
99
99
 
100
100
  it "should work with Dates" do
101
- item = HappyMapper::Item.new(:foo, Date)
101
+ item = XmlMapper::Item.new(:foo, Date)
102
102
  item.typecast('2000-01-01').should == Date.new(2000, 1, 1)
103
103
  end
104
104
 
105
105
  it "should work with DateTimes" do
106
- item = HappyMapper::Item.new(:foo, DateTime)
106
+ item = XmlMapper::Item.new(:foo, DateTime)
107
107
  item.typecast('2000-01-01 00:00:00').should == DateTime.new(2000, 1, 1, 0, 0, 0)
108
108
  end
109
109
 
110
110
  it "should work with Boolean" do
111
- item = HappyMapper::Item.new(:foo, HappyMapper::Boolean)
111
+ item = XmlMapper::Item.new(:foo, XmlMapper::Boolean)
112
112
  item.typecast('false').should == false
113
113
  end
114
114
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe XmlMapper::Attribute do
4
+ describe "initialization" do
5
+ before do
6
+ @attr = XmlMapper::TextNode.new(:foo, String)
7
+ end
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HappyMapper do
3
+ describe XmlMapper do
4
4
 
5
5
  context ".parse" do
6
6
 
@@ -85,7 +85,7 @@ describe HappyMapper do
85
85
  context "after_parse callbacks" do
86
86
  module AfterParseSpec
87
87
  class Address
88
- include HappyMapper
88
+ include XmlMapper
89
89
  element :street, String
90
90
  end
91
91
  end
@@ -110,4 +110,4 @@ describe HappyMapper do
110
110
 
111
111
  end
112
112
 
113
- end
113
+ end
@@ -3,7 +3,7 @@ require 'uri'
3
3
 
4
4
  module Analytics
5
5
  class Property
6
- include HappyMapper
6
+ include XmlMapper
7
7
 
8
8
  tag 'property'
9
9
  namespace 'dxp'
@@ -12,7 +12,7 @@ module Analytics
12
12
  end
13
13
 
14
14
  class Goal
15
- include HappyMapper
15
+ include XmlMapper
16
16
 
17
17
  # Google Analytics does a dirtry trick where a user with no goals
18
18
  # returns a profile without any goals data or the declared namespace
@@ -35,7 +35,7 @@ module Analytics
35
35
  end
36
36
 
37
37
  class Profile
38
- include HappyMapper
38
+ include XmlMapper
39
39
 
40
40
  tag 'entry'
41
41
  element :title, String
@@ -47,7 +47,7 @@ module Analytics
47
47
 
48
48
 
49
49
  class Entry
50
- include HappyMapper
50
+ include XmlMapper
51
51
 
52
52
  tag 'entry'
53
53
  element :id, String
@@ -58,7 +58,7 @@ module Analytics
58
58
  end
59
59
 
60
60
  class Feed
61
- include HappyMapper
61
+ include XmlMapper
62
62
 
63
63
  tag 'feed'
64
64
  element :id, String
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  module Atom
72
72
  class Feed
73
- include HappyMapper
73
+ include XmlMapper
74
74
  tag 'feed'
75
75
 
76
76
  attribute :xmlns, String, :single => true
@@ -87,7 +87,10 @@ module Atom
87
87
  end
88
88
 
89
89
  class Address
90
- include HappyMapper
90
+ include XmlMapper
91
+
92
+ attr_accessor :xml_value
93
+ attr_accessor :xml_content
91
94
 
92
95
  tag 'address'
93
96
  element :street, String
@@ -98,12 +101,12 @@ class Address
98
101
  end
99
102
 
100
103
  class Feature
101
- include HappyMapper
104
+ include XmlMapper
102
105
  element :name, String, :xpath => './/text()'
103
106
  end
104
107
 
105
108
  class FeatureBullet
106
- include HappyMapper
109
+ include XmlMapper
107
110
 
108
111
  tag 'features_bullets'
109
112
  has_many :features, Feature
@@ -111,7 +114,7 @@ class FeatureBullet
111
114
  end
112
115
 
113
116
  class Product
114
- include HappyMapper
117
+ include XmlMapper
115
118
 
116
119
  element :title, String
117
120
  has_one :feature_bullets, FeatureBullet
@@ -119,25 +122,25 @@ class Product
119
122
  end
120
123
 
121
124
  class Rate
122
- include HappyMapper
125
+ include XmlMapper
123
126
  end
124
127
 
125
128
  module FamilySearch
126
129
  class AlternateIds
127
- include HappyMapper
130
+ include XmlMapper
128
131
 
129
132
  tag 'alternateIds'
130
133
  has_many :ids, String, :tag => 'id'
131
134
  end
132
135
 
133
136
  class Information
134
- include HappyMapper
137
+ include XmlMapper
135
138
 
136
139
  has_one :alternateIds, AlternateIds
137
140
  end
138
141
 
139
142
  class Person
140
- include HappyMapper
143
+ include XmlMapper
141
144
 
142
145
  attribute :version, String
143
146
  attribute :modified, Time
@@ -146,12 +149,12 @@ module FamilySearch
146
149
  end
147
150
 
148
151
  class Persons
149
- include HappyMapper
152
+ include XmlMapper
150
153
  has_many :person, Person
151
154
  end
152
155
 
153
156
  class FamilyTree
154
- include HappyMapper
157
+ include XmlMapper
155
158
 
156
159
  tag 'familytree'
157
160
  attribute :version, String
@@ -163,7 +166,7 @@ end
163
166
 
164
167
  module FedEx
165
168
  class Address
166
- include HappyMapper
169
+ include XmlMapper
167
170
 
168
171
  tag 'Address'
169
172
  namespace 'v2'
@@ -175,7 +178,7 @@ module FedEx
175
178
  end
176
179
 
177
180
  class Event
178
- include HappyMapper
181
+ include XmlMapper
179
182
 
180
183
  tag 'Events'
181
184
  namespace 'v2'
@@ -186,7 +189,7 @@ module FedEx
186
189
  end
187
190
 
188
191
  class PackageWeight
189
- include HappyMapper
192
+ include XmlMapper
190
193
 
191
194
  tag 'PackageWeight'
192
195
  namespace 'v2'
@@ -195,7 +198,7 @@ module FedEx
195
198
  end
196
199
 
197
200
  class TrackDetails
198
- include HappyMapper
201
+ include XmlMapper
199
202
 
200
203
  tag 'TrackDetails'
201
204
  namespace 'v2'
@@ -210,7 +213,7 @@ module FedEx
210
213
  end
211
214
 
212
215
  class Notification
213
- include HappyMapper
216
+ include XmlMapper
214
217
 
215
218
  tag 'Notifications'
216
219
  namespace 'v2'
@@ -222,7 +225,7 @@ module FedEx
222
225
  end
223
226
 
224
227
  class TransactionDetail
225
- include HappyMapper
228
+ include XmlMapper
226
229
 
227
230
  tag 'TransactionDetail'
228
231
  namespace 'v2'
@@ -230,7 +233,7 @@ module FedEx
230
233
  end
231
234
 
232
235
  class TrackReply
233
- include HappyMapper
236
+ include XmlMapper
234
237
 
235
238
  tag 'TrackReply'
236
239
  namespace 'v2'
@@ -243,17 +246,17 @@ module FedEx
243
246
  end
244
247
 
245
248
  class Place
246
- include HappyMapper
249
+ include XmlMapper
247
250
  element :name, String
248
251
  end
249
252
 
250
253
  class Radar
251
- include HappyMapper
254
+ include XmlMapper
252
255
  has_many :places, Place, :tag => :place
253
256
  end
254
257
 
255
258
  class Post
256
- include HappyMapper
259
+ include XmlMapper
257
260
 
258
261
  attribute :href, String
259
262
  attribute :hash, String
@@ -265,7 +268,7 @@ class Post
265
268
  end
266
269
 
267
270
  class User
268
- include HappyMapper
271
+ include XmlMapper
269
272
 
270
273
  element :id, Integer
271
274
  element :name, String
@@ -279,7 +282,7 @@ class User
279
282
  end
280
283
 
281
284
  class Status
282
- include HappyMapper
285
+ include XmlMapper
283
286
 
284
287
  register_namespace 'fake', "faka:namespace"
285
288
 
@@ -296,7 +299,7 @@ class Status
296
299
  end
297
300
 
298
301
  class CurrentWeather
299
- include HappyMapper
302
+ include XmlMapper
300
303
 
301
304
  tag 'ob'
302
305
  namespace 'aws'
@@ -306,7 +309,7 @@ class CurrentWeather
306
309
  end
307
310
 
308
311
  class Country
309
- include HappyMapper
312
+ include XmlMapper
310
313
 
311
314
  attribute :code, String
312
315
  content :name, String
@@ -314,11 +317,11 @@ end
314
317
 
315
318
 
316
319
  class State
317
- include HappyMapper
320
+ include XmlMapper
318
321
  end
319
322
 
320
323
  class Address
321
- include HappyMapper
324
+ include XmlMapper
322
325
 
323
326
  tag 'address'
324
327
  element :street, String
@@ -334,7 +337,7 @@ class ProductGroup < String; end
334
337
 
335
338
  module PITA
336
339
  class Item
337
- include HappyMapper
340
+ include XmlMapper
338
341
 
339
342
  tag 'Item' # if you put class in module you need tag
340
343
  element :asin, String, :tag => 'ASIN'
@@ -345,7 +348,7 @@ module PITA
345
348
  end
346
349
 
347
350
  class Items
348
- include HappyMapper
351
+ include XmlMapper
349
352
 
350
353
  tag 'Items' # if you put class in module you need tag
351
354
  element :total_results, Integer, :tag => 'TotalResults'
@@ -356,7 +359,7 @@ end
356
359
 
357
360
  module GitHub
358
361
  class Commit
359
- include HappyMapper
362
+ include XmlMapper
360
363
 
361
364
  tag "commit"
362
365
  element :url, String
@@ -369,20 +372,20 @@ end
369
372
 
370
373
  module QuarterTest
371
374
  class Quarter
372
- include HappyMapper
375
+ include XmlMapper
373
376
 
374
377
  element :start, String
375
378
  end
376
379
 
377
380
  class Details
378
- include HappyMapper
381
+ include XmlMapper
379
382
 
380
383
  element :round, Integer
381
384
  element :quarter, Integer
382
385
  end
383
386
 
384
387
  class Game
385
- include HappyMapper
388
+ include XmlMapper
386
389
 
387
390
  # in an ideal world, the following elements would all be
388
391
  # called 'quarter' with an attribute indicating which quarter
@@ -399,7 +402,7 @@ end
399
402
 
400
403
  # To check for multiple primitives
401
404
  class Artist
402
- include HappyMapper
405
+ include XmlMapper
403
406
 
404
407
  tag 'artist'
405
408
  element :images, String, :tag => "image", :single => false
@@ -407,7 +410,7 @@ class Artist
407
410
  end
408
411
 
409
412
  class Location
410
- include HappyMapper
413
+ include XmlMapper
411
414
 
412
415
  tag 'point'
413
416
  namespace "geo"
@@ -417,7 +420,7 @@ end
417
420
  # Testing the XmlContent type
418
421
  module Dictionary
419
422
  class Variant
420
- include HappyMapper
423
+ include XmlMapper
421
424
  tag 'var'
422
425
  has_xml_content
423
426
 
@@ -427,14 +430,14 @@ module Dictionary
427
430
  end
428
431
 
429
432
  class Definition
430
- include HappyMapper
433
+ include XmlMapper
431
434
 
432
435
  tag 'def'
433
436
  element :text, XmlContent, :tag => 'dtext'
434
437
  end
435
438
 
436
439
  class Record
437
- include HappyMapper
440
+ include XmlMapper
438
441
 
439
442
  tag 'record'
440
443
  has_many :definitions, Definition
@@ -444,7 +447,7 @@ end
444
447
 
445
448
  module AmbigousItems
446
449
  class Item
447
- include HappyMapper
450
+ include XmlMapper
448
451
 
449
452
  tag 'item'
450
453
  element :name, String
@@ -453,7 +456,7 @@ module AmbigousItems
453
456
  end
454
457
 
455
458
  class PublishOptions
456
- include HappyMapper
459
+ include XmlMapper
457
460
 
458
461
  tag 'publishOptions'
459
462
 
@@ -470,7 +473,7 @@ class PublishOptions
470
473
  end
471
474
 
472
475
  class Article
473
- include HappyMapper
476
+ include XmlMapper
474
477
 
475
478
  tag 'Article'
476
479
  namespace 'article'
@@ -487,7 +490,7 @@ class Article
487
490
  end
488
491
 
489
492
  class PartiallyBadArticle
490
- include HappyMapper
493
+ include XmlMapper
491
494
 
492
495
  attr_writer :xml_value
493
496
 
@@ -504,7 +507,7 @@ class PartiallyBadArticle
504
507
  end
505
508
 
506
509
  class Photo
507
- include HappyMapper
510
+ include XmlMapper
508
511
 
509
512
  tag 'Photo'
510
513
  namespace 'photo'
@@ -517,7 +520,7 @@ class Photo
517
520
  end
518
521
 
519
522
  class Gallery
520
- include HappyMapper
523
+ include XmlMapper
521
524
 
522
525
  tag 'Gallery'
523
526
  namespace 'gallery'
@@ -529,7 +532,7 @@ class Gallery
529
532
  end
530
533
 
531
534
  class Video
532
- include HappyMapper
535
+ include XmlMapper
533
536
 
534
537
  tag 'Video'
535
538
  namespace 'video'
@@ -542,14 +545,14 @@ class Video
542
545
  end
543
546
 
544
547
  class OptionalAttribute
545
- include HappyMapper
548
+ include XmlMapper
546
549
  tag 'address'
547
550
 
548
551
  attribute :street, String
549
552
  end
550
553
 
551
554
  class DefaultNamespaceCombi
552
- include HappyMapper
555
+ include XmlMapper
553
556
 
554
557
 
555
558
  register_namespace 'bk', "urn:loc.gov:books"
@@ -564,12 +567,12 @@ class DefaultNamespaceCombi
564
567
  element :author, String, :namespace => 'p', :tag => "author"
565
568
  end
566
569
 
567
- describe HappyMapper do
570
+ describe XmlMapper do
568
571
 
569
572
  describe "being included into another class" do
570
573
  before do
571
574
  @klass = Class.new do
572
- include HappyMapper
575
+ include XmlMapper
573
576
 
574
577
  def self.to_s
575
578
  'Boo'
@@ -577,7 +580,7 @@ describe HappyMapper do
577
580
  end
578
581
  end
579
582
 
580
- class Boo; include HappyMapper end
583
+ class Boo; include XmlMapper end
581
584
 
582
585
  it "should set attributes to an array" do
583
586
  @klass.attributes.should == []
@@ -643,7 +646,7 @@ describe HappyMapper do
643
646
  end
644
647
 
645
648
  it "should default tag name of class in modules to the last constant lowercase" do
646
- module Bar; class Baz; include HappyMapper; end; end
649
+ module Bar; class Baz; include XmlMapper; end; end
647
650
  Bar::Baz.tag_name.should == 'baz'
648
651
  end
649
652
 
@@ -713,10 +716,10 @@ describe HappyMapper do
713
716
  first.id.should == 882281424
714
717
  first.created_at.should == Time.utc(2008, 8, 9, 5, 38, 12)
715
718
  first.source.should == 'web'
716
- first.truncated.should be_false
719
+ first.truncated.should be_falsey
717
720
  first.in_reply_to_status_id.should == 1234
718
721
  first.in_reply_to_user_id.should == 12345
719
- first.favorited.should be_false
722
+ first.favorited.should be_falsey
720
723
  first.user.id.should == 4243
721
724
  first.user.name.should == 'John Nunemaker'
722
725
  first.user.screen_name.should == 'jnunemaker'
@@ -724,7 +727,7 @@ describe HappyMapper do
724
727
  first.user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
725
728
  first.user.profile_image_url.should == 'http://s3.amazonaws.com/twitter_production/profile_images/53781608/Photo_75_normal.jpg'
726
729
  first.user.url.should == 'http://addictedtonew.com'
727
- first.user.protected.should be_false
730
+ first.user.protected.should be_falsey
728
731
  first.user.followers_count.should == 486
729
732
  end
730
733
 
@@ -854,7 +857,7 @@ describe HappyMapper do
854
857
  it "should parse xml with multiple namespaces" do
855
858
  track = FedEx::TrackReply.parse(fixture_file('multiple_namespaces.xml'))
856
859
  track.highest_severity.should == 'SUCCESS'
857
- track.more_data.should be_false
860
+ track.more_data.should be_falsey
858
861
  notification = track.notifications.first
859
862
  notification.code.should == 0
860
863
  notification.localized_message.should == 'Request was successfully processed.'
@@ -878,7 +881,7 @@ describe HappyMapper do
878
881
  first_event.timestamp.should == '2009-01-02T06:00:00'
879
882
  first_event.address.city.should == 'WICHITA'
880
883
  first_event.address.countrycode.should == 'US'
881
- first_event.address.residential.should be_false
884
+ first_event.address.residential.should be_falsey
882
885
  first_event.address.state.should == 'KS'
883
886
  first_event.address.zip.should == '67226'
884
887
  last_event = events[-1]
@@ -887,7 +890,7 @@ describe HappyMapper do
887
890
  last_event.timestamp.should == '2008-12-27T09:40:00'
888
891
  last_event.address.city.should == 'LONGWOOD'
889
892
  last_event.address.countrycode.should == 'US'
890
- last_event.address.residential.should be_false
893
+ last_event.address.residential.should be_falsey
891
894
  last_event.address.state.should == 'FL'
892
895
  last_event.address.zip.should == '327506398'
893
896
  track.tran_detail.cust_tran_id.should == '20090102-111321'
@@ -920,12 +923,12 @@ describe HappyMapper do
920
923
  it "should allow instantiating with a string" do
921
924
  module StringFoo
922
925
  class Bar
923
- include HappyMapper
926
+ include XmlMapper
924
927
  has_many :things, 'StringFoo::Thing'
925
928
  end
926
929
 
927
930
  class Thing
928
- include HappyMapper
931
+ include XmlMapper
929
932
  end
930
933
  end
931
934
  end
@@ -1077,13 +1080,13 @@ describe HappyMapper do
1077
1080
  context "when letting user set Nokogiri::XML::ParseOptions" do
1078
1081
  let(:default) {
1079
1082
  Class.new do
1080
- include HappyMapper
1083
+ include XmlMapper
1081
1084
  element :item, String
1082
1085
  end
1083
1086
  }
1084
1087
  let(:custom) {
1085
1088
  Class.new do
1086
- include HappyMapper
1089
+ include XmlMapper
1087
1090
  element :item, String
1088
1091
  with_nokogiri_config do |config|
1089
1092
  config.default_xml
@@ -1113,4 +1116,22 @@ describe HappyMapper do
1113
1116
  end
1114
1117
  end
1115
1118
 
1119
+ context 'xml_value' do
1120
+ it 'does not reformat the xml' do
1121
+ xml = fixture_file('unformatted_address.xml')
1122
+ address = Address.parse(xml, single: true)
1123
+
1124
+ expect(address.xml_value).to eq %{<address><street>Milchstrasse</street><housenumber>23</housenumber></address>}
1125
+ end
1126
+ end
1127
+
1128
+ context 'xml_content' do
1129
+ it 'does not reformat the xml' do
1130
+ xml = fixture_file('unformatted_address.xml')
1131
+ address = Address.parse(xml)
1132
+
1133
+ expect(address.xml_content).to eq %{<street>Milchstrasse</street><housenumber>23</housenumber>}
1134
+ end
1135
+ end
1136
+
1116
1137
  end