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 @@
|
|
1
|
+
Version 1.0 (2008):: everything-done release.
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# Rakefile for testspec. -*-ruby-*-
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
|
6
|
+
desc "Run all the tests"
|
7
|
+
task :default => [:test]
|
8
|
+
|
9
|
+
desc "Do predistribution stuff"
|
10
|
+
task :predist => [:chmod, :changelog, :rdoc]
|
11
|
+
|
12
|
+
|
13
|
+
desc "Make an archive as .tar.gz"
|
14
|
+
task :dist => :test do
|
15
|
+
system "export DARCS_REPO=#{File.expand_path "."}; " +
|
16
|
+
"darcs dist -d test-spec-#{get_darcs_tree_version}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Helper to retrieve the "revision number" of the darcs tree.
|
20
|
+
def get_darcs_tree_version
|
21
|
+
unless File.directory? "_darcs"
|
22
|
+
load 'lib/test/spec/version.rb'
|
23
|
+
return Test::Spec::VERSION
|
24
|
+
end
|
25
|
+
|
26
|
+
changes = `darcs changes`
|
27
|
+
count = 0
|
28
|
+
tag = "0.0"
|
29
|
+
|
30
|
+
changes.each("\n\n") { |change|
|
31
|
+
head, title, desc = change.split("\n", 3)
|
32
|
+
|
33
|
+
if title =~ /^ \*/
|
34
|
+
# Normal change.
|
35
|
+
count += 1
|
36
|
+
elsif title =~ /tagged (.*)/
|
37
|
+
# Tag. We look for these.
|
38
|
+
tag = $1
|
39
|
+
break
|
40
|
+
else
|
41
|
+
warn "Unparsable change: #{change}"
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
tag + "." + count.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def manifest
|
49
|
+
`darcs query manifest 2>/dev/null`.split("\n").map { |f| f.gsub(/\A\.\//, '') }
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
desc "Make binaries executable"
|
54
|
+
task :chmod do
|
55
|
+
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Generate a ChangeLog"
|
59
|
+
task :changelog do
|
60
|
+
system "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
desc "Generate RDox"
|
65
|
+
task "SPECS" do
|
66
|
+
ruby "bin/specrb -Ilib:test -a --rdox >SPECS"
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "Run all the tests"
|
70
|
+
task :test => :chmod do
|
71
|
+
ruby "bin/specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
begin
|
76
|
+
require 'rubygems'
|
77
|
+
|
78
|
+
require 'rake'
|
79
|
+
require 'rake/clean'
|
80
|
+
require 'rake/packagetask'
|
81
|
+
require 'rake/gempackagetask'
|
82
|
+
require 'fileutils'
|
83
|
+
rescue LoadError
|
84
|
+
# Too bad.
|
85
|
+
else
|
86
|
+
spec = Gem::Specification.new do |s|
|
87
|
+
s.name = "test-spec"
|
88
|
+
s.version = get_darcs_tree_version
|
89
|
+
s.platform = Gem::Platform::RUBY
|
90
|
+
s.summary = "a Behaviour Driven Development interface for Test::Unit"
|
91
|
+
s.description = <<-EOF
|
92
|
+
test/spec layers an RSpec-inspired interface on top of Test::Unit, so
|
93
|
+
you can mix TDD and BDD (Behavior-Driven Development).
|
94
|
+
|
95
|
+
test/spec is a clean-room implementation that maps most kinds of
|
96
|
+
Test::Unit assertions to a `should'-like syntax.
|
97
|
+
EOF
|
98
|
+
|
99
|
+
s.files = manifest + %w(SPECS)
|
100
|
+
s.bindir = 'bin'
|
101
|
+
s.executables << 'specrb'
|
102
|
+
s.require_path = 'lib'
|
103
|
+
s.has_rdoc = true
|
104
|
+
s.extra_rdoc_files = ['README', 'SPECS', 'ROADMAP']
|
105
|
+
s.test_files = Dir['test/{test,spec}_*.rb']
|
106
|
+
|
107
|
+
s.author = 'Christian Neukirchen'
|
108
|
+
s.email = 'chneukirchen@gmail.com'
|
109
|
+
s.homepage = "http://test-spec.rubyforge.org"
|
110
|
+
s.rubyforge_project = 'test-spec'
|
111
|
+
end
|
112
|
+
|
113
|
+
task :package => [:dist]
|
114
|
+
|
115
|
+
Rake::GemPackageTask.new(spec) do |p|
|
116
|
+
p.gem_spec = spec
|
117
|
+
p.need_tar = false
|
118
|
+
p.need_zip = false
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
desc "Generate RDoc documentation"
|
124
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
125
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
126
|
+
rdoc.rdoc_dir = "doc"
|
127
|
+
rdoc.rdoc_files.include 'README'
|
128
|
+
rdoc.rdoc_files.include 'ROADMAP'
|
129
|
+
rdoc.rdoc_files.include 'SPECS'
|
130
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
131
|
+
end
|
132
|
+
task :rdoc => "SPECS"
|
133
|
+
|
134
|
+
|
135
|
+
begin
|
136
|
+
require 'rcov/rcovtask'
|
137
|
+
|
138
|
+
Rcov::RcovTask.new do |t|
|
139
|
+
t.test_files = FileList['test/{spec,test}_*.rb'] + ['--', '-rs'] # evil
|
140
|
+
t.verbose = true # uncomment to see the executed command
|
141
|
+
t.rcov_opts = ["--text-report",
|
142
|
+
"--include-file", "^lib,^test",
|
143
|
+
"--exclude-only", "^/usr,^/home/.*/src"]
|
144
|
+
end
|
145
|
+
rescue LoadError
|
146
|
+
end
|
@@ -0,0 +1,161 @@
|
|
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
|
@@ -0,0 +1,107 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|