sdl4r 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -222,6 +222,12 @@ module SDL4R
222
222
  assert_equal [1, 2, 3], tag1.children[0].values
223
223
  assert_equal [4, 5, 6], tag1.children[1].values
224
224
  assert_equal 2, tag1.child_count
225
+
226
+ # Test empty or nil attribute value
227
+ tag1.clear_attributes
228
+ tag1 << { "a1" => "" }
229
+ tag1 << { "a2" => nil }
230
+ assert_equal({ "a1" => "", "a2" => nil }, tag1.attributes)
225
231
  end
226
232
 
227
233
  def test_attributes
@@ -261,6 +267,10 @@ module SDL4R
261
267
  tag.clear_attributes
262
268
  assert_nil tag.attribute("a2")
263
269
  assert_equal({}, tag.attributes)
270
+
271
+ # test empty value
272
+ tag.set_attribute("a1", "")
273
+ assert_equal "", tag.attribute("a1")
264
274
  end
265
275
 
266
276
  def test_attributes_with_namespace
@@ -485,6 +495,49 @@ EOF
485
495
  assert_equal "123", xml_doc.elements[1].elements[1].attribute("a1").value
486
496
  end
487
497
 
498
+ def test_write
499
+ root = Tag.new("root")
500
+
501
+ output = ""
502
+ root.write(output)
503
+ assert_equal "", output
504
+
505
+ output = ""
506
+ root.write(output, true)
507
+ assert_equal "root", output
508
+
509
+ child1 = root.new_child "child1"
510
+ child1 << 123
511
+
512
+ output = ""
513
+ root.write(output)
514
+ assert_equal "child1 123", output
515
+
516
+ output = ""
517
+ root.write(output, true)
518
+ assert_equal(
519
+ "root {\n" +
520
+ "\tchild1 123\n" +
521
+ "}",
522
+ output)
523
+
524
+ child1 = root.new_child "child2"
525
+ child1 << "abc"
526
+
527
+ output = ""
528
+ root.write(output)
529
+ assert_equal "child1 123\nchild2 \"abc\"", output
530
+
531
+ output = ""
532
+ root.write(output, true)
533
+ assert_equal(
534
+ "root {\n" +
535
+ "\tchild1 123\n" +
536
+ "\tchild2 \"abc\"\n" +
537
+ "}",
538
+ output)
539
+ end
540
+
488
541
  end
489
542
 
490
543
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdl4r
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 55
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 5
9
- version: 0.9.5
9
+ - 6
10
+ version: 0.9.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Philippe Vosges
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-08 00:00:00 +09:00
19
+ date: 2010-08-10 00:00:00 +09:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -86,23 +87,27 @@ rdoc_options: []
86
87
  require_paths:
87
88
  - lib
88
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
89
91
  requirements:
90
92
  - - ">="
91
93
  - !ruby/object:Gem::Version
94
+ hash: 3
92
95
  segments:
93
96
  - 0
94
97
  version: "0"
95
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
96
100
  requirements:
97
101
  - - ">="
98
102
  - !ruby/object:Gem::Version
103
+ hash: 3
99
104
  segments:
100
105
  - 0
101
106
  version: "0"
102
107
  requirements:
103
108
  - none
104
109
  rubyforge_project: sdl4r
105
- rubygems_version: 1.3.6
110
+ rubygems_version: 1.3.7
106
111
  signing_key:
107
112
  specification_version: 3
108
113
  summary: Simple Declarative Language for Ruby library