jordi-xml_struct 0.2.1 → 0.9.0

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.
Files changed (43) hide show
  1. data/README.rdoc +152 -0
  2. data/WHATSNEW +10 -0
  3. data/lib/xml_struct/adapters/hpricot.rb +47 -0
  4. data/lib/xml_struct/adapters/rexml.rb +34 -0
  5. data/lib/xml_struct/array_notation.rb +44 -0
  6. data/lib/xml_struct/blankish_slate.rb +1 -1
  7. data/lib/xml_struct/collection_proxy.rb +7 -3
  8. data/lib/xml_struct/default_adapter.rb +15 -0
  9. data/lib/xml_struct/method_missing_dispatchers.rb +43 -0
  10. data/lib/xml_struct/string.rb +6 -2
  11. data/lib/xml_struct.rb +31 -52
  12. data/xml_struct.gemspec +38 -0
  13. metadata +17 -49
  14. data/README.markdown +0 -151
  15. data/Rakefile +0 -36
  16. data/lib/xml_struct/common_behaviours.rb +0 -53
  17. data/test/samples/lorem.xml +0 -63
  18. data/test/samples/recipe.xml +0 -16
  19. data/test/samples/weird_characters.xml +0 -2
  20. data/test/test_helper.rb +0 -39
  21. data/test/vendor/test-spec/README +0 -378
  22. data/test/vendor/test-spec/ROADMAP +0 -1
  23. data/test/vendor/test-spec/Rakefile +0 -146
  24. data/test/vendor/test-spec/SPECS +0 -161
  25. data/test/vendor/test-spec/TODO +0 -2
  26. data/test/vendor/test-spec/bin/specrb +0 -107
  27. data/test/vendor/test-spec/examples/stack.rb +0 -38
  28. data/test/vendor/test-spec/examples/stack_spec.rb +0 -119
  29. data/test/vendor/test-spec/lib/test/spec/dox.rb +0 -148
  30. data/test/vendor/test-spec/lib/test/spec/rdox.rb +0 -25
  31. data/test/vendor/test-spec/lib/test/spec/should-output.rb +0 -49
  32. data/test/vendor/test-spec/lib/test/spec/version.rb +0 -8
  33. data/test/vendor/test-spec/lib/test/spec.rb +0 -660
  34. data/test/vendor/test-spec/test/spec_dox.rb +0 -39
  35. data/test/vendor/test-spec/test/spec_flexmock.rb +0 -209
  36. data/test/vendor/test-spec/test/spec_mocha.rb +0 -104
  37. data/test/vendor/test-spec/test/spec_nestedcontexts.rb +0 -26
  38. data/test/vendor/test-spec/test/spec_new_style.rb +0 -80
  39. data/test/vendor/test-spec/test/spec_should-output.rb +0 -26
  40. data/test/vendor/test-spec/test/spec_testspec.rb +0 -699
  41. data/test/vendor/test-spec/test/spec_testspec_order.rb +0 -26
  42. data/test/vendor/test-spec/test/test_testunit.rb +0 -22
  43. data/test/xml_struct_test.rb +0 -185
@@ -1,161 +0,0 @@
1
-
2
- == TestUnit
3
- * still works on its own
4
- * supports should good enough
5
- * works inside test/spec
6
-
7
- == CustomTestUnitSubclass
8
- * truth
9
-
10
- == test/spec
11
- * has should.satisfy
12
- * has should.equal
13
- * has should.raise
14
- * has should.raise with a block
15
- * should.raise should return the exception
16
- * has should.be.an.instance_of
17
- * has should.be.nil
18
- * has should.include
19
- * has should.be.a.kind_of
20
- * has should.match
21
- * has should.be
22
- * has should.not.raise
23
- * has should.not.satisfy
24
- * has should.not.be
25
- * has should.not.equal
26
- * has should.not.match
27
- * has should.throw
28
- * has should.not.throw
29
- * has should.respond_to
30
- * has should.be_close
31
- * multiple negation works
32
- * has should.<predicate>
33
- * has should.<predicate>?
34
- * has should <operator> (>, >=, <, <=, ===)
35
- * is robust against careless users
36
- * should detect warnings
37
- * should message/blame faults
38
- * should allow for custom shoulds
39
- * disabled specification (disabled)
40
- * empty specification (disabled)
41
- === more disabled
42
- * this is intentional (disabled)
43
- * an empty specification (empty)
44
- ==== even more disabled
45
- * we can cut out (disabled)
46
- * entire contexts, now (disabled)
47
-
48
- == setup/teardown
49
- * run in the right order
50
-
51
- == before all
52
- * runs parent before all
53
-
54
- == nested teardown
55
- === nested
56
- * should call local teardown then parent teardown
57
-
58
- == before all
59
- === nested
60
- * should call parent then local
61
-
62
- == after all
63
- === after nested
64
- * should call local then parent
65
-
66
- == contexts
67
- * are defined in class scope
68
- * can include modules
69
-
70
- == contexts with subclasses
71
- * use the supplied class as the superclass
72
- * truth
73
-
74
- == xcontexts with subclasses
75
- * work great! (disabled)
76
- * truth
77
-
78
- == Shared contexts
79
- * can be included several times
80
- * can include other shared contexts
81
- * can be included several times
82
- * can include other shared contexts
83
- * can be nested
84
- * can access data
85
- * should raise when the context cannot be found
86
-
87
- == SpecDox
88
- * can unmangle Test::Unit names correctly
89
- * can unmangle Test::Spec names correctly
90
- * has sensible fallbacks
91
-
92
- == flexmock
93
- * should receive and return
94
- * should receive without a block
95
- * should receive and return with a block
96
- * should have a return value
97
- * should handle missing methods
98
- * should ignore missing methods
99
- * should count correctly
100
- * should raise on bad counts
101
- * should handle undetermined counts
102
- * should handle zero counts
103
- * should have file IO with use
104
- * should have use
105
- * should handle failures during use
106
- * should deal with sequential values
107
- * respond_to? should return false for non handled methods
108
- * respond_to? should return true for explicit methods
109
- * respond_to? should return true for missing_methods when should_ignore_missing
110
- * should raise error on unknown method proc
111
- * should return callable proc on method
112
- * should return do nothing proc for missing methods
113
- * works with test/spec
114
-
115
- == mocha
116
- * works with test/spec
117
- * works with test/spec and Enterprise example
118
-
119
- == stubba
120
- * works with test/spec and instance method stubbing
121
- * works with test/spec and class method stubbing
122
- * works with test/spec and global instance method stubbing
123
-
124
- == Outer context
125
- === Inner context
126
- * is nested (empty)
127
- * has multiple empty specifications (empty)
128
- === Second Inner context
129
- * is indented properly (empty)
130
- * still runs in order of definition (empty)
131
- ==== Inmost context
132
- * works too! (empty)
133
- * whoo! (empty)
134
-
135
- == A new-style description
136
- * should run before-clauses
137
- * should behave like context/specify
138
- * this is disabled (disabled)
139
- * should raise on unimplement{ed,able} before/after
140
- * should work as well with shared descriptions
141
- === when nested
142
- * should work
143
-
144
- == An disabled description
145
- * should not be run (disabled)
146
-
147
- == should.output
148
- * works for print
149
- * works for puts
150
- * works with readline
151
-
152
- == Context First
153
- * runs before Second
154
-
155
- == Context Second
156
- * runs before Last
157
-
158
- == Context Last
159
- * runs last
160
-
161
- 104 specifications, 8 disabled, 7 empty (636 requirements), 0 failures
@@ -1,2 +0,0 @@
1
- - see ROADMAP
2
- - better handling of .should outside of specify(?)
@@ -1,107 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- ruby -*-
3
-
4
- require 'optparse'
5
-
6
- testrbargv = []
7
- automatic = false
8
-
9
- opts = OptionParser.new("", 24, ' ') { |opts|
10
- opts.banner = "Usage: specrb [options] [files | -a] [-- untouched arguments]"
11
-
12
- opts.separator ""
13
- opts.separator "Ruby options:"
14
-
15
- lineno = 1
16
- opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line|
17
- eval line, TOPLEVEL_BINDING, "-e", lineno
18
- lineno += 1
19
- }
20
-
21
- opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") {
22
- $DEBUG = true
23
- }
24
- opts.on("-w", "--warn", "turn warnings on for your script") {
25
- $-w = true
26
- }
27
-
28
- opts.on("-I", "--include PATH",
29
- "specify $LOAD_PATH (may be used more than once)") { |path|
30
- $LOAD_PATH.unshift(*path.split(":"))
31
- }
32
-
33
- opts.on("-r", "--require LIBRARY",
34
- "require the library, before executing your script") { |library|
35
- require library
36
- }
37
-
38
- opts.separator ""
39
- opts.separator "test/spec options:"
40
-
41
- opts.on("-s", "--specdox", "do AgileDox-like output") {
42
- testrbargv << "--runner=specdox"
43
- }
44
- opts.on("--rdox", "do AgileDox-like output with RDoc formatting") {
45
- testrbargv << "--runner=rdox"
46
- }
47
-
48
- opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") {
49
- $LOAD_PATH.unshift "lib" if File.directory? "lib"
50
- automatic = true
51
- }
52
-
53
- opts.separator ""
54
- opts.separator "test/unit options:"
55
-
56
- opts.on('-n', '--name NAME', String,
57
- "runs tests matching regexp NAME") { |n|
58
- testrbargv << "-n" << "/#{n}/"
59
- }
60
-
61
- opts.on('-t', '--testcase TESTCASE', String,
62
- "runs tests in TestCases matching regexp TESTCASE") { |t|
63
- testrbargv << "-t" << "/#{t}/"
64
- }
65
-
66
- opts.separator ""
67
- opts.separator "Common options:"
68
-
69
- opts.on_tail("-h", "--help", "Show this message") do
70
- puts opts
71
- exit
72
- end
73
-
74
- opts.on_tail("--version", "Show version") do
75
- require 'test/spec'
76
- puts "specrb #{Test::Spec::VERSION}"
77
- exit
78
- end
79
-
80
- opts.parse! ARGV
81
- }
82
-
83
- files = ARGV
84
-
85
- if automatic
86
- files.concat Dir["test/test_*.rb"]
87
- files.concat Dir["test/spec_*.rb"]
88
- files.concat Dir["spec/spec_*.rb"]
89
- end
90
-
91
- if files.empty?
92
- puts opts.banner
93
- exit 1
94
- end
95
-
96
- argv = testrbargv + files
97
- # Should use -- to separate them *but* there's a bug in
98
- # Test::Unit::AutoRunner#process_args: arguments after -- are ignored.
99
- # (You could also argue that it's a bug in optparse.rb).
100
-
101
- require 'test/spec'
102
-
103
- Test::Unit.run = false
104
- runner = Test::Unit::AutoRunner.new true
105
- runner.process_args(argv) ||
106
- abort("internal error calling Test::Unit, please report a bug")
107
- exit runner.run
@@ -1,38 +0,0 @@
1
- # Copied without code changes from RSpec.
2
-
3
- class StackUnderflowError < RuntimeError
4
- end
5
-
6
- class StackOverflowError < RuntimeError
7
- end
8
-
9
- class Stack
10
-
11
- def initialize
12
- @items = []
13
- end
14
-
15
- def push object
16
- raise StackOverflowError if @items.length == 10
17
- @items.push object
18
- end
19
-
20
- def pop
21
- raise StackUnderflowError if @items.empty?
22
- @items.delete @items.last
23
- end
24
-
25
- def peek
26
- raise StackUnderflowError if @items.empty?
27
- @items.last
28
- end
29
-
30
- def empty?
31
- @items.empty?
32
- end
33
-
34
- def full?
35
- @items.length == 10
36
- end
37
-
38
- end
@@ -1,119 +0,0 @@
1
- # Copied with minor code changes (should_xxx -> should.xxx) from RSpec.
2
-
3
- require File.dirname(__FILE__) + '/../lib/test/spec'
4
- require File.dirname(__FILE__) + "/stack"
5
-
6
- context "A stack (in general)" do
7
- setup do
8
- @stack = Stack.new
9
- ["a","b","c"].each { |x| @stack.push x }
10
- end
11
-
12
- specify "should add to the top when sent 'push'" do
13
- @stack.push "d"
14
- @stack.peek.should.equal "d"
15
- end
16
-
17
- specify "should return the top item when sent 'peek'" do
18
- @stack.peek.should.equal "c"
19
- end
20
-
21
- specify "should NOT remove the top item when sent 'peek'" do
22
- @stack.peek.should.equal "c"
23
- @stack.peek.should.equal "c"
24
- end
25
-
26
- specify "should return the top item when sent 'pop'" do
27
- @stack.pop.should.equal "c"
28
- end
29
-
30
- specify "should remove the top item when sent 'pop'" do
31
- @stack.pop.should.equal "c"
32
- @stack.pop.should.equal "b"
33
- end
34
- end
35
-
36
- context "An empty stack" do
37
- setup do
38
- @stack = Stack.new
39
- end
40
-
41
- specify "should be empty" do
42
- @stack.should.be.empty
43
- end
44
-
45
- specify "should no longer be empty after 'push'" do
46
- @stack.push "anything"
47
- @stack.should.not.be.empty
48
- end
49
-
50
- specify "should complain when sent 'peek'" do
51
- lambda { @stack.peek }.should.raise StackUnderflowError
52
- end
53
-
54
- specify "should complain when sent 'pop'" do
55
- lambda { @stack.pop }.should.raise StackUnderflowError
56
- end
57
- end
58
-
59
- context "An almost empty stack (with one item)" do
60
- setup do
61
- @stack = Stack.new
62
- @stack.push 3
63
- end
64
-
65
- specify "should not be empty" do
66
- @stack.should.not.be.empty
67
- end
68
-
69
- specify "should remain not empty after 'peek'" do
70
- @stack.peek
71
- @stack.should.not.be.empty
72
- end
73
-
74
- specify "should become empty after 'pop'" do
75
- @stack.pop
76
- @stack.should.be.empty
77
- end
78
- end
79
-
80
- context "An almost full stack (with one item less than capacity)" do
81
- setup do
82
- @stack = Stack.new
83
- (1..9).each { |i| @stack.push i }
84
- end
85
-
86
- specify "should not be full" do
87
- @stack.should.not.be.full
88
- end
89
-
90
- specify "should become full when sent 'push'" do
91
- @stack.push Object.new
92
- @stack.should.be.full
93
- end
94
- end
95
-
96
- context "A full stack" do
97
- setup do
98
- @stack = Stack.new
99
- (1..10).each { |i| @stack.push i }
100
- end
101
-
102
- specify "should be full" do
103
- @stack.should.be.full
104
- end
105
-
106
- specify "should remain full after 'peek'" do
107
- @stack.peek
108
- @stack.should.be.full
109
- end
110
-
111
- specify "should no longer be full after 'pop'" do
112
- @stack.pop
113
- @stack.should.not.be.full
114
- end
115
-
116
- specify "should complain on 'push'" do
117
- lambda { @stack.push Object.new }.should.raise StackOverflowError
118
- end
119
- end
@@ -1,148 +0,0 @@
1
- require 'test/unit/ui/console/testrunner'
2
-
3
- module Test::Unit::UI # :nodoc:
4
- module SpecDox # :nodoc:
5
- class TestRunner < Test::Unit::UI::Console::TestRunner
6
- protected
7
- def setup_mediator
8
- @mediator = create_mediator(@suite)
9
- end
10
-
11
- def add_fault(fault)
12
- if fault.kind_of? Test::Spec::Disabled
13
- @disabled += 1
14
- output_no_nl " (disabled)"
15
- elsif fault.kind_of? Test::Spec::Empty
16
- @empty += 1
17
- output_no_nl " (empty)"
18
- else
19
- @faults << fault
20
- word = fault.class.name[/(.*::)?(.*)/, 2].upcase
21
- output_no_nl " (#{word} - #{@faults.size})"
22
- end
23
- end
24
-
25
- def started(result)
26
- @result = result
27
- @context = nil
28
- @contexts = []
29
- @disabled = 0
30
- @empty = 0
31
- indent 0
32
- end
33
-
34
- def finished(elapsed_time)
35
- nl
36
- output "Finished in #{elapsed_time} seconds."
37
- @faults.each_with_index do |fault, index|
38
- nl
39
- output("%3d) %s" % [index + 1, fault.long_display])
40
- end
41
- nl
42
- output_result
43
- end
44
-
45
- def output_result
46
- if @disabled > 0
47
- disabled = ", #{@disabled} disabled"
48
- else
49
- disabled = ""
50
- end
51
-
52
- if @empty > 0
53
- empty = ", #{@empty} empty"
54
- else
55
- empty = ""
56
- end
57
-
58
- r = ("%d specifications#{disabled}#{empty} " +
59
- "(%d requirements), %d failures") % [
60
- @result.run_count, @result.assertion_count, @result.failure_count]
61
- r << ", #{@result.error_count} errors" if @result.error_count > 0
62
- output r
63
- end
64
-
65
- def test_started(name)
66
- return if special_test? name
67
-
68
- contextname, @specname = unmangle name
69
- return if contextname.nil? || @specname.nil?
70
-
71
- if @context != contextname
72
- @context = contextname
73
-
74
- @old_contexts = @contexts
75
- @contexts = @context.split("\t")
76
-
77
- common = 0
78
- @contexts.zip(@old_contexts) { |a, b|
79
- break if a != b
80
- common += 1
81
- }
82
-
83
- nl if common == 0
84
-
85
- @contexts[common..-1].each_with_index { |head, i|
86
- indent common + i
87
- output_heading head
88
- }
89
- end
90
-
91
- @assertions = @result.assertion_count
92
- @prevdisabled = @disabled
93
- output_item @specname
94
- end
95
-
96
- def test_finished(name)
97
- return if special_test? name
98
-
99
- # Did any assertion run?
100
- if @assertions == @result.assertion_count && @prevdisabled == @disabled
101
- add_fault Test::Spec::Empty.new(@specname)
102
- end
103
-
104
- # Don't let empty contexts clutter up the output.
105
- nl unless name =~ /\Adefault_test\(/
106
- end
107
-
108
- def output_no_nl(something, level=NORMAL)
109
- @io.write(something) if (output?(level))
110
- @io.flush
111
- end
112
-
113
- def output_item(item)
114
- output_no_nl "#{@prefix}- #{item}"
115
- end
116
-
117
- def output_heading(heading)
118
- output "#{@prefix}#{heading}"
119
- end
120
-
121
- def unmangle(name)
122
- if name =~ /\Atest_spec \{(.*?)\} \d+ \[(.*)\]/
123
- contextname = $1
124
- specname = $2
125
- elsif name =~ /test_(.*?)\((.*)\)$/
126
- specname = $1
127
- contextname = $2
128
-
129
- contextname.gsub!(/^Test\B|\BTest$/, '')
130
- specname.gsub!(/_/, ' ')
131
- else
132
- contextname = specname = nil
133
- end
134
-
135
- [contextname, specname]
136
- end
137
-
138
- def indent(depth)
139
- @indent = depth
140
- @prefix = " " * depth
141
- end
142
-
143
- def special_test?(name)
144
- name =~ /\Atest_spec \{.*?\} (-1 BEFORE|AFTER) ALL\(/
145
- end
146
- end
147
- end
148
- end