relevance-test-spec 0.4.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1 @@
1
+ vx.x.x. Add focused specs (ie "fit"); add pending specs if you leave off the block
data/Manifest ADDED
@@ -0,0 +1,29 @@
1
+ bin/specrb
2
+ CHANGELOG
3
+ examples/stack.rb
4
+ examples/stack_spec.rb
5
+ lib/test/spec/dox.rb
6
+ lib/test/spec/focused/collector-extensions.rb
7
+ lib/test/spec/focused/focused.rb
8
+ lib/test/spec/rails_helper.rb
9
+ lib/test/spec/rdox.rb
10
+ lib/test/spec/should-output.rb
11
+ lib/test/spec/version.rb
12
+ lib/test/spec.rb
13
+ Rakefile
14
+ README.rdoc
15
+ ROADMAP
16
+ SPECS
17
+ test/helper.rb
18
+ test/spec_dox.rb
19
+ test/spec_flexmock.rb
20
+ test/spec_focused.rb
21
+ test/spec_mocha.rb
22
+ test/spec_nestedcontexts.rb
23
+ test/spec_new_style.rb
24
+ test/spec_should-output.rb
25
+ test/spec_testspec.rb
26
+ test/spec_testspec_order.rb
27
+ test/test_testunit.rb
28
+ TODO
29
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,394 @@
1
+ = test/spec, a BDD interface for Test::Unit
2
+
3
+ === Copyright (C) 2006, 2007, 2008 Christian Neukirchen <mailto:chneukirchen@gmail.com>
4
+ === Relevance Fork by Rob Sanheim
5
+
6
+ == What does this fork add?
7
+
8
+ This is a fork to add some new features to make the dev experience nicer, and also to DRY up boilerplate
9
+ that can appear in test/spec.
10
+
11
+ Specifically:
12
+
13
+ * Rspec style pending specs - leave off the block, and the spec is automatically pending:
14
+
15
+ it "this is a pending spec"
16
+
17
+ * Focused specs - prepend an `it` declaration with "f", so it reads `fit`, and that spec will run at the exclusion of all others. This is great for use in autotest, when you make a change and ten specs start failing and you want to focus on one spec at a time as you move through them and fix them. For example:
18
+
19
+ fit "can create things" # test/spec will only run this spec, and ignore all others, until you remove the leading "f"
20
+
21
+ * DRY'er, context-aware spec declarations for Rails projects. Very similiar to Rspec's Rails support:
22
+
23
+ describe UsersController # Subclasses ActionController::TestCase and sets up the UsersController properly
24
+ describe User # Subclasses ActiveSupport::TestCase for model specs
25
+
26
+
27
+ == What is test/spec?
28
+
29
+ test/spec layers an RSpec-inspired interface on top of Test::Unit, so
30
+ you can mix TDD and BDD (Behavior-Driven Development).
31
+
32
+ test/spec is a clean-room implementation that maps most kinds of
33
+ Test::Unit assertions to a `should'-like syntax.
34
+
35
+ Consider this Test::Unit test case:
36
+
37
+ class TestFoo < Test::Unit::TestCase
38
+ def test_should_bar
39
+ assert_equal 5, 2 + 3
40
+ end
41
+ end
42
+
43
+ In test/spec, it looks like this:
44
+
45
+ require 'test/spec'
46
+
47
+ context "Foo" do
48
+ specify "should bar" do
49
+ (2 + 3).should.equal 5
50
+ end
51
+ end
52
+
53
+ Since test/spec 0.4, you can also use the new RSpec 1.0 style:
54
+
55
+ require 'test/spec'
56
+
57
+ describe "Foo" do
58
+ it "should bar" do
59
+ (2 + 3).should.equal 5
60
+ end
61
+ end
62
+
63
+ test/spec does not include a mocking/stubbing-framework; use whichever
64
+ you like to. test/spec has been tested successfully with FlexMock and
65
+ Mocha.
66
+
67
+ test/spec has no dependencies outside Ruby 1.8.
68
+
69
+
70
+ == Mixing test/spec and test/unit
71
+
72
+ test/spec and Test::Unit contexts/test cases can be intermixed freely,
73
+ run in the same test and live in the same files. You can just add them
74
+ to your Rake::TestTask, too. test/spec allows you to leverage your
75
+ full existing Test::Unit infrastructure.
76
+
77
+ test/spec does not change Test::Unit with the exception of
78
+ monkey-patching Test::Unit::TestSuite to order the test cases before
79
+ running them. (This should not do any harm, but if you know a way
80
+ around it, please tell me.)
81
+
82
+ test/spec adds three global methods, Object#should, Kernel.context,
83
+ and Kernel.describe.
84
+
85
+ You can use <tt>assert_*</tt> freely in specify-blocks; Object#should
86
+ works in plain Test::Unit test cases, too, but they will not be counted.
87
+
88
+
89
+ == Wrapped assertions
90
+
91
+ +assert_equal+:: <tt>should.equal</tt>, <tt>should ==</tt>
92
+ +assert_not_equal+:: <tt>should.not.equal</tt>, <tt>should.not ==</tt>
93
+ +assert_same+:: <tt>should.be</tt>
94
+ +assert_not_same+:: <tt>should.not.be</tt>
95
+ +assert_nil+:: <tt>should.be.nil</tt>
96
+ +assert_not_nil+:: <tt>should.not.be.nil</tt>
97
+ +assert_in_delta+:: <tt>should.be.close</tt>
98
+ +assert_match+:: <tt>should.match</tt>, <tt>should =~</tt>
99
+ +assert_no_match+:: <tt>should.not.match</tt>, <tt>should.not =~</tt>
100
+
101
+ +assert_instance_of+:: <tt>should.be.an.instance_of</tt>
102
+ +assert_kind_of+:: <tt>should.be.a.kind_of</tt>
103
+ +assert_respond_to+:: <tt>should.respond_to</tt>
104
+ +assert_raise+:: <tt>should.raise</tt>
105
+ +assert_nothing_raised+:: <tt>should.not.raise</tt>
106
+ +assert_throws+:: <tt>should.throw</tt>
107
+ +assert_nothing_thrown+:: <tt>should.not.throw</tt>
108
+
109
+ +assert_block+:: <tt>should.satisfy</tt>
110
+
111
+ (+a+, +an+ and +be+ without arguments are optional and no-ops.)
112
+
113
+
114
+ == Additional assertions
115
+
116
+ These assertions are not included in Test::Unit, but have been added
117
+ to test/spec for convenience:
118
+
119
+ * <tt>should.not.satisfy</tt>
120
+ * <tt>should.include</tt>
121
+ * <tt>a.should.</tt>_predicate_ (works like <tt>assert
122
+ a.</tt>_predicate_<tt>?</tt>)
123
+ * <tt>a.should.be </tt>_operator_ (where _operator_ is one of <tt>></tt>, <tt>>=</tt>, <tt><</tt>, <tt><=</tt> or <tt>===</tt>)
124
+ * <tt>should.output</tt> (require test/spec/should-output)
125
+
126
+ If you write an useful general-purpose assertion, I'd like to hear of
127
+ it and may add it to the test/spec distribution.
128
+
129
+
130
+ == Messaging/Blaming
131
+
132
+ With more complex assertions, it may be helpful to provide a message
133
+ to show if the assertion has failed. This can be done with the
134
+ Should#blaming or Should#messaging methods:
135
+
136
+ RUBY_VERSION.should.messaging("Ruby too old.").be > "1.8.4"
137
+
138
+ (1 + 1).should.blaming("weird math").not.equal 11
139
+
140
+
141
+ == Custom shoulds ("Matchers")
142
+
143
+ To capture recurring patterns in parts of your specifications, you can
144
+ define custom "shoulds" (RSpec calls them "matchers") in your
145
+ contexts, or include modules of them:
146
+
147
+ context "Numbers"
148
+ class EqualString < Test::Spec::CustomShould
149
+ def matches?(other)
150
+ object == other.to_s
151
+ end
152
+ end
153
+
154
+ def equal_string(str)
155
+ EqualString.new(str)
156
+ end
157
+
158
+ specify "should have to_s"
159
+ 42.should equal_string("42")
160
+ end
161
+ end
162
+
163
+ Alternatively, your implementation can define
164
+ CustomShould#assumptions, where you can use test/spec assertions
165
+ instead of Boolean predicates:
166
+
167
+ class EqualString < Test::Spec::CustomShould
168
+ def assumptions(other)
169
+ object.should.equal other.to_s
170
+ end
171
+ end
172
+
173
+ A CustomShould by default takes one argument, which is placed in
174
+ self.object for your convenience.
175
+
176
+ You can CustomShould#failure_message to provide a better error
177
+ message.
178
+
179
+
180
+ == SpecDox and RDox
181
+
182
+ test/spec adds two additional test runners to Test::Unit, based on the
183
+ console runner but with a different output format.
184
+
185
+ SpecDox, run with <tt>--runner=specdox</tt> (or <tt>-rs</tt>) looks
186
+ like RSpec's output:
187
+
188
+ should.output
189
+ - works for print
190
+ - works for puts
191
+ - works with readline
192
+
193
+ RDox, run with <tt>--runner=rdox</tt> (or <tt>-rr</tt>) can be
194
+ included for RDoc documentation (e.g. see SPECS):
195
+
196
+ == should.output
197
+ * works for print
198
+ * works for puts
199
+ * works with readline
200
+
201
+ SpecDox and RDox work for Test::Unit too:
202
+
203
+ $ ruby -r test/spec test/testunit/test_testresult.rb -rs
204
+
205
+ Test::Unit::TC_TestResult
206
+ - fault notification
207
+ - passed?
208
+ - result changed notification
209
+
210
+ Finished in 0.106647 seconds.
211
+
212
+ 3 specifications (30 requirements), 0 failures
213
+
214
+ Since version 0.4, SpecDox and RDox also notice and count empty
215
+ specifications.
216
+
217
+
218
+ == Disabled specifications
219
+
220
+ Akin to the usual Test::Unit practice, tests quickly can be disabled
221
+ by replacing +specify+ with +xspecify+ (or +it+ with +xit+).
222
+ test/spec will count the disabled tests when you run it with SpecDox
223
+ or RDox.
224
+
225
+ When you use xspecify/xit, you also can drop the block. This is
226
+ useful for writing specifications that you haven't yet started
227
+ implementing.
228
+
229
+ Complete contexts can be disabled by using +xcontext+/+xdescribe+.
230
+
231
+
232
+ == Setup/Teardown
233
+
234
+ Setup/Teardown methods are run in this order:
235
+
236
+ * before(:all) in order of definition
237
+ * before(:each)/setup in order of definition
238
+ * specify
239
+ * after(:each)/setup in order of definition
240
+ * before(:each)/setup in order of definition
241
+ * specify
242
+ * after(:each)/setup in order of definition
243
+ * ...
244
+ * after(:all) in order of definition
245
+
246
+ Please note that before(:all) and after(:all) are run in their own
247
+ instance, so all instance variables they set are lost(!) and not
248
+ visible to other specifications. They are e.g. useful for setting up
249
+ database connections or starting servers.
250
+
251
+
252
+ == Shared contexts
253
+
254
+ Since version 0.5, you can define shared contexts in test/spec using
255
+ shared_context/describe_shared. These contexts are not executed on
256
+ their own, but can be included with it_should_behave_like/behaves_like
257
+ in other contexts. You can use shared contexts to structure suites
258
+ with many recurring specifications.
259
+
260
+
261
+ == specrb
262
+
263
+ Since version 0.2, test/spec features a standalone test runner called
264
+ specrb. specrb is like an extended version of testrb, Test::Unit's
265
+ test runner, but has additional options. It can be used for
266
+ plain Test::Unit suites, too.
267
+
268
+ $ specrb -a -s -n should.output
269
+
270
+ should.output
271
+ - works for print
272
+ - works for puts
273
+ - works with readline
274
+
275
+ Finished in 0.162571 seconds.
276
+
277
+ 3 specifications (6 requirements), 0 failures
278
+
279
+ Run <tt>specrb --help</tt> for the usage.
280
+
281
+
282
+ == test/spec on Rails
283
+
284
+ If you want to specify your Rails applications, you can use the third-party
285
+ plugin "test/spec on Rails", which can be found at:
286
+
287
+ http://svn.techno-weenie.net/projects/plugins/test_spec_on_rails/
288
+
289
+ It features testing of model validation, redirection, output, HTTP
290
+ status, template rendering and URL generation.
291
+
292
+
293
+ == Installing with RubyGems
294
+
295
+ Since version 0.3, a Gem of test/spec is available. You can install with:
296
+
297
+ gem install test-spec
298
+
299
+ I also provide a local mirror of the gems (and development snapshots)
300
+ at my site:
301
+
302
+ gem install test-spec --source http://chneukirchen.org/releases/gems
303
+
304
+
305
+ == History
306
+
307
+ * September 29th, 2006: First public release 0.1.
308
+
309
+ * October 18th, 2006: Second public release 0.2.
310
+ * Better, module-based implementation
311
+ * Official support for FlexMock and Mocha
312
+ * More robust Should#output
313
+ * Should#_operator_
314
+ * Nested contexts
315
+ * Standalone test/spec runner, specrb
316
+
317
+ * January 24th, 2007: Third public release 0.3.
318
+ * should.be_close, should.be_an_instance_of, should.be_a_kind_of,
319
+ and should.be_nil have been deprecated. Use the dot-variants of
320
+ them. These assertions will be removed in 1.0.
321
+ * specrb -a now includes -Ilib by default for easier out-of-the-box
322
+ testing.
323
+ * Added custom shoulds.
324
+ * Added messaging/blaming.
325
+ * Added disabling of specifications.
326
+ * Small bug fixes.
327
+ * Gem available.
328
+
329
+ * June 29th, 2007: Fourth public release 0.4.
330
+ * Support for Ruby 1.8.6.
331
+ * Support describe/it/before/after RSpec 1.0 syntax.
332
+ * Allow should.raise { code_that_raises }
333
+ * Add xcontext to disable complete contexts.
334
+ * Backtraces are cleaner now.
335
+ * Mention test/spec on Rails.
336
+ * Fix small Gem bugs.
337
+ * Fix bug related to counting negated assertions.
338
+ * Fix bug in specrb.
339
+ * Allow empty xspecifys.
340
+ * Make SpecDox and RDox count empty specifications.
341
+ * Allow Kernel#context to take a superclass.
342
+
343
+ * XXX, 2007: Fifth public release 0.5.
344
+ * Allow should.<predicate>? as well as should.<predicate>.
345
+ * Add shared contexts.
346
+
347
+
348
+ == Contact
349
+
350
+ Please mail bugs, suggestions and patches to
351
+ <mailto:chneukirchen@gmail.com>.
352
+
353
+ Darcs repository ("darcs send" is welcome for patches):
354
+ http://chneukirchen.org/repos/testspec
355
+
356
+
357
+ == Thanks to
358
+
359
+ * Eero Saynatkari for writing <tt>should.output</tt>.
360
+ * Tuxie for writing test/spec on Rails.
361
+ * Brian Donovan for allowing alternative superclasses.
362
+ * Chris Wanstrath for <tt>should.raise</tt> with a block and <tt>xcontext</tt>.
363
+ * Jean-Michel Garnier for packaging the first gem.
364
+ * Mikko Lehtonen, Jan Wikholm, Matt Mower and Michael Fellinger for
365
+ testing the gem.
366
+ * Chris McGrath for reporting a bug.
367
+ * Thomas Fuchs for script.aculo.us BDD testing which convinced me.
368
+ * Dave Astels for BDD.
369
+ * The RSpec team for API inspiration.
370
+ * Nathaniel Talbott for Test::Unit.
371
+
372
+
373
+ == Copying
374
+
375
+ Copyright (C) 2006, 2007 Christian Neukirchen <http://purl.org/net/chneukirchen>
376
+
377
+ test/spec is licensed under the same terms as Ruby itself.
378
+
379
+ Please mail bugs, feature requests or patches to the mail addresses
380
+ found above or use IRC[irc://freenode.net/#ruby-lang] to contact the
381
+ developer.
382
+
383
+
384
+ == Links
385
+
386
+ Behavior-Driven Development:: <http://behaviour-driven.org/>
387
+ RSpec:: <http://rspec.rubyforge.org/>
388
+ script.aculo.us testing:: <http://mir.aculo.us/articles/2006/08/29/bdd-style-javascript-testing>
389
+
390
+ FlexMock:: <http://onestepback.org/software/flexmock/>
391
+ Mocha:: <http://mocha.rubyforge.org/>
392
+
393
+ Christian Neukirchen:: <http://chneukirchen.org/>
394
+
data/ROADMAP ADDED
@@ -0,0 +1 @@
1
+ Version 1.0 (February 2006):: first stable release.
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ begin
3
+ gem 'echoe'
4
+ require 'echoe'
5
+ rescue LoadError => e
6
+ puts "You must install echoe to dev/test this gem"
7
+ end
8
+
9
+ require './lib/test/spec/version'
10
+
11
+ echoe = Echoe.new('test-spec', Test::Spec::VERSION) do |p|
12
+ p.rubyforge_name = 'test-spec'
13
+ p.author = 'Christian Neukirchen'
14
+ p.email = 'chneukirchen@gmail.com'
15
+ p.summary = 'Relevance fork of Behaviour Driven Development interface for Test::Unit'
16
+ p.description = <<-EOF
17
+ test/spec layers an RSpec-inspired interface on top of Test::Unit, so
18
+ you can mix TDD and BDD (Behavior-Driven Development).
19
+
20
+ test/spec is a clean-room implementation that maps most kinds of
21
+ Test::Unit assertions to a `should'-like syntax.
22
+
23
+ This is a fork of the main version to add some features and make thigns a bit easier for developers.
24
+ EOF
25
+ p.url = "http://github.com/relevance/test-spec"
26
+ p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc|CHANGELOG|LICENSE|SPECS$/
27
+ rdoc_template = `allison --path`.strip << ".rb"
28
+ p.rdoc_template = rdoc_template
29
+ end
30
+
31
+ echoe.spec.executables << "specrb"
32
+ echoe.spec.add_development_dependency "allison"
33
+ echoe.spec.add_development_dependency "markaby"
34
+
35
+
36
+ desc "Make binaries executable"
37
+ task :chmod do
38
+ Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
39
+ end
40
+
41
+ desc "Generate RDox"
42
+ task "SPECS" do
43
+ ruby "bin/specrb -Ilib:test -a --rdox >SPECS"
44
+ end
45
+
46
+ desc "Run all the tests"
47
+ task :test => :chmod do
48
+ ruby "bin/specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
49
+ end
50
+
51
+ begin
52
+ require 'rcov/rcovtask'
53
+
54
+ Rcov::RcovTask.new do |t|
55
+ t.test_files = FileList['test/{spec,test}_*.rb'] + ['--', '-rs'] # evil
56
+ t.verbose = true # uncomment to see the executed command
57
+ t.rcov_opts = ["--text-report",
58
+ "--include-file", "^lib,^test",
59
+ "--exclude-only", "^/usr,^/home/.*/src"]
60
+ end
61
+ rescue LoadError
62
+ end