roxml 3.3.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +7 -0
  3. data/Gemfile +9 -6
  4. data/Gemfile.lock +96 -40
  5. data/History.txt +9 -0
  6. data/README.rdoc +3 -2
  7. data/Rakefile +6 -9
  8. data/VERSION +1 -1
  9. data/examples/search_query.rb +17 -0
  10. data/lib/roxml.rb +8 -2
  11. data/lib/roxml/definition.rb +2 -7
  12. data/lib/roxml/xml/references.rb +22 -7
  13. data/roxml.gemspec +48 -36
  14. data/spec/definition_spec.rb +81 -101
  15. data/spec/examples/active_record_spec.rb +13 -13
  16. data/spec/examples/amazon_spec.rb +13 -13
  17. data/spec/examples/current_weather_spec.rb +6 -6
  18. data/spec/examples/dashed_elements_spec.rb +3 -3
  19. data/spec/examples/library_spec.rb +3 -3
  20. data/spec/examples/library_with_fines_spec.rb +7 -7
  21. data/spec/examples/person_spec.rb +3 -3
  22. data/spec/examples/post_spec.rb +4 -4
  23. data/spec/examples/search_query_spec.rb +26 -0
  24. data/spec/examples/twitter_spec.rb +4 -4
  25. data/spec/reference_spec.rb +2 -2
  26. data/spec/regression_spec.rb +13 -8
  27. data/spec/roxml_spec.rb +30 -43
  28. data/spec/shared_specs.rb +2 -2
  29. data/spec/spec_helper.rb +2 -0
  30. data/spec/xml/array_spec.rb +2 -2
  31. data/spec/xml/attributes_spec.rb +7 -7
  32. data/spec/xml/encoding_spec.rb +9 -9
  33. data/spec/xml/namespace_spec.rb +40 -21
  34. data/spec/xml/namespaces_spec.rb +3 -3
  35. data/spec/xml/object_spec.rb +7 -7
  36. data/spec/xml/parser_spec.rb +2 -2
  37. data/spec/xml/text_spec.rb +6 -6
  38. data/test/fixtures/book_with_octal_pages.xml +2 -3
  39. data/test/test_helper.rb +1 -2
  40. data/test/unit/definition_test.rb +26 -27
  41. data/test/unit/deprecations_test.rb +23 -2
  42. data/test/unit/to_xml_test.rb +7 -7
  43. data/test/unit/xml_attribute_test.rb +3 -2
  44. data/test/unit/xml_block_test.rb +3 -2
  45. data/test/unit/xml_bool_test.rb +7 -8
  46. data/test/unit/xml_convention_test.rb +4 -3
  47. data/test/unit/xml_hash_test.rb +5 -13
  48. data/test/unit/xml_initialize_test.rb +4 -3
  49. data/test/unit/xml_name_test.rb +3 -2
  50. data/test/unit/xml_namespace_test.rb +4 -3
  51. data/test/unit/xml_object_test.rb +8 -7
  52. data/test/unit/xml_required_test.rb +7 -6
  53. data/test/unit/xml_text_test.rb +3 -2
  54. data/website/index.html +11 -11
  55. metadata +115 -60
@@ -4,19 +4,19 @@ require_relative './spec_helper'
4
4
  describe ROXML::Definition do
5
5
  describe "#name_explicit?" do
6
6
  it "should indicate whether from option is present" do
7
- ROXML::Definition.new(:element, :from => 'somewhere').name_explicit?.should be_true
8
- ROXML::Definition.new(:element).name_explicit?.should be_false
7
+ expect(ROXML::Definition.new(:element, :from => 'somewhere').name_explicit?).to be_truthy
8
+ expect(ROXML::Definition.new(:element).name_explicit?).to be_falsey
9
9
  end
10
10
 
11
11
  it "should not consider name proxies as explicit" do
12
- ROXML::Definition.new(:element, :from => :attr).name_explicit?.should be_false
13
- ROXML::Definition.new(:element, :from => :content).name_explicit?.should be_false
12
+ expect(ROXML::Definition.new(:element, :from => :attr).name_explicit?).to be_falsey
13
+ expect(ROXML::Definition.new(:element, :from => :content).name_explicit?).to be_falsey
14
14
  end
15
15
  end
16
16
 
17
17
  shared_examples_for "DateTime reference" do
18
18
  it "should return nil on empty string" do
19
- @subject.blocks.first.call(" ").should be_nil
19
+ expect(@subject.blocks.first.call(" ")).to be_nil
20
20
  end
21
21
 
22
22
  it "should return a time version of the string" do
@@ -25,14 +25,14 @@ describe ROXML::Definition do
25
25
 
26
26
  context "when passed an array of values" do
27
27
  it "should timify all of them" do
28
- @subject.blocks.first.call(["12:05pm, September 3rd, 1970", "3:00pm, May 22, 1700"]).map(&:to_s).should == ["1970-09-03T12:05:00+00:00", "1700-05-22T15:00:00+00:00"]
28
+ expect(@subject.blocks.first.call(["12:05pm, September 3rd, 1970", "3:00pm, May 22, 1700"]).map(&:to_s)).to eq(["1970-09-03T12:05:00+00:00", "1700-05-22T15:00:00+00:00"])
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
33
  shared_examples_for "Date reference" do
34
34
  it "should return nil on empty string" do
35
- @subject.blocks.first.call(" ").should be_nil
35
+ expect(@subject.blocks.first.call(" ")).to be_nil
36
36
  end
37
37
 
38
38
  it "should return a time version of the string" do
@@ -41,26 +41,26 @@ describe ROXML::Definition do
41
41
 
42
42
  context "when passed an array of values" do
43
43
  it "should timify all of them" do
44
- @subject.blocks.first.call(["September 3rd, 1970", "1776-07-04"]).map(&:to_s).should == ["1970-09-03", "1776-07-04"]
44
+ expect(@subject.blocks.first.call(["September 3rd, 1970", "1776-07-04"]).map(&:to_s)).to eq(["1970-09-03", "1776-07-04"])
45
45
  end
46
46
  end
47
47
  end
48
48
 
49
49
  it "should unescape xml entities" do
50
- ROXML::Definition.new(:questions, :as => []).to_ref(RoxmlObject.new).value_in(%{
50
+ expect(ROXML::Definition.new(:questions, :as => []).to_ref(RoxmlObject.new).value_in(%{
51
51
  <xml>
52
52
  <question>&quot;Wickard &amp; Filburn&quot; &gt;</question>
53
53
  <question> &lt; McCulloch &amp; Maryland?</question>
54
54
  </xml>
55
- }).should == ["\"Wickard & Filburn\" >", " < McCulloch & Maryland?"]
55
+ })).to eq(["\"Wickard & Filburn\" >", " < McCulloch & Maryland?"])
56
56
  end
57
57
 
58
58
  it "should unescape utf characters in xml" do
59
- ROXML::Definition.new(:questions, :as => []).to_ref(RoxmlObject.new).value_in(%{
59
+ expect(ROXML::Definition.new(:questions, :as => []).to_ref(RoxmlObject.new).value_in(%{
60
60
  <xml>
61
61
  <question>ROXML\342\204\242</question>
62
62
  </xml>
63
- }).should == ["ROXML™"]
63
+ })).to eq(["ROXML™"])
64
64
  end
65
65
 
66
66
  describe "attr name" do
@@ -87,8 +87,8 @@ describe ROXML::Definition do
87
87
  describe "=> []" do
88
88
  it "should means array of texts" do
89
89
  opts = ROXML::Definition.new(:authors, :as => [])
90
- opts.array?.should be_true
91
- opts.sought_type.should == :text
90
+ expect(opts.array?).to be_truthy
91
+ expect(opts.sought_type).to eq(:text)
92
92
  end
93
93
  end
94
94
 
@@ -99,7 +99,7 @@ describe ROXML::Definition do
99
99
 
100
100
  it "should store type" do
101
101
  opts = ROXML::Definition.new(:name, :as => RoxmlClass)
102
- opts.sought_type.should == RoxmlClass
102
+ expect(opts.sought_type).to eq(RoxmlClass)
103
103
  end
104
104
  end
105
105
 
@@ -112,35 +112,35 @@ describe ROXML::Definition do
112
112
 
113
113
  it "should accept type" do
114
114
  opts = ROXML::Definition.new(:name, :as => OctalInteger)
115
- opts.sought_type.should == OctalInteger
115
+ expect(opts.sought_type).to eq(OctalInteger)
116
116
  end
117
117
  end
118
118
 
119
119
  describe "=> NonRoxmlClass" do
120
120
  it "should fail with a warning" do
121
- proc { ROXML::Definition.new(:authors, :as => Module) }.should raise_error(ArgumentError)
121
+ expect { ROXML::Definition.new(:authors, :as => Module) }.to raise_error(ArgumentError)
122
122
  end
123
123
  end
124
124
 
125
125
  describe "=> [NonRoxmlClass]" do
126
126
  it "should raise" do
127
- proc { ROXML::Definition.new(:authors, :as => [Module]) }.should raise_error(ArgumentError)
127
+ expect { ROXML::Definition.new(:authors, :as => [Module]) }.to raise_error(ArgumentError)
128
128
  end
129
129
  end
130
130
 
131
131
  describe "=> {}" do
132
132
  shared_examples_for "hash options declaration" do
133
133
  it "should represent a hash" do
134
- @opts.hash?.should be_true
134
+ expect(@opts.hash?).to be_truthy
135
135
  end
136
136
 
137
137
  it "should have hash definition" do
138
- {@opts.hash.key.sought_type => @opts.hash.key.name}.should == @hash_args[:key]
139
- {@opts.hash.value.sought_type => @opts.hash.value.name}.should == @hash_args[:value]
138
+ expect({@opts.hash.key.sought_type => @opts.hash.key.name}).to eq(@hash_args[:key])
139
+ expect({@opts.hash.value.sought_type => @opts.hash.value.name}).to eq(@hash_args[:value])
140
140
  end
141
141
 
142
142
  it "should not represent an array" do
143
- @opts.array?.should be_false
143
+ expect(@opts.array?).to be_falsey
144
144
  end
145
145
  end
146
146
 
@@ -193,32 +193,32 @@ describe ROXML::Definition do
193
193
  end
194
194
 
195
195
  it "should be detected as array reference" do
196
- @opts.array?.should be_true
196
+ expect(@opts.array?).to be_truthy
197
197
  end
198
198
 
199
199
  it "should be normal otherwise" do
200
- @opts.sought_type.should == :text
201
- @opts.blocks.size.should == 1
200
+ expect(@opts.sought_type).to eq(:text)
201
+ expect(@opts.blocks.size).to eq(1)
202
202
  end
203
203
  end
204
204
 
205
205
  it "should have no blocks without a shorthand" do
206
- ROXML::Definition.new(:count).blocks.should be_empty
206
+ expect(ROXML::Definition.new(:count).blocks).to be_empty
207
207
  end
208
208
 
209
209
  it "should raise on unknown :as" do
210
- proc { ROXML::Definition.new(:count, :as => :bogus) }.should raise_error(ArgumentError)
211
- proc { ROXML::Definition.new(:count, :as => :foat) }.should raise_error(ArgumentError)
210
+ expect { ROXML::Definition.new(:count, :as => :bogus) }.to raise_error(ArgumentError)
211
+ expect { ROXML::Definition.new(:count, :as => :foat) }.to raise_error(ArgumentError)
212
212
  end
213
213
 
214
214
  shared_examples_for "block shorthand type declaration" do
215
215
  it "should translate nil to nil" do
216
- @definition.blocks.first.call(nil).should be_nil
216
+ expect(@definition.blocks.first.call(nil)).to be_nil
217
217
  end
218
218
 
219
219
  it "should translate empty strings to nil" do
220
- @definition.blocks.first.call("").should be_nil
221
- @definition.blocks.first.call(" ").should be_nil
220
+ expect(@definition.blocks.first.call("")).to be_nil
221
+ expect(@definition.blocks.first.call(" ")).to be_nil
222
222
  end
223
223
  end
224
224
 
@@ -230,20 +230,21 @@ describe ROXML::Definition do
230
230
  it_should_behave_like "block shorthand type declaration"
231
231
 
232
232
  it "should translate text to integers" do
233
- @definition.blocks.first['3'].should == 3
234
- @definition.blocks.first['792'].should == 792
233
+ expect(@definition.blocks.first['3']).to eq(3)
234
+ expect(@definition.blocks.first['792']).to eq(792)
235
+ expect(@definition.blocks.first['08']).to eq(8)
236
+ expect(@definition.blocks.first['279.23']).to eq(279)
235
237
  end
236
238
 
237
- it "should raise on non-integer values" do
238
- proc { @definition.blocks.first['08'] }.should raise_error(ArgumentError)
239
- proc { @definition.blocks.first['793.12'] }.should raise_error(ArgumentError)
240
- proc { @definition.blocks.first['junk 11'] }.should raise_error(ArgumentError)
241
- proc { @definition.blocks.first['11sttf'] }.should raise_error(ArgumentError)
239
+ it "should extract whatever is possible and fall back to 0" do
240
+ expect(@definition.blocks.first['junk 11']).to eql(0)
241
+ expect(@definition.blocks.first['.?sttf']).to eql(0)
242
+ expect(@definition.blocks.first['11sttf']).to eql(11)
242
243
  end
243
244
 
244
245
  context "when passed an array" do
245
246
  it "should translate the array elements to integer" do
246
- @definition.blocks.first.call(["792", "12", "328"]).should == [792, 12, 328]
247
+ expect(@definition.blocks.first.call(["792", "12", "328"])).to eq([792, 12, 328])
247
248
  end
248
249
  end
249
250
  end
@@ -256,18 +257,18 @@ describe ROXML::Definition do
256
257
  it_should_behave_like "block shorthand type declaration"
257
258
 
258
259
  it "should translate text to float" do
259
- @definition.blocks.first['3'].should == 3.0
260
- @definition.blocks.first['12.7'].should == 12.7
260
+ expect(@definition.blocks.first['3']).to eq(3.0)
261
+ expect(@definition.blocks.first['12.7']).to eq(12.7)
261
262
  end
262
263
 
263
264
  it "should raise on non-float values" do
264
- proc { @definition.blocks.first['junk 11.3'] }.should raise_error(ArgumentError)
265
- proc { @definition.blocks.first['11.1sttf'] }.should raise_error(ArgumentError)
265
+ expect { @definition.blocks.first['junk 11.3'] }.to raise_error(ArgumentError)
266
+ expect { @definition.blocks.first['11.1sttf'] }.to raise_error(ArgumentError)
266
267
  end
267
268
 
268
269
  context "when passed an array" do
269
270
  it "should translate the array elements to integer" do
270
- @definition.blocks.first.call(["792.13", "240", "3.14"]).should == [792.13, 240.0, 3.14]
271
+ expect(@definition.blocks.first.call(["792.13", "240", "3.14"])).to eq([792.13, 240.0, 3.14])
271
272
  end
272
273
  end
273
274
  end
@@ -280,67 +281,46 @@ describe ROXML::Definition do
280
281
  it_should_behave_like "block shorthand type declaration"
281
282
 
282
283
  it "should translate text to decimal numbers" do
283
- @definition.blocks.first['3'].should == BigDecimal.new("3.0")
284
- @definition.blocks.first['0.3'].should == BigDecimal.new("0.3")
285
- end
286
-
287
- it "should extract what it can, and fall back to 0" do
288
- @definition.blocks.first['junk 11'].should eql(BigDecimal.new("0"))
289
- @definition.blocks.first['11sttf'].should eql(BigDecimal.new("11.0"))
284
+ expect(@definition.blocks.first['3']).to eq(BigDecimal.new("3.0"))
285
+ expect(@definition.blocks.first['0.3']).to eq(BigDecimal.new("0.3"))
290
286
  end
291
287
 
292
- context "when passed an array" do
293
- it "should translate the array elements to integer" do
294
- @definition.blocks.first.call(["12.1", "328.2"]).should == [BigDecimal.new("12.1"), BigDecimal.new("328.2")]
288
+ # Ruby behavior of BigDecimal changed in 2.4, this test is not valid on older rubies
289
+ if RUBY_VERSION >= "2.4"
290
+ it "should raise on non-decimal values" do
291
+ expect { @definition.blocks.first['junk 11'] }.to raise_error(ArgumentError)
295
292
  end
296
293
  end
297
- end
298
294
 
299
- describe "Fixnum" do
300
- before do
301
- @definition = ROXML::Definition.new(:fixnumvalue, :as => Fixnum)
302
- end
303
-
304
- it_should_behave_like "block shorthand type declaration"
305
-
306
- it "should translate text to integers" do
307
- @definition.blocks.first['3'].should == 3
308
- @definition.blocks.first['792'].should == 792
309
- @definition.blocks.first['08'].should == 8
310
- @definition.blocks.first['279.23'].should == 279
311
- end
312
-
313
- it "should extract whatever is possible and fall back to 0" do
314
- @definition.blocks.first['junk 11'].should eql(0)
315
- @definition.blocks.first['.?sttf'].should eql(0)
316
- @definition.blocks.first['11sttf'].should eql(11)
295
+ it "should extract what it can" do
296
+ expect(@definition.blocks.first['11sttf']).to eql(BigDecimal.new("11.0"))
317
297
  end
318
298
 
319
299
  context "when passed an array" do
320
300
  it "should translate the array elements to integer" do
321
- @definition.blocks.first.call(["792", "12", "328"]).should == [792, 12, 328]
301
+ expect(@definition.blocks.first.call(["12.1", "328.2"])).to eq([BigDecimal.new("12.1"), BigDecimal.new("328.2")])
322
302
  end
323
303
  end
324
304
  end
325
305
 
326
306
  describe ":bool" do
327
307
  it "should boolify individual values" do
328
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("1").should be_true
329
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("True").should be_true
330
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("Yes").should be_true
308
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("1")).to be_truthy
309
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("True")).to be_truthy
310
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("Yes")).to be_truthy
331
311
  end
332
312
 
333
313
  context "when an array is passed in" do
334
314
  it "should boolify arrays of values" do
335
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("0").should be_false
336
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("false").should be_false
337
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("nO").should be_false
315
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("0")).to be_falsey
316
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("false")).to be_falsey
317
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("nO")).to be_falsey
338
318
  end
339
319
  end
340
320
 
341
321
  context "when no value is detected" do
342
322
  it "should return nil" do
343
- ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("junk").should be_nil
323
+ expect(ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("junk")).to be_nil
344
324
  end
345
325
 
346
326
  context "when a literal block is available" do
@@ -351,16 +331,16 @@ describe ROXML::Definition do
351
331
 
352
332
  describe "Time" do
353
333
  it "should return nil on empty string" do
354
- ROXML::Definition.new(:floatvalue, :as => Time).blocks.first.call(" ").should be_nil
334
+ expect(ROXML::Definition.new(:floatvalue, :as => Time).blocks.first.call(" ")).to be_nil
355
335
  end
356
336
 
357
337
  it "should return a time version of the string" do
358
- ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call("12:31am").min.should == 31
338
+ expect(ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call("12:31am").min).to eq(31)
359
339
  end
360
340
 
361
341
  context "when passed an array of values" do
362
342
  it "should timify all of them" do
363
- ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call(["12:31am", "3:00pm", "11:59pm"]).map(&:min).should == [31, 0, 59]
343
+ expect(ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call(["12:31am", "3:00pm", "11:59pm"]).map(&:min)).to eq([31, 0, 59])
364
344
  end
365
345
  end
366
346
  end
@@ -380,12 +360,12 @@ describe ROXML::Definition do
380
360
  end
381
361
 
382
362
  it "should prohibit multiple shorthands" do
383
- proc { ROXML::Definition.new(:count, :as => [Float, Integer]) }.should raise_error(ArgumentError)
363
+ expect { ROXML::Definition.new(:count, :as => [Float, Integer]) }.to raise_error(ArgumentError)
384
364
  end
385
365
 
386
366
  it "should stack block shorthands with explicit blocks" do
387
- ROXML::Definition.new(:count, :as => Integer) {|val| val.to_i }.blocks.size.should == 2
388
- ROXML::Definition.new(:count, :as => Float) {|val| val.object_id }.blocks.size.should == 2
367
+ expect(ROXML::Definition.new(:count, :as => Integer) {|val| val.to_i }.blocks.size).to eq(2)
368
+ expect(ROXML::Definition.new(:count, :as => Float) {|val| val.object_id }.blocks.size).to eq(2)
389
369
  end
390
370
  end
391
371
  end
@@ -393,17 +373,17 @@ describe ROXML::Definition do
393
373
  describe ":from" do
394
374
  shared_examples_for "attribute reference" do
395
375
  it "should be interpreted as :attr" do
396
- @opts.sought_type.should == :attr
376
+ expect(@opts.sought_type).to eq(:attr)
397
377
  end
398
378
 
399
379
  it "should strip '@' from name" do
400
- @opts.name.should == 'attr_name'
380
+ expect(@opts.name).to eq('attr_name')
401
381
  end
402
382
 
403
383
  it "should unescape xml entities" do
404
- @opts.to_ref(RoxmlObject.new).value_in(%{
384
+ expect(@opts.to_ref(RoxmlObject.new).value_in(%{
405
385
  <question attr_name="&quot;Wickard &amp; Filburn&quot; &gt; / &lt; McCulloch &amp; Marryland?" />
406
- }).should == "\"Wickard & Filburn\" > / < McCulloch & Marryland?"
386
+ })).to eq("\"Wickard & Filburn\" > / < McCulloch & Marryland?")
407
387
  end
408
388
  end
409
389
 
@@ -425,12 +405,12 @@ describe ROXML::Definition do
425
405
 
426
406
  describe ":content" do
427
407
  it "should be recognized" do
428
- ROXML::Definition.new(:author).content?.should be_false
429
- ROXML::Definition.new(:author, :from => :content).content?.should == true
408
+ expect(ROXML::Definition.new(:author).content?).to be_falsey
409
+ expect(ROXML::Definition.new(:author, :from => :content).content?).to eq(true)
430
410
  end
431
411
 
432
412
  it "should be equivalent to :from => '.'" do
433
- ROXML::Definition.new(:author, :from => '.').content?.should == true
413
+ expect(ROXML::Definition.new(:author, :from => '.').content?).to eq(true)
434
414
  end
435
415
  end
436
416
  end
@@ -438,13 +418,13 @@ describe ROXML::Definition do
438
418
  describe ":in" do
439
419
  context "as xpath" do
440
420
  it "should pass through as wrapper" do
441
- ROXML::Definition.new(:manufacturer, :in => './').wrapper.should == './'
421
+ expect(ROXML::Definition.new(:manufacturer, :in => './').wrapper).to eq('./')
442
422
  end
443
423
  end
444
424
 
445
425
  context "as xpath" do
446
426
  it "should pass through as wrapper" do
447
- ROXML::Definition.new(:manufacturer, :in => 'wrapper').wrapper.should == 'wrapper'
427
+ expect(ROXML::Definition.new(:manufacturer, :in => 'wrapper').wrapper).to eq('wrapper')
448
428
  end
449
429
  end
450
430
  end
@@ -454,12 +434,12 @@ describe ROXML::Definition do
454
434
  shared_examples_for "boolean option" do
455
435
  it "should be recognized" do
456
436
  ROXML::Definition.new(:author, :from => :content, @option => true).respond_to?(:"#{@option}?")
457
- ROXML::Definition.new(:author, :from => :content, @option => true).send(:"#{@option}?").should be_true
458
- ROXML::Definition.new(:author, :from => :content, @option => false).send(:"#{@option}?").should be_false
437
+ expect(ROXML::Definition.new(:author, :from => :content, @option => true).send(:"#{@option}?")).to be_truthy
438
+ expect(ROXML::Definition.new(:author, :from => :content, @option => false).send(:"#{@option}?")).to be_falsey
459
439
  end
460
440
 
461
441
  it "should default to false" do
462
- ROXML::Definition.new(:author, :from => :content).send(:"#{@option}?").should be_false
442
+ expect(ROXML::Definition.new(:author, :from => :content).send(:"#{@option}?")).to be_falsey
463
443
  end
464
444
  end
465
445
 
@@ -471,8 +451,8 @@ describe ROXML::Definition do
471
451
  it_should_behave_like "boolean option"
472
452
 
473
453
  it "should not be allowed together with :else" do
474
- proc { ROXML::Definition.new(:author, :from => :content, :required => true, :else => 'Johnny') }.should raise_error(ArgumentError)
475
- proc { ROXML::Definition.new(:author, :from => :content, :required => false, :else => 'Johnny') }.should_not raise_error
454
+ expect { ROXML::Definition.new(:author, :from => :content, :required => true, :else => 'Johnny') }.to raise_error(ArgumentError)
455
+ expect { ROXML::Definition.new(:author, :from => :content, :required => false, :else => 'Johnny') }.to_not raise_error
476
456
  end
477
457
  end
478
458
 
@@ -8,30 +8,30 @@ describe ROXML, "under ActiveRecord" do
8
8
  end
9
9
 
10
10
  it "should be parsed" do
11
- @route.should_not == nil
12
- @route.should be_an_instance_of(Route)
11
+ expect(@route).to_not eq(nil)
12
+ expect(@route).to be_an_instance_of(Route)
13
13
  end
14
14
 
15
15
  describe "xml attributes" do
16
16
  it "should extract xml attributes" do
17
- @route.totalHg.should == "640"
18
- @route.lonlatx.should == "357865"
19
- @route.lonlaty.should == "271635"
20
- @route.grcenter.should == "SH 71635 57865"
21
- @route.totalMins.should == "235.75000000000003"
22
- @route.totalDist.should == "11185.321521477119"
17
+ expect(@route.totalHg).to eq("640")
18
+ expect(@route.lonlatx).to eq("357865")
19
+ expect(@route.lonlaty).to eq("271635")
20
+ expect(@route.grcenter).to eq("SH 71635 57865")
21
+ expect(@route.totalMins).to eq("235.75000000000003")
22
+ expect(@route.totalDist).to eq("11185.321521477119")
23
23
  end
24
24
  end
25
25
 
26
26
  describe "xml sub-objects" do
27
27
  it "should extract xml sub-objects" do
28
- @route.should have(6).waypoints
29
- @route.waypoints.each {|waypoint| waypoint.should be_an_instance_of(Waypoint)}
28
+ expect(@route.waypoints.size).to eq(6)
29
+ @route.waypoints.each {|waypoint| expect(waypoint).to be_an_instance_of(Waypoint)}
30
30
  end
31
31
  it "should be usable as a ActiveRecord object" do
32
- Waypoint.count.should == 0
32
+ expect(Waypoint.count).to eq(0)
33
33
  @route.save!
34
- Waypoint.count.should == 6
34
+ expect(Waypoint.count).to eq(6)
35
35
  end
36
36
  end
37
- end
37
+ end