pump 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,19 +6,19 @@ describe Pump::Xml do
6
6
  let(:xml) { Pump::Xml.new('person', [{:name => :name}]) }
7
7
 
8
8
  it "requires one object" do
9
- lambda{ xml.encode }.should raise_error(ArgumentError)
10
- lambda{ xml.encode(person) }.should_not raise_error
9
+ expect{ xml.encode }.to raise_error(ArgumentError)
10
+ expect{ xml.encode(person) }.not_to raise_error
11
11
  end
12
12
 
13
13
  it "returns xml string" do
14
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n</person>\n")
14
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n</person>\n")
15
15
  end
16
16
 
17
17
  context "with ilegal chars" do
18
18
  let(:person) { Struct.new(:name, :age, :last_name).new("Benny\n\u001APenny", 9, "Hellman") }
19
19
 
20
20
  it "returns xml string" do
21
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Benny\nPenny</name>\n</person>\n")
21
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Benny\nPenny</name>\n</person>\n")
22
22
  end
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ describe Pump::Xml do
28
28
  let(:people) { [person] }
29
29
 
30
30
  it "returns xml string" do
31
- xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n</people>\n")
31
+ expect(xml.encode(people)).to eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n</people>\n")
32
32
  end
33
33
  end
34
34
 
@@ -36,7 +36,7 @@ describe Pump::Xml do
36
36
  let(:people) { [person, Struct.new(:name, :age).new('Carlo', 5)] }
37
37
 
38
38
  it "returns xml string" do
39
- xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n <person>\n <name>Carlo</name>\n </person>\n</people>\n")
39
+ expect(xml.encode(people)).to eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n <person>\n <name>Carlo</name>\n </person>\n</people>\n")
40
40
  end
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ describe Pump::Xml do
44
44
  let(:people) { [] }
45
45
 
46
46
  it "returns xml string" do
47
- xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\"/>\n")
47
+ expect(xml.encode(people)).to eql("#{XML_INSTRUCT}<people type=\"array\"/>\n")
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ describe Pump::Xml do
53
53
  let(:people) { [] }
54
54
 
55
55
  it "returns xml string" do
56
- xml.encode(people).should eql("<people type=\"array\"/>\n")
56
+ expect(xml.encode(people)).to eql("<people type=\"array\"/>\n")
57
57
  end
58
58
  end
59
59
 
@@ -62,7 +62,7 @@ describe Pump::Xml do
62
62
  let(:xml) { Pump::Xml.new('person', [{:name => :name}], :instruct => false, :extra_indent => 1) }
63
63
 
64
64
  it "returns xml string" do
65
- xml.encode(people).should eql(" <people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n </people>\n")
65
+ expect(xml.encode(people)).to eql(" <people type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n </people>\n")
66
66
  end
67
67
  end
68
68
 
@@ -71,7 +71,7 @@ describe Pump::Xml do
71
71
  let(:xml) { Pump::Xml.new('person', [{:name => :name}], :instruct => false, :array_root => "personas") }
72
72
 
73
73
  it "returns xml string" do
74
- xml.encode(people).should eql("<personas type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n</personas>\n")
74
+ expect(xml.encode(people)).to eql("<personas type=\"array\">\n <person>\n <name>Benny</name>\n </person>\n</personas>\n")
75
75
  end
76
76
  end
77
77
  end
@@ -80,7 +80,7 @@ describe Pump::Xml do
80
80
  let(:xml) { Pump::Xml.new('person', [{:name => :name}], :instruct => false) }
81
81
 
82
82
  it "returns xml string" do
83
- xml.encode(person).should eql("<person>\n <name>Benny</name>\n</person>\n")
83
+ expect(xml.encode(person)).to eql("<person>\n <name>Benny</name>\n</person>\n")
84
84
  end
85
85
  end
86
86
 
@@ -88,7 +88,7 @@ describe Pump::Xml do
88
88
  let(:xml) { Pump::Xml.new('person', [{:name => :name}], :instruct => false, :extra_indent => 1) }
89
89
 
90
90
  it "returns xml string" do
91
- xml.encode(person).should eql(" <person>\n <name>Benny</name>\n </person>\n")
91
+ expect(xml.encode(person)).to eql(" <person>\n <name>Benny</name>\n </person>\n")
92
92
  end
93
93
  end
94
94
 
@@ -101,7 +101,7 @@ describe Pump::Xml do
101
101
  end
102
102
 
103
103
  it do
104
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n <age type=\"integer\">9</age>\n</person>\n")
104
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n <age type=\"integer\">9</age>\n</person>\n")
105
105
  end
106
106
  end
107
107
 
@@ -109,7 +109,7 @@ describe Pump::Xml do
109
109
  let(:person) { Struct.new(:name, :age).new('', 9) }
110
110
 
111
111
  it do
112
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name></name>\n</person>\n")
112
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name></name>\n</person>\n")
113
113
  end
114
114
  end
115
115
 
@@ -117,7 +117,7 @@ describe Pump::Xml do
117
117
  let(:person) { Struct.new(:name, :age).new(nil, 9) }
118
118
 
119
119
  it do
120
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name nil=\"true\"/>\n</person>\n")
120
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name nil=\"true\"/>\n</person>\n")
121
121
  end
122
122
  end
123
123
 
@@ -125,7 +125,7 @@ describe Pump::Xml do
125
125
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age}]) }
126
126
 
127
127
  it "returns xml string" do
128
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n <age>9</age>\n</person>\n")
128
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Benny</name>\n <age>9</age>\n</person>\n")
129
129
  end
130
130
  end
131
131
 
@@ -133,7 +133,7 @@ describe Pump::Xml do
133
133
  let(:xml) { Pump::Xml.new('person', [{"last-name" => :last_name}]) }
134
134
 
135
135
  it "returns xml string" do
136
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <last-name>Hellman</last-name>\n</person>\n")
136
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <last-name>Hellman</last-name>\n</person>\n")
137
137
  end
138
138
  end
139
139
 
@@ -142,7 +142,7 @@ describe Pump::Xml do
142
142
  let(:xml) { Pump::Xml.new('person', [{:at => :at, :attributes => {:type => 'date'}}]) }
143
143
 
144
144
  it "returns xml string" do
145
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <at type=\"date\">2013-02-07</at>\n</person>\n")
145
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <at type=\"date\">2013-02-07</at>\n</person>\n")
146
146
  end
147
147
  end
148
148
 
@@ -151,14 +151,14 @@ describe Pump::Xml do
151
151
  let(:xml) { Pump::Xml.new('person', [{:at => :at, :typecast => :xmlschema, :attributes => {:type => 'datetime'}}]) }
152
152
 
153
153
  it "returns xml string" do
154
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <at type=\"datetime\">2013-02-07T00:00:00Z</at>\n</person>\n")
154
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <at type=\"datetime\">2013-02-07T00:00:00Z</at>\n</person>\n")
155
155
  end
156
156
 
157
157
  context "but nil" do
158
158
  let(:person) { Struct.new(:at).new(nil) }
159
159
 
160
160
  it "returns xml string" do
161
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <at type=\"datetime\" nil=\"true\"/>\n</person>\n")
161
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <at type=\"datetime\" nil=\"true\"/>\n</person>\n")
162
162
  end
163
163
  end
164
164
  end
@@ -170,7 +170,7 @@ describe Pump::Xml do
170
170
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :if => :is_young}]) }
171
171
 
172
172
  it "skips tag on false" do
173
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
173
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
174
174
  end
175
175
  end
176
176
 
@@ -178,7 +178,7 @@ describe Pump::Xml do
178
178
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :unless => :is_old}]) }
179
179
 
180
180
  it "skips tag on false" do
181
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
181
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
182
182
  end
183
183
  end
184
184
 
@@ -187,7 +187,7 @@ describe Pump::Xml do
187
187
  let(:people) { [person, Struct.new(:name, :age).new('Schewardnadse', nil)] }
188
188
 
189
189
  it "skips tag on false" do
190
- xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Gorbatschow</name>\n <age>82</age>\n </person>\n <person>\n <name>Schewardnadse</name>\n </person>\n</people>\n")
190
+ expect(xml.encode(people)).to eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Gorbatschow</name>\n <age>82</age>\n </person>\n <person>\n <name>Schewardnadse</name>\n </person>\n</people>\n")
191
191
  end
192
192
  end
193
193
  end
@@ -199,7 +199,7 @@ describe Pump::Xml do
199
199
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :static_value => 12}]) }
200
200
 
201
201
  it "returns given static_value" do
202
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age>12</age>\n</person>\n")
202
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age>12</age>\n</person>\n")
203
203
  end
204
204
  end
205
205
 
@@ -207,7 +207,7 @@ describe Pump::Xml do
207
207
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :static_value => nil}]) }
208
208
 
209
209
  it "returns given static_value" do
210
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age nil=\"true\"/>\n</person>\n")
210
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age nil=\"true\"/>\n</person>\n")
211
211
  end
212
212
  end
213
213
 
@@ -215,7 +215,7 @@ describe Pump::Xml do
215
215
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :static_value => 12, :if => :is_yount}]) }
216
216
 
217
217
  it "returns given static_value" do
218
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
218
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n</person>\n")
219
219
  end
220
220
  end
221
221
 
@@ -223,7 +223,7 @@ describe Pump::Xml do
223
223
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age, :static_value => 12, :unless => :is_yount}]) }
224
224
 
225
225
  it "returns given static_value" do
226
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age>12</age>\n</person>\n")
226
+ expect(xml.encode(person)).to eql("#{XML_INSTRUCT}<person>\n <name>Gorbatschow</name>\n <age>12</age>\n</person>\n")
227
227
  end
228
228
  end
229
229
  end
@@ -232,14 +232,14 @@ describe Pump::Xml do
232
232
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:parent => [{:name => :name}, {:age => :age}]}], :instruct => false) }
233
233
 
234
234
  it "returns xml string" do
235
- xml.encode(person).should eql("<person>\n <name>Benny</name>\n <parent>\n <name>Benny</name>\n <age>9</age>\n </parent>\n</person>\n")
235
+ expect(xml.encode(person)).to eql("<person>\n <name>Benny</name>\n <parent>\n <name>Benny</name>\n <age>9</age>\n </parent>\n</person>\n")
236
236
  end
237
237
 
238
238
  context "with static_value = nil" do
239
239
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:parent => [{:name => :name}, {:age => :age}], :static_value => nil}], :instruct => false) }
240
240
 
241
241
  it "uses static value" do
242
- xml.encode(person).should eql("<person>\n <name>Benny</name>\n <parent nil=\"true\"/>\n</person>\n")
242
+ expect(xml.encode(person)).to eql("<person>\n <name>Benny</name>\n <parent nil=\"true\"/>\n</person>\n")
243
243
  end
244
244
  end
245
245
 
@@ -247,7 +247,7 @@ describe Pump::Xml do
247
247
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:parent => [{:name => :name}, {:age => :age}], :static_value => ""}], :instruct => false) }
248
248
 
249
249
  it "uses static value" do
250
- xml.encode(person).should eql("<person>\n <name>Benny</name>\n <parent></parent>\n</person>\n")
250
+ expect(xml.encode(person)).to eql("<person>\n <name>Benny</name>\n <parent></parent>\n</person>\n")
251
251
  end
252
252
  end
253
253
  end
@@ -263,7 +263,7 @@ describe Pump::Xml do
263
263
  :array => [{:name => :name}]}], :instruct => false) }
264
264
 
265
265
  it "returns xml string" do
266
- xml.encode(person).should eql("<person>\n <name>Gustav</name>\n <children type=\"array\">\n <child>\n <name>Lilly</name>\n </child>\n <child>\n <name>Lena</name>\n </child>\n </children>\n</person>\n")
266
+ expect(xml.encode(person)).to eql("<person>\n <name>Gustav</name>\n <children type=\"array\">\n <child>\n <name>Lilly</name>\n </child>\n <child>\n <name>Lena</name>\n </child>\n </children>\n</person>\n")
267
267
  end
268
268
 
269
269
  context "overwriting child name" do
@@ -271,7 +271,7 @@ describe Pump::Xml do
271
271
  :array => [{:name => :name}], :child_root => 'kid'}], :instruct => false) }
272
272
 
273
273
  it "returns xml string" do
274
- xml.encode(person).should eql("<person>\n <name>Gustav</name>\n <children type=\"array\">\n <kid>\n <name>Lilly</name>\n </kid>\n <kid>\n <name>Lena</name>\n </kid>\n </children>\n</person>\n")
274
+ expect(xml.encode(person)).to eql("<person>\n <name>Gustav</name>\n <children type=\"array\">\n <kid>\n <name>Lilly</name>\n </kid>\n <kid>\n <name>Lena</name>\n </kid>\n </children>\n</person>\n")
275
275
  end
276
276
  end
277
277
 
@@ -279,7 +279,7 @@ describe Pump::Xml do
279
279
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:children => :children,
280
280
  :array => [{:name => :name}], :static_value => nil}], :instruct => false) }
281
281
  it "uses static value" do
282
- xml.encode(person).should eql("<person>\n <name>Gustav</name>\n <children type=\"array\"/>\n</person>\n")
282
+ expect(xml.encode(person)).to eql("<person>\n <name>Gustav</name>\n <children type=\"array\"/>\n</person>\n")
283
283
  end
284
284
  end
285
285
 
@@ -287,7 +287,7 @@ describe Pump::Xml do
287
287
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:children => :children,
288
288
  :array => [{:name => :name}], :static_value => ''}], :instruct => false) }
289
289
  it "uses static value" do
290
- xml.encode(person).should eql("<person>\n <name>Gustav</name>\n <children type=\"array\"></children>\n</person>\n")
290
+ expect(xml.encode(person)).to eql("<person>\n <name>Gustav</name>\n <children type=\"array\"></children>\n</person>\n")
291
291
  end
292
292
  end
293
293
  end
@@ -297,7 +297,7 @@ describe Pump::Xml do
297
297
  let(:xml) { Pump::Xml.new('my_person', [{"first_name" => :name}]) }
298
298
 
299
299
  it "returns xml string with dashes" do
300
- xml.encode(person).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my-person>\n <first-name>Benny</first-name>\n</my-person>\n")
300
+ expect(xml.encode(person)).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my-person>\n <first-name>Benny</first-name>\n</my-person>\n")
301
301
  end
302
302
  end
303
303
 
@@ -305,7 +305,7 @@ describe Pump::Xml do
305
305
  let(:xml) { Pump::Xml.new('my_person', [{"first-name" => :name}], :xml_key_style => :dashes) }
306
306
 
307
307
  it "returns xml string with dashes" do
308
- xml.encode(person).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my-person>\n <first-name>Benny</first-name>\n</my-person>\n")
308
+ expect(xml.encode(person)).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my-person>\n <first-name>Benny</first-name>\n</my-person>\n")
309
309
  end
310
310
  end
311
311
 
@@ -313,7 +313,7 @@ describe Pump::Xml do
313
313
  let(:xml) { Pump::Xml.new('my_person', [{"first-name" => :name}], :xml_key_style => :underscores) }
314
314
 
315
315
  it "returns xml string with underscores" do
316
- xml.encode(person).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my_person>\n <first_name>Benny</first_name>\n</my_person>\n")
316
+ expect(xml.encode(person)).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my_person>\n <first_name>Benny</first_name>\n</my_person>\n")
317
317
  end
318
318
 
319
319
  context "on complex array like" do
@@ -327,7 +327,7 @@ describe Pump::Xml do
327
327
  :array => [{:"child-name" => :name}]}], :xml_key_style => :underscores) }
328
328
 
329
329
  it "returns xml string with underscores" do
330
- xml.encode(person).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my_person>\n <my_name>Gustav</my_name>\n <the_children type=\"array\">\n <the_child>\n <child_name>Lilly</child_name>\n </the_child>\n <the_child>\n <child_name>Lena</child_name>\n </the_child>\n </the_children>\n</my_person>\n")
330
+ expect(xml.encode(person)).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<my_person>\n <my_name>Gustav</my_name>\n <the_children type=\"array\">\n <the_child>\n <child_name>Lilly</child_name>\n </the_child>\n <the_child>\n <child_name>Lena</child_name>\n </the_child>\n </the_children>\n</my_person>\n")
331
331
  end
332
332
  end
333
333
 
@@ -335,7 +335,7 @@ describe Pump::Xml do
335
335
  let(:xml) { Pump::Xml.new('a-person', [{:"my-name" => :name}, {:"the-parent" => [{:"a-name" => :name}, {:"la-age" => :age}]}], :xml_key_style => :underscores) }
336
336
 
337
337
  it "returns xml string with underscores" do
338
- xml.encode(person).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a_person>\n <my_name>Benny</my_name>\n <the_parent>\n <a_name>Benny</a_name>\n <la_age>9</la_age>\n </the_parent>\n</a_person>\n")
338
+ expect(xml.encode(person)).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a_person>\n <my_name>Benny</my_name>\n <the_parent>\n <a_name>Benny</a_name>\n <la_age>9</la_age>\n </the_parent>\n</a_person>\n")
339
339
  end
340
340
  end
341
341
  end
@@ -348,23 +348,23 @@ describe Pump::Xml do
348
348
  ])}
349
349
 
350
350
  it "returns only specified fields" do
351
- xml.encode(person, :fields => ['name']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n</person>\n")
352
- xml.encode(person, :fields => ['age']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <age>9</age>\n</person>\n")
351
+ expect(xml.encode(person, :fields => ['name'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n</person>\n")
352
+ expect(xml.encode(person, :fields => ['age'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <age>9</age>\n</person>\n")
353
353
  end
354
354
 
355
355
  it "ignores unknown fields" do
356
- xml.encode(person, :fields => ['name', 'unknown']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n</person>\n")
357
- xml.encode(person, :fields => ['unknown']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n</person>\n")
356
+ expect(xml.encode(person, :fields => ['name', 'unknown'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n</person>\n")
357
+ expect(xml.encode(person, :fields => ['unknown'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n</person>\n")
358
358
  end
359
359
 
360
360
  it "accepts dasherized and underscored field names" do
361
- xml.encode(person, :fields => ['name', 'last-name']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n <last-name>Hellman</last-name>\n</person>\n")
362
- xml.encode(person, :fields => ['name', 'last_name']).should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n <last-name>Hellman</last-name>\n</person>\n")
361
+ expect(xml.encode(person, :fields => ['name', 'last-name'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n <last-name>Hellman</last-name>\n</person>\n")
362
+ expect(xml.encode(person, :fields => ['name', 'last_name'])).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n <last-name>Hellman</last-name>\n</person>\n")
363
363
  end
364
364
 
365
365
  context "deep hash-like nesting" do
366
366
  it "adds all keys if fields contains parent" do
367
- xml.encode(person, :fields => ['name', 'parent']).should eql(
367
+ expect(xml.encode(person, :fields => ['name', 'parent'])).to eql(
368
368
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Benny</name>\n <parent>\n <name>Benny</name>\n <age>9</age>\n </parent>\n</person>\n"
369
369
  )
370
370
  end
@@ -381,7 +381,7 @@ describe Pump::Xml do
381
381
  :array => [{:name => :name}, {:age => :age}]}]) }
382
382
 
383
383
  it "adds all keys if fields contains children" do
384
- xml.encode(person, :fields => ['name', 'children']).should eql(
384
+ expect(xml.encode(person, :fields => ['name', 'children'])).to eql(
385
385
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Gustav</name>\n <children type=\"array\">\n <child>\n <name>Lilly</name>\n <age>2</age>\n </child>\n <child>\n <name>Lena</name>\n <age>3</age>\n </child>\n </children>\n</person>\n"
386
386
  )
387
387
  end
@@ -398,7 +398,7 @@ describe Pump::Xml do
398
398
  let(:xml) { Pump::Xml.new('person', [{:name => :name}, {:age => :age}]) }
399
399
 
400
400
  it "returns only specified fields" do
401
- xml.encode(people, :fields => ['name']).should eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Gustav</name>\n </person>\n <person>\n <name>Mary</name>\n </person>\n</people>\n")
401
+ expect(xml.encode(people, :fields => ['name'])).to eql("#{XML_INSTRUCT}<people type=\"array\">\n <person>\n <name>Gustav</name>\n </person>\n <person>\n <name>Mary</name>\n </person>\n</people>\n")
402
402
  end
403
403
  end
404
404
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/../lib/pump.rb'
2
2
 
3
+ require 'rspec/its'
4
+
5
+ require 'active_support/json'
6
+ ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
7
+ ActiveSupport::JSON::Encoding.time_precision = 0
8
+
3
9
  XML_INSTRUCT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
4
10
 
5
11
  RSpec.configure do |config|
6
- config.treat_symbols_as_metadata_keys_with_true_values = true
7
12
  config.run_all_when_everything_filtered = true
8
13
  config.filter_run :focus
9
14
  config.order = 'random'
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Munz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-its
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 2.12.0
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 2.12.0
68
+ version: '0'
55
69
  description: Fast but inflexible XML and JSON encoding for ruby objects.
56
70
  email:
57
71
  - sebastian@yo.lk
@@ -59,20 +73,22 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
- - .gitignore
63
- - .rspec
64
- - .ruby-version
65
- - .travis.yml
66
- - .yardopts
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".ruby-version"
79
+ - ".travis.yml"
80
+ - ".yardopts"
67
81
  - CHANGES.md
68
82
  - Gemfile
69
83
  - Guardfile
70
84
  - MIT-LICENSE
71
85
  - README.md
72
86
  - Rakefile
87
+ - benchmarks/Gemfile
88
+ - benchmarks/Gemfile.lock
73
89
  - benchmarks/encode.rb
74
- - gemfiles/activesupport-3-2
75
90
  - gemfiles/activesupport-4
91
+ - gemfiles/activesupport-5
76
92
  - lib/pump.rb
77
93
  - lib/pump/array.rb
78
94
  - lib/pump/collection.rb
@@ -108,17 +124,17 @@ require_paths:
108
124
  - lib
109
125
  required_ruby_version: !ruby/object:Gem::Requirement
110
126
  requirements:
111
- - - '>='
127
+ - - ">="
112
128
  - !ruby/object:Gem::Version
113
129
  version: '0'
114
130
  required_rubygems_version: !ruby/object:Gem::Requirement
115
131
  requirements:
116
- - - '>='
132
+ - - ">="
117
133
  - !ruby/object:Gem::Version
118
134
  version: '0'
119
135
  requirements: []
120
136
  rubyforge_project:
121
- rubygems_version: 2.0.3
137
+ rubygems_version: 2.6.11
122
138
  signing_key:
123
139
  specification_version: 4
124
140
  summary: Fast but inflexible XML and JSON encoding for ruby objects.
@@ -1,7 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "activemodel", "3.2.13"
4
- gem "oj"
5
-
6
- gem 'rspec', '>= 2.14'
7
- gem 'rake'