jordi-xml_struct 0.2.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +152 -0
- data/WHATSNEW +10 -0
- data/lib/xml_struct/adapters/hpricot.rb +47 -0
- data/lib/xml_struct/adapters/rexml.rb +34 -0
- data/lib/xml_struct/array_notation.rb +44 -0
- data/lib/xml_struct/blankish_slate.rb +1 -1
- data/lib/xml_struct/collection_proxy.rb +7 -3
- data/lib/xml_struct/default_adapter.rb +15 -0
- data/lib/xml_struct/method_missing_dispatchers.rb +43 -0
- data/lib/xml_struct/string.rb +6 -2
- data/lib/xml_struct.rb +31 -52
- data/xml_struct.gemspec +38 -0
- metadata +17 -49
- data/README.markdown +0 -151
- data/Rakefile +0 -36
- data/lib/xml_struct/common_behaviours.rb +0 -53
- data/test/samples/lorem.xml +0 -63
- data/test/samples/recipe.xml +0 -16
- data/test/samples/weird_characters.xml +0 -2
- data/test/test_helper.rb +0 -39
- data/test/vendor/test-spec/README +0 -378
- data/test/vendor/test-spec/ROADMAP +0 -1
- data/test/vendor/test-spec/Rakefile +0 -146
- data/test/vendor/test-spec/SPECS +0 -161
- data/test/vendor/test-spec/TODO +0 -2
- data/test/vendor/test-spec/bin/specrb +0 -107
- data/test/vendor/test-spec/examples/stack.rb +0 -38
- data/test/vendor/test-spec/examples/stack_spec.rb +0 -119
- data/test/vendor/test-spec/lib/test/spec/dox.rb +0 -148
- data/test/vendor/test-spec/lib/test/spec/rdox.rb +0 -25
- data/test/vendor/test-spec/lib/test/spec/should-output.rb +0 -49
- data/test/vendor/test-spec/lib/test/spec/version.rb +0 -8
- data/test/vendor/test-spec/lib/test/spec.rb +0 -660
- data/test/vendor/test-spec/test/spec_dox.rb +0 -39
- data/test/vendor/test-spec/test/spec_flexmock.rb +0 -209
- data/test/vendor/test-spec/test/spec_mocha.rb +0 -104
- data/test/vendor/test-spec/test/spec_nestedcontexts.rb +0 -26
- data/test/vendor/test-spec/test/spec_new_style.rb +0 -80
- data/test/vendor/test-spec/test/spec_should-output.rb +0 -26
- data/test/vendor/test-spec/test/spec_testspec.rb +0 -699
- data/test/vendor/test-spec/test/spec_testspec_order.rb +0 -26
- data/test/vendor/test-spec/test/test_testunit.rb +0 -22
- data/test/xml_struct_test.rb +0 -185
data/test/samples/recipe.xml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
<recipe name="bread" prep_time="5 mins" cook_time="3 hours">
|
2
|
-
<title>Basic bread</title>
|
3
|
-
<ingredient amount="8" unit="dL">Flour</ingredient>
|
4
|
-
<ingredient amount="10" unit="grams">Yeast</ingredient>
|
5
|
-
<ingredient amount="4" unit="dL" state="warm">Water</ingredient>
|
6
|
-
<ingredient amount="1" unit="teaspoon">Salt</ingredient>
|
7
|
-
<instructions easy="yes" hard="false">
|
8
|
-
<step>Mix all ingredients together.</step>
|
9
|
-
<step>Knead thoroughly.</step>
|
10
|
-
<step>Cover with a cloth, and leave for one hour in warm room.</step>
|
11
|
-
<step>Knead again.</step>
|
12
|
-
<step>Place in a bread baking tin.</step>
|
13
|
-
<step>Cover with a cloth, and leave for one hour in warm room.</step>
|
14
|
-
<step>Bake in the oven at 180(degrees)C for 30 minutes.</step>
|
15
|
-
</instructions>
|
16
|
-
</recipe>
|
data/test/test_helper.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rubygems'
|
3
|
-
require File.join(File.dirname(__FILE__),
|
4
|
-
'vendor', 'test-spec', 'lib', 'test', 'spec')
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'redgreen'
|
8
|
-
rescue LoadError
|
9
|
-
puts "Install the 'redgreen' gem to get color output"
|
10
|
-
end
|
11
|
-
|
12
|
-
begin
|
13
|
-
require 'ruby-prof'
|
14
|
-
rescue LoadError
|
15
|
-
puts "Install the 'ruby-prof' gem (>= 0.6.1) to get profiling information"
|
16
|
-
end
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'xml_struct')
|
19
|
-
|
20
|
-
def xml_file(name_symbol)
|
21
|
-
File.open File.join(File.dirname(__FILE__), 'samples',
|
22
|
-
"#{name_symbol.to_s}.xml")
|
23
|
-
end
|
24
|
-
|
25
|
-
require 'digest/md5'
|
26
|
-
{ :lorem => '9062c0f294383435d5b04ce6d67b6d61',
|
27
|
-
:weird_characters => 'cdcbd9b89b261487fa98c11d856f50fe',
|
28
|
-
:recipe => '6087ab42049273d123d473093b04ab12' }.each do |file_key, md5|
|
29
|
-
|
30
|
-
unless Digest::MD5.hexdigest(xml_file(file_key).read) == md5
|
31
|
-
raise "Sample test file #{file_key.to_s}.xml doesn't match expected MD5"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Test::Unit::TestCase
|
36
|
-
def debug
|
37
|
-
require 'ruby-debug'; debugger
|
38
|
-
end
|
39
|
-
end
|
@@ -1,378 +0,0 @@
|
|
1
|
-
= test/spec, a BDD interface for Test::Unit
|
2
|
-
|
3
|
-
Copyright (C) 2006, 2007, 2008 Christian Neukirchen <mailto:chneukirchen@gmail.com>
|
4
|
-
|
5
|
-
|
6
|
-
== What is test/spec?
|
7
|
-
|
8
|
-
test/spec layers an RSpec-inspired interface on top of Test::Unit, so
|
9
|
-
you can mix TDD and BDD (Behavior-Driven Development).
|
10
|
-
|
11
|
-
test/spec is a clean-room implementation that maps most kinds of
|
12
|
-
Test::Unit assertions to a `should'-like syntax.
|
13
|
-
|
14
|
-
Consider this Test::Unit test case:
|
15
|
-
|
16
|
-
class TestFoo < Test::Unit::TestCase
|
17
|
-
def test_should_bar
|
18
|
-
assert_equal 5, 2 + 3
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
In test/spec, it looks like this:
|
23
|
-
|
24
|
-
require 'test/spec'
|
25
|
-
|
26
|
-
context "Foo" do
|
27
|
-
specify "should bar" do
|
28
|
-
(2 + 3).should.equal 5
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Since test/spec 0.4, you can also use the new RSpec 1.0 style:
|
33
|
-
|
34
|
-
require 'test/spec'
|
35
|
-
|
36
|
-
describe "Foo" do
|
37
|
-
it "should bar" do
|
38
|
-
(2 + 3).should.equal 5
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
test/spec does not include a mocking/stubbing-framework; use whichever
|
43
|
-
you like to. test/spec has been tested successfully with FlexMock and
|
44
|
-
Mocha.
|
45
|
-
|
46
|
-
test/spec has no dependencies outside Ruby 1.8.
|
47
|
-
|
48
|
-
|
49
|
-
== Mixing test/spec and test/unit
|
50
|
-
|
51
|
-
test/spec and Test::Unit contexts/test cases can be intermixed freely,
|
52
|
-
run in the same test and live in the same files. You can just add them
|
53
|
-
to your Rake::TestTask, too. test/spec allows you to leverage your
|
54
|
-
full existing Test::Unit infrastructure.
|
55
|
-
|
56
|
-
test/spec does not change Test::Unit with the exception of
|
57
|
-
monkey-patching Test::Unit::TestSuite to order the test cases before
|
58
|
-
running them. (This should not do any harm, but if you know a way
|
59
|
-
around it, please tell me.)
|
60
|
-
|
61
|
-
test/spec adds seven global methods, Object#should, Kernel.context,
|
62
|
-
Kernel.xcontext, Kernel.shared_context, Kernel.describe,
|
63
|
-
Kernel.xdescribe, and Kernel.describe_shared. The Kernel methods are
|
64
|
-
private.
|
65
|
-
|
66
|
-
You can use <tt>assert_*</tt> freely in specify-blocks; Object#should
|
67
|
-
works in plain Test::Unit test cases, too, but they will not be counted.
|
68
|
-
|
69
|
-
|
70
|
-
== Wrapped assertions
|
71
|
-
|
72
|
-
+assert_equal+:: <tt>should.equal</tt>, <tt>should ==</tt>
|
73
|
-
+assert_not_equal+:: <tt>should.not.equal</tt>, <tt>should.not ==</tt>
|
74
|
-
+assert_same+:: <tt>should.be</tt>
|
75
|
-
+assert_not_same+:: <tt>should.not.be</tt>
|
76
|
-
+assert_nil+:: <tt>should.be.nil</tt>
|
77
|
-
+assert_not_nil+:: <tt>should.not.be.nil</tt>
|
78
|
-
+assert_in_delta+:: <tt>should.be.close</tt>
|
79
|
-
+assert_match+:: <tt>should.match</tt>, <tt>should =~</tt>
|
80
|
-
+assert_no_match+:: <tt>should.not.match</tt>, <tt>should.not =~</tt>
|
81
|
-
|
82
|
-
+assert_instance_of+:: <tt>should.be.an.instance_of</tt>
|
83
|
-
+assert_kind_of+:: <tt>should.be.a.kind_of</tt>
|
84
|
-
+assert_respond_to+:: <tt>should.respond_to</tt>
|
85
|
-
+assert_raise+:: <tt>should.raise</tt>
|
86
|
-
+assert_nothing_raised+:: <tt>should.not.raise</tt>
|
87
|
-
+assert_throws+:: <tt>should.throw</tt>
|
88
|
-
+assert_nothing_thrown+:: <tt>should.not.throw</tt>
|
89
|
-
|
90
|
-
+assert_block+:: <tt>should.satisfy</tt>
|
91
|
-
|
92
|
-
(+a+, +an+ and +be+ without arguments are optional and no-ops.)
|
93
|
-
|
94
|
-
|
95
|
-
== Additional assertions
|
96
|
-
|
97
|
-
These assertions are not included in Test::Unit, but have been added
|
98
|
-
to test/spec for convenience:
|
99
|
-
|
100
|
-
* <tt>should.not.satisfy</tt>
|
101
|
-
* <tt>should.include</tt>
|
102
|
-
* <tt>a.should.</tt>_predicate_ (works like <tt>assert
|
103
|
-
a.</tt>_predicate_<tt>?</tt>)
|
104
|
-
* <tt>a.should.be </tt>_operator_ (where _operator_ is one of <tt>></tt>, <tt>>=</tt>, <tt><</tt>, <tt><=</tt> or <tt>===</tt>)
|
105
|
-
* <tt>should.output</tt> (require test/spec/should-output)
|
106
|
-
|
107
|
-
If you write an useful general-purpose assertion, I'd like to hear of
|
108
|
-
it and may add it to the test/spec distribution.
|
109
|
-
|
110
|
-
|
111
|
-
== Messaging/Blaming
|
112
|
-
|
113
|
-
With more complex assertions, it may be helpful to provide a message
|
114
|
-
to show if the assertion has failed. This can be done with the
|
115
|
-
Should#blaming or Should#messaging methods:
|
116
|
-
|
117
|
-
RUBY_VERSION.should.messaging("Ruby too old.").be > "1.8.4"
|
118
|
-
|
119
|
-
(1 + 1).should.blaming("weird math").not.equal 11
|
120
|
-
|
121
|
-
|
122
|
-
== Custom shoulds ("Matchers")
|
123
|
-
|
124
|
-
To capture recurring patterns in parts of your specifications, you can
|
125
|
-
define custom "shoulds" (RSpec calls them "matchers") in your
|
126
|
-
contexts, or include modules of them:
|
127
|
-
|
128
|
-
context "Numbers"
|
129
|
-
class EqualString < Test::Spec::CustomShould
|
130
|
-
def matches?(other)
|
131
|
-
object == other.to_s
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def equal_string(str)
|
136
|
-
EqualString.new(str)
|
137
|
-
end
|
138
|
-
|
139
|
-
specify "should have to_s"
|
140
|
-
42.should equal_string("42")
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
Alternatively, your implementation can define
|
145
|
-
CustomShould#assumptions, where you can use test/spec assertions
|
146
|
-
instead of Boolean predicates:
|
147
|
-
|
148
|
-
class EqualString < Test::Spec::CustomShould
|
149
|
-
def assumptions(other)
|
150
|
-
object.should.equal other.to_s
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
A CustomShould by default takes one argument, which is placed in
|
155
|
-
self.object for your convenience.
|
156
|
-
|
157
|
-
You can CustomShould#failure_message to provide a better error
|
158
|
-
message.
|
159
|
-
|
160
|
-
|
161
|
-
== SpecDox and RDox
|
162
|
-
|
163
|
-
test/spec adds two additional test runners to Test::Unit, based on the
|
164
|
-
console runner but with a different output format.
|
165
|
-
|
166
|
-
SpecDox, run with <tt>--runner=specdox</tt> (or <tt>-rs</tt>) looks
|
167
|
-
like RSpec's output:
|
168
|
-
|
169
|
-
should.output
|
170
|
-
- works for print
|
171
|
-
- works for puts
|
172
|
-
- works with readline
|
173
|
-
|
174
|
-
RDox, run with <tt>--runner=rdox</tt> (or <tt>-rr</tt>) can be
|
175
|
-
included for RDoc documentation (e.g. see SPECS):
|
176
|
-
|
177
|
-
== should.output
|
178
|
-
* works for print
|
179
|
-
* works for puts
|
180
|
-
* works with readline
|
181
|
-
|
182
|
-
SpecDox and RDox work for Test::Unit too:
|
183
|
-
|
184
|
-
$ ruby -r test/spec test/testunit/test_testresult.rb -rs
|
185
|
-
|
186
|
-
Test::Unit::TC_TestResult
|
187
|
-
- fault notification
|
188
|
-
- passed?
|
189
|
-
- result changed notification
|
190
|
-
|
191
|
-
Finished in 0.106647 seconds.
|
192
|
-
|
193
|
-
3 specifications (30 requirements), 0 failures
|
194
|
-
|
195
|
-
Since version 0.4, SpecDox and RDox also notice and count empty
|
196
|
-
specifications.
|
197
|
-
|
198
|
-
|
199
|
-
== Disabled specifications
|
200
|
-
|
201
|
-
Akin to the usual Test::Unit practice, tests quickly can be disabled
|
202
|
-
by replacing +specify+ with +xspecify+ (or +it+ with +xit+).
|
203
|
-
test/spec will count the disabled tests when you run it with SpecDox
|
204
|
-
or RDox.
|
205
|
-
|
206
|
-
When you use xspecify/xit, you also can drop the block. This is
|
207
|
-
useful for writing specifications that you haven't yet started
|
208
|
-
implementing.
|
209
|
-
|
210
|
-
Complete contexts can be disabled by using +xcontext+/+xdescribe+.
|
211
|
-
|
212
|
-
|
213
|
-
== Setup/Teardown
|
214
|
-
|
215
|
-
Setup/Teardown methods are run in this order:
|
216
|
-
|
217
|
-
* before(:all) in order of definition
|
218
|
-
* before(:each)/setup in order of definition
|
219
|
-
* specify
|
220
|
-
* after(:each)/setup in order of definition
|
221
|
-
* before(:each)/setup in order of definition
|
222
|
-
* specify
|
223
|
-
* after(:each)/setup in order of definition
|
224
|
-
* ...
|
225
|
-
* after(:all) in order of definition
|
226
|
-
|
227
|
-
Please note that before(:all) and after(:all) are run in their own
|
228
|
-
instance, so all instance variables they set are lost(!) and not
|
229
|
-
visible to other specifications. They are e.g. useful for setting up
|
230
|
-
database connections or starting servers.
|
231
|
-
|
232
|
-
|
233
|
-
== Shared contexts
|
234
|
-
|
235
|
-
Since version 0.9, you can define shared contexts in test/spec using
|
236
|
-
shared_context/describe_shared. These contexts are not executed on
|
237
|
-
their own, but can be included with it_should_behave_like/behaves_like
|
238
|
-
in other contexts. You can use shared contexts to structure suites
|
239
|
-
with many recurring specifications.
|
240
|
-
|
241
|
-
|
242
|
-
== specrb
|
243
|
-
|
244
|
-
Since version 0.2, test/spec features a standalone test runner called
|
245
|
-
specrb. specrb is like an extended version of testrb, Test::Unit's
|
246
|
-
test runner, but has additional options. It can be used for
|
247
|
-
plain Test::Unit suites, too.
|
248
|
-
|
249
|
-
$ specrb -a -s -n should.output
|
250
|
-
|
251
|
-
should.output
|
252
|
-
- works for print
|
253
|
-
- works for puts
|
254
|
-
- works with readline
|
255
|
-
|
256
|
-
Finished in 0.162571 seconds.
|
257
|
-
|
258
|
-
3 specifications (6 requirements), 0 failures
|
259
|
-
|
260
|
-
Run <tt>specrb --help</tt> for the usage.
|
261
|
-
|
262
|
-
|
263
|
-
== test/spec on Rails
|
264
|
-
|
265
|
-
If you want to specify your Rails applications, you can use the third-party
|
266
|
-
plugin "test/spec on Rails", which can be found at:
|
267
|
-
|
268
|
-
http://svn.techno-weenie.net/projects/plugins/test_spec_on_rails/
|
269
|
-
|
270
|
-
It features testing of model validation, redirection, output, HTTP
|
271
|
-
status, template rendering and URL generation.
|
272
|
-
|
273
|
-
|
274
|
-
== Installing with RubyGems
|
275
|
-
|
276
|
-
Since version 0.3, a Gem of test/spec is available. You can install with:
|
277
|
-
|
278
|
-
gem install test-spec
|
279
|
-
|
280
|
-
I also provide a local mirror of the gems (and development snapshots)
|
281
|
-
at my site:
|
282
|
-
|
283
|
-
gem install test-spec --source http://chneukirchen.org/releases/gems
|
284
|
-
|
285
|
-
|
286
|
-
== History
|
287
|
-
|
288
|
-
* September 29th, 2006: First public release 0.1.
|
289
|
-
|
290
|
-
* October 18th, 2006: Second public release 0.2.
|
291
|
-
* Better, module-based implementation
|
292
|
-
* Official support for FlexMock and Mocha
|
293
|
-
* More robust Should#output
|
294
|
-
* Should#_operator_
|
295
|
-
* Nested contexts
|
296
|
-
* Standalone test/spec runner, specrb
|
297
|
-
|
298
|
-
* January 24th, 2007: Third public release 0.3.
|
299
|
-
* should.be_close, should.be_an_instance_of, should.be_a_kind_of,
|
300
|
-
and should.be_nil have been deprecated. Use the dot-variants of
|
301
|
-
them. These assertions will be removed in 1.0.
|
302
|
-
* specrb -a now includes -Ilib by default for easier out-of-the-box
|
303
|
-
testing.
|
304
|
-
* Added custom shoulds.
|
305
|
-
* Added messaging/blaming.
|
306
|
-
* Added disabling of specifications.
|
307
|
-
* Small bug fixes.
|
308
|
-
* Gem available.
|
309
|
-
|
310
|
-
* June 29th, 2007: Fourth public release 0.4.
|
311
|
-
* Support for Ruby 1.8.6.
|
312
|
-
* Support describe/it/before/after RSpec 1.0 syntax.
|
313
|
-
* Allow should.raise { code_that_raises }
|
314
|
-
* Add xcontext to disable complete contexts.
|
315
|
-
* Backtraces are cleaner now.
|
316
|
-
* Mention test/spec on Rails.
|
317
|
-
* Fix small Gem bugs.
|
318
|
-
* Fix bug related to counting negated assertions.
|
319
|
-
* Fix bug in specrb.
|
320
|
-
* Allow empty xspecifys.
|
321
|
-
* Make SpecDox and RDox count empty specifications.
|
322
|
-
* Allow Kernel#context to take a superclass.
|
323
|
-
|
324
|
-
* July 2nd, 2008: Fifth public release 0.9.
|
325
|
-
* Allow should.<predicate>? as well as should.<predicate>.
|
326
|
-
* Add shared contexts.
|
327
|
-
* Nested contexts now run the
|
328
|
-
setups/teardowns/before(:all)/after(:all) of their parents.
|
329
|
-
|
330
|
-
|
331
|
-
== Contact
|
332
|
-
|
333
|
-
Please mail bugs, suggestions and patches to
|
334
|
-
<mailto:chneukirchen@gmail.com>.
|
335
|
-
|
336
|
-
Darcs repository ("darcs send" is welcome for patches):
|
337
|
-
http://chneukirchen.org/repos/testspec
|
338
|
-
|
339
|
-
|
340
|
-
== Thanks to
|
341
|
-
|
342
|
-
* Eero Saynatkari for writing <tt>should.output</tt>.
|
343
|
-
* Tuxie for writing test/spec on Rails.
|
344
|
-
* Brian Donovan for allowing alternative superclasses.
|
345
|
-
* Xavier Shay for implementing nested setups/teardowns.
|
346
|
-
* Chris Wanstrath for <tt>should.raise</tt> with a block and <tt>xcontext</tt>.
|
347
|
-
* Jean-Michel Garnier for packaging the first gem.
|
348
|
-
* Mikko Lehtonen, Jan Wikholm, Matt Mower and Michael Fellinger for
|
349
|
-
testing the gem.
|
350
|
-
* Chris McGrath for reporting a bug.
|
351
|
-
* Thomas Fuchs for script.aculo.us BDD testing which convinced me.
|
352
|
-
* Dave Astels for BDD.
|
353
|
-
* The RSpec team for API inspiration.
|
354
|
-
* Nathaniel Talbott for Test::Unit.
|
355
|
-
|
356
|
-
|
357
|
-
== Copying
|
358
|
-
|
359
|
-
Copyright (C) 2006, 2007, 2008 Christian Neukirchen <http://purl.org/net/chneukirchen>
|
360
|
-
|
361
|
-
test/spec is licensed under the same terms as Ruby itself.
|
362
|
-
|
363
|
-
Please mail bugs, feature requests or patches to the mail addresses
|
364
|
-
found above or use IRC[irc://freenode.net/#ruby-lang] to contact the
|
365
|
-
developer.
|
366
|
-
|
367
|
-
|
368
|
-
== Links
|
369
|
-
|
370
|
-
Behavior-Driven Development:: <http://behaviour-driven.org/>
|
371
|
-
RSpec:: <http://rspec.rubyforge.org/>
|
372
|
-
script.aculo.us testing:: <http://mir.aculo.us/articles/2006/08/29/bdd-style-javascript-testing>
|
373
|
-
|
374
|
-
FlexMock:: <http://onestepback.org/software/flexmock/>
|
375
|
-
Mocha:: <http://mocha.rubyforge.org/>
|
376
|
-
|
377
|
-
Christian Neukirchen:: <http://chneukirchen.org/>
|
378
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
Version 1.0 (2008):: everything-done release.
|
@@ -1,146 +0,0 @@
|
|
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
|