jordi-xml_struct 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +18 -4
- data/TODO +1 -0
- data/WHATSNEW +9 -1
- data/lib/xml_struct.rb +15 -5
- data/test/test_helper.rb +8 -8
- data/test/vendor/test-spec/README +378 -0
- data/test/vendor/test-spec/ROADMAP +1 -0
- data/test/vendor/test-spec/Rakefile +146 -0
- data/test/vendor/test-spec/SPECS +161 -0
- data/test/vendor/test-spec/TODO +2 -0
- data/test/vendor/test-spec/bin/specrb +107 -0
- data/test/vendor/test-spec/examples/stack.rb +38 -0
- data/test/vendor/test-spec/examples/stack_spec.rb +119 -0
- data/test/vendor/test-spec/lib/test/spec/dox.rb +148 -0
- data/test/vendor/test-spec/lib/test/spec/rdox.rb +25 -0
- data/test/vendor/test-spec/lib/test/spec/should-output.rb +49 -0
- data/test/vendor/test-spec/lib/test/spec/version.rb +8 -0
- data/test/vendor/test-spec/lib/test/spec.rb +660 -0
- data/test/vendor/test-spec/test/spec_dox.rb +39 -0
- data/test/vendor/test-spec/test/spec_flexmock.rb +209 -0
- data/test/vendor/test-spec/test/spec_mocha.rb +104 -0
- data/test/vendor/test-spec/test/spec_nestedcontexts.rb +26 -0
- data/test/vendor/test-spec/test/spec_new_style.rb +80 -0
- data/test/vendor/test-spec/test/spec_should-output.rb +26 -0
- data/test/vendor/test-spec/test/spec_testspec.rb +699 -0
- data/test/vendor/test-spec/test/spec_testspec_order.rb +26 -0
- data/test/vendor/test-spec/test/test_testunit.rb +22 -0
- data/test/xml_struct_test.rb +60 -54
- data/xml_struct.gemspec +41 -11
- metadata +33 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
3
|
+
$foo = 0
|
4
|
+
|
5
|
+
context "Context First" do
|
6
|
+
specify "runs before Second" do
|
7
|
+
$foo.should.equal 0
|
8
|
+
$foo += 1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "Context Second" do
|
13
|
+
specify "runs before Last" do
|
14
|
+
$foo.should.equal 1
|
15
|
+
$foo += 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Context Last" do
|
20
|
+
specify "runs last" do
|
21
|
+
$foo.should.equal 2
|
22
|
+
$foo += 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
3
|
+
class TestTestUnit < Test::Unit::TestCase
|
4
|
+
def test_still_works_on_its_own
|
5
|
+
assert_equal 1, 1
|
6
|
+
assert_raise(RuntimeError) { raise "Error" }
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_supports_should_good_enough
|
10
|
+
(2 + 3).should.be 5
|
11
|
+
lambda { raise "Error" }.should.raise
|
12
|
+
assert true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "TestUnit" do
|
17
|
+
specify "works inside test/spec" do
|
18
|
+
assert_equal 1, 1
|
19
|
+
assert_raise(RuntimeError) { raise "Error" }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/test/xml_struct_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
|
-
|
3
|
+
describe 'XML Struct' do
|
4
4
|
|
5
5
|
include RubyProf::Test if defined? RubyProf::Test
|
6
6
|
|
@@ -8,108 +8,114 @@ class XMLStructTest < Test::Unit::TestCase
|
|
8
8
|
@lorem = XMLStruct.new xml_file(:lorem)
|
9
9
|
end
|
10
10
|
|
11
|
-
should
|
12
|
-
@lorem.
|
11
|
+
it 'should be an XMLStruct' do
|
12
|
+
@lorem.should.be.an.instance_of XMLStruct
|
13
13
|
end
|
14
14
|
|
15
|
-
should
|
16
|
-
@lorem.ipsum.blank
|
15
|
+
it 'should be blank if devoid of children, attributes and value' do
|
16
|
+
@lorem.ipsum.should.be.blank
|
17
17
|
end
|
18
18
|
|
19
|
-
should
|
20
|
-
|
19
|
+
it 'should not be blank when value, children, or attributes are present' do
|
20
|
+
@lorem.dolor.should.not.be.blank
|
21
|
+
@lorem.sit.should.not.be.blank
|
22
|
+
@lorem.ut.should.not.be.blank
|
21
23
|
end
|
22
24
|
|
23
|
-
should
|
24
|
-
@lorem['_tempor'] == 'incididunt'
|
25
|
+
it 'should allow access to attributes named like invalid methods' do
|
26
|
+
@lorem['_tempor'].should == 'incididunt'
|
25
27
|
end
|
26
28
|
|
27
|
-
should
|
28
|
-
@lorem['_minim']
|
29
|
+
it 'should allow access to elements named like invalid methods' do
|
30
|
+
'veniam'.should == @lorem['_minim']
|
29
31
|
end
|
30
32
|
|
31
|
-
should
|
32
|
-
@lorem.sed[:element => 'do']
|
33
|
+
it 'should provide unambiguous access to elements named like attributes' do
|
34
|
+
'eiusmod elementus'.should == @lorem.sed[:element => 'do']
|
33
35
|
end
|
34
36
|
|
35
|
-
should
|
36
|
-
@lorem.sed[:attribute => 'do'] == 'eiusmod attributus'
|
37
|
+
it 'should provide unambiguous access to attributes named like elements' do
|
38
|
+
@lorem.sed[:attribute => 'do'].should == 'eiusmod attributus'
|
37
39
|
end
|
38
40
|
|
39
|
-
should
|
40
|
-
@lorem.sed
|
41
|
+
it 'should return elements first when using dot notation' do
|
42
|
+
@lorem.sed[:element => 'do'].should == @lorem.sed.do
|
41
43
|
end
|
42
44
|
|
43
|
-
should
|
44
|
-
@lorem.sed['do'] == @lorem.sed[:element => 'do']
|
45
|
+
it 'should return elements first when using array notation and string key' do
|
46
|
+
@lorem.sed['do'].should == @lorem.sed[:element => 'do']
|
45
47
|
end
|
46
48
|
|
47
|
-
should
|
48
|
-
@lorem.sed[:do] == @lorem.sed[:element => 'do']
|
49
|
+
it 'should return elements first when using array notation and symbol key' do
|
50
|
+
@lorem.sed[:do].should == @lorem.sed[:element => 'do']
|
49
51
|
end
|
50
52
|
|
51
|
-
should
|
52
|
-
(@lorem[:foo => 'bar']
|
53
|
+
it 'should raise exception when unkown keys are used in hash-in-array mode' do
|
54
|
+
should.raise(RuntimeError) { @lorem[:foo => 'bar'] }
|
53
55
|
end
|
54
56
|
|
55
|
-
should
|
56
|
-
@lorem.consectetur.is_a?
|
57
|
+
it 'should group multiple parallel namesake elements in arrays' do
|
58
|
+
@lorem.consectetur.is_a?(Array).should.be true
|
57
59
|
end
|
58
60
|
|
59
|
-
should
|
60
|
-
@lorem.consecteturs.
|
61
|
+
it 'should make auto-grouped arrays accessible by their plural form' do
|
62
|
+
@lorem.consecteturs.should.be @lorem.consectetur
|
61
63
|
end
|
62
64
|
|
63
|
-
should
|
64
|
-
|
65
|
+
it 'should allow explicit access to elements named like plural arrays' do
|
66
|
+
@lorem.consecteturs.should.not.be @lorem[:element => 'consecteturs']
|
65
67
|
end
|
66
68
|
|
67
|
-
should
|
68
|
-
@lorem.consecteturs.
|
69
|
+
it 'should convert integer-looking attribute strings to integers' do
|
70
|
+
@lorem.consecteturs.each do |c|
|
71
|
+
c['id'].is_a?(Numeric).should.be true
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
|
-
should
|
72
|
-
@lorem.consecteturs.
|
75
|
+
it 'should convert float-looking attribute strings to floats' do
|
76
|
+
@lorem.consecteturs.each do |c|
|
77
|
+
c.capacity.is_a?(Float).should.be true
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
|
-
should
|
76
|
-
@lorem.consecteturs.
|
81
|
+
it 'should convert bool-looking attribute strings to bools when asked' do
|
82
|
+
@lorem.consecteturs.each { |c| c.enabled?.should == !!(c.enabled?) }
|
77
83
|
end
|
78
84
|
|
79
|
-
should
|
80
|
-
@lorem.consecteturs.first.enabled
|
81
|
-
@lorem.consecteturs.last.enabled
|
85
|
+
it 'should convert to bool correctly when asked' do
|
86
|
+
@lorem.consecteturs.first.enabled?.should.be true
|
87
|
+
@lorem.consecteturs.last.enabled?.should.be false
|
82
88
|
end
|
83
89
|
|
84
|
-
should
|
85
|
-
@lorem.cupidatats.slice(0).
|
90
|
+
it 'should pass forth methods to single array child when empty valued' do
|
91
|
+
@lorem.cupidatats.slice(0).should.be @lorem.cupidatats.cupidatat.slice(0)
|
86
92
|
end
|
87
93
|
|
88
|
-
should
|
89
|
-
|
94
|
+
it 'should not pass methods to single array child if not empty valued' do
|
95
|
+
@lorem.voluptate.slice(0).should.not.be @lorem.voluptate.esse.slice(0)
|
90
96
|
end
|
91
97
|
|
92
|
-
should
|
93
|
-
@lorem.ullamco
|
98
|
+
it 'should be valued as its text when text first and CDATA exist' do
|
99
|
+
'Laboris'.should == @lorem.ullamco
|
94
100
|
end
|
95
101
|
|
96
|
-
should
|
97
|
-
@lorem.deserunt
|
102
|
+
it 'should have the value of its first CDATA when multiple exist' do
|
103
|
+
'mollit'.should == @lorem.deserunt
|
98
104
|
end
|
99
105
|
|
100
|
-
should
|
101
|
-
@lorem.irure.metadata
|
106
|
+
it 'should squish whitespace in string attribute values' do
|
107
|
+
'dolor'.should == @lorem.irure.metadata
|
102
108
|
end
|
103
109
|
|
104
|
-
should
|
105
|
-
|
110
|
+
it 'should not squish whitespace in string element values' do
|
111
|
+
" \n\t\t\treprehenderit ".should == @lorem.irure
|
106
112
|
end
|
107
113
|
|
108
|
-
should
|
109
|
-
|
114
|
+
it 'should not squish whitespace in CDATA values' do
|
115
|
+
"\t foo\n".should == @lorem
|
110
116
|
end
|
111
117
|
|
112
|
-
should
|
113
|
-
|
118
|
+
it 'should have a working inspect function' do
|
119
|
+
should.not.raise { @lorem.inspect.is_a?(String) }
|
114
120
|
end
|
115
121
|
end
|
data/xml_struct.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'xml_struct'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2008-10-
|
3
|
+
s.version = '0.1.3'
|
4
|
+
s.date = '2008-10-10'
|
5
5
|
|
6
6
|
s.author = 'Jordi Bunster'
|
7
7
|
s.email = 'jordi@bunster.org'
|
@@ -21,17 +21,47 @@ Gem::Specification.new do |s|
|
|
21
21
|
test/samples
|
22
22
|
test/samples/lorem.xml
|
23
23
|
test/test_helper.rb
|
24
|
+
test/vendor
|
25
|
+
test/vendor/test-spec
|
26
|
+
test/vendor/test-spec/bin
|
27
|
+
test/vendor/test-spec/bin/specrb
|
28
|
+
test/vendor/test-spec/examples
|
29
|
+
test/vendor/test-spec/examples/stack.rb
|
30
|
+
test/vendor/test-spec/examples/stack_spec.rb
|
31
|
+
test/vendor/test-spec/lib
|
32
|
+
test/vendor/test-spec/lib/test
|
33
|
+
test/vendor/test-spec/lib/test/spec
|
34
|
+
test/vendor/test-spec/lib/test/spec/dox.rb
|
35
|
+
test/vendor/test-spec/lib/test/spec/rdox.rb
|
36
|
+
test/vendor/test-spec/lib/test/spec/should-output.rb
|
37
|
+
test/vendor/test-spec/lib/test/spec/version.rb
|
38
|
+
test/vendor/test-spec/lib/test/spec.rb
|
39
|
+
test/vendor/test-spec/Rakefile
|
40
|
+
test/vendor/test-spec/README
|
41
|
+
test/vendor/test-spec/ROADMAP
|
42
|
+
test/vendor/test-spec/SPECS
|
43
|
+
test/vendor/test-spec/test
|
44
|
+
test/vendor/test-spec/test/spec_dox.rb
|
45
|
+
test/vendor/test-spec/test/spec_flexmock.rb
|
46
|
+
test/vendor/test-spec/test/spec_mocha.rb
|
47
|
+
test/vendor/test-spec/test/spec_nestedcontexts.rb
|
48
|
+
test/vendor/test-spec/test/spec_new_style.rb
|
49
|
+
test/vendor/test-spec/test/spec_should-output.rb
|
50
|
+
test/vendor/test-spec/test/spec_testspec.rb
|
51
|
+
test/vendor/test-spec/test/spec_testspec_order.rb
|
52
|
+
test/vendor/test-spec/test/test_testunit.rb
|
53
|
+
test/vendor/test-spec/TODO
|
24
54
|
test/xml_struct_test.rb ]
|
25
55
|
|
26
|
-
s.files
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
56
|
+
s.files = %w[ MIT-LICENSE
|
57
|
+
README.markdown
|
58
|
+
Rakefile
|
59
|
+
TODO
|
60
|
+
WHATSNEW
|
61
|
+
lib
|
62
|
+
lib/jordi-xml_struct.rb
|
63
|
+
lib/xml_struct.rb
|
64
|
+
xml_struct.gemspec ]
|
35
65
|
|
36
66
|
s.has_rdoc = true
|
37
67
|
s.extra_rdoc_files = %w[ README.markdown ]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jordi-xml_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Bunster
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,8 +33,8 @@ files:
|
|
33
33
|
- MIT-LICENSE
|
34
34
|
- README.markdown
|
35
35
|
- Rakefile
|
36
|
-
- WHATSNEW
|
37
36
|
- TODO
|
37
|
+
- WHATSNEW
|
38
38
|
- lib
|
39
39
|
- lib/jordi-xml_struct.rb
|
40
40
|
- lib/xml_struct.rb
|
@@ -71,4 +71,34 @@ test_files:
|
|
71
71
|
- test/samples
|
72
72
|
- test/samples/lorem.xml
|
73
73
|
- test/test_helper.rb
|
74
|
+
- test/vendor
|
75
|
+
- test/vendor/test-spec
|
76
|
+
- test/vendor/test-spec/bin
|
77
|
+
- test/vendor/test-spec/bin/specrb
|
78
|
+
- test/vendor/test-spec/examples
|
79
|
+
- test/vendor/test-spec/examples/stack.rb
|
80
|
+
- test/vendor/test-spec/examples/stack_spec.rb
|
81
|
+
- test/vendor/test-spec/lib
|
82
|
+
- test/vendor/test-spec/lib/test
|
83
|
+
- test/vendor/test-spec/lib/test/spec
|
84
|
+
- test/vendor/test-spec/lib/test/spec/dox.rb
|
85
|
+
- test/vendor/test-spec/lib/test/spec/rdox.rb
|
86
|
+
- test/vendor/test-spec/lib/test/spec/should-output.rb
|
87
|
+
- test/vendor/test-spec/lib/test/spec/version.rb
|
88
|
+
- test/vendor/test-spec/lib/test/spec.rb
|
89
|
+
- test/vendor/test-spec/Rakefile
|
90
|
+
- test/vendor/test-spec/README
|
91
|
+
- test/vendor/test-spec/ROADMAP
|
92
|
+
- test/vendor/test-spec/SPECS
|
93
|
+
- test/vendor/test-spec/test
|
94
|
+
- test/vendor/test-spec/test/spec_dox.rb
|
95
|
+
- test/vendor/test-spec/test/spec_flexmock.rb
|
96
|
+
- test/vendor/test-spec/test/spec_mocha.rb
|
97
|
+
- test/vendor/test-spec/test/spec_nestedcontexts.rb
|
98
|
+
- test/vendor/test-spec/test/spec_new_style.rb
|
99
|
+
- test/vendor/test-spec/test/spec_should-output.rb
|
100
|
+
- test/vendor/test-spec/test/spec_testspec.rb
|
101
|
+
- test/vendor/test-spec/test/spec_testspec_order.rb
|
102
|
+
- test/vendor/test-spec/test/test_testunit.rb
|
103
|
+
- test/vendor/test-spec/TODO
|
74
104
|
- test/xml_struct_test.rb
|