baretest 0.1.0 → 0.2.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.
Files changed (69) hide show
  1. data/LICENSE.txt +52 -0
  2. data/MANIFEST.txt +50 -31
  3. data/README.rdoc +260 -0
  4. data/bin/baretest +82 -24
  5. data/doc/baretest.rdoc +98 -0
  6. data/doc/mocking_stubbing_test_doubles.rdoc +5 -0
  7. data/doc/quickref.rdoc +261 -0
  8. data/doc/writing_tests.rdoc +148 -0
  9. data/examples/test.rake +58 -30
  10. data/examples/tests/irb_mode/failures.rb +26 -0
  11. data/examples/tests/mock_developer/test/helper/mocks.rb +0 -0
  12. data/examples/tests/mock_developer/test/setup.rb +57 -0
  13. data/examples/tests/mock_developer/test/suite/mock_demo.rb +19 -0
  14. data/examples/tests/overview/test.rb +89 -0
  15. data/examples/tests/variations/variations_01.rb +14 -0
  16. data/examples/tests/variations/variations_02.rb +19 -0
  17. data/examples/tests/variations/variations_03.rb +19 -0
  18. data/lib/baretest/assertion/context.rb +20 -0
  19. data/lib/baretest/assertion/failure.rb +22 -0
  20. data/lib/baretest/assertion/skip.rb +21 -0
  21. data/lib/{test → baretest}/assertion/support.rb +174 -39
  22. data/lib/baretest/assertion.rb +182 -0
  23. data/lib/baretest/irb_mode.rb +263 -0
  24. data/lib/{test/assertion/failure.rb → baretest/layout.rb} +6 -5
  25. data/lib/baretest/mocha.rb +18 -0
  26. data/lib/baretest/run/cli.rb +104 -0
  27. data/lib/{test → baretest}/run/errors.rb +12 -7
  28. data/lib/{test → baretest}/run/minimal.rb +8 -3
  29. data/lib/baretest/run/profile.rb +151 -0
  30. data/lib/{test → baretest}/run/spec.rb +10 -4
  31. data/lib/baretest/run/tap.rb +44 -0
  32. data/lib/baretest/run/xml.rb +80 -0
  33. data/lib/{test → baretest}/run.rb +31 -18
  34. data/lib/baretest/setup.rb +15 -0
  35. data/lib/baretest/skipped/assertion.rb +20 -0
  36. data/lib/baretest/skipped/suite.rb +49 -0
  37. data/lib/baretest/skipped.rb +15 -0
  38. data/lib/baretest/suite.rb +234 -0
  39. data/lib/baretest/utilities.rb +43 -0
  40. data/lib/{test → baretest}/version.rb +12 -3
  41. data/lib/baretest.rb +112 -0
  42. data/test/external/bootstraptest.rb +1 -1
  43. data/test/setup.rb +1 -1
  44. data/test/{lib/test → suite/lib/baretest}/assertion/support.rb +78 -24
  45. data/test/suite/lib/baretest/assertion.rb +192 -0
  46. data/test/{lib/test → suite/lib/baretest}/irb_mode.rb +0 -0
  47. data/test/{lib/test → suite/lib/baretest}/run/cli.rb +0 -0
  48. data/test/{lib/test → suite/lib/baretest}/run/errors.rb +0 -0
  49. data/test/{lib/test → suite/lib/baretest}/run/interactive.rb +0 -0
  50. data/test/{lib/test → suite/lib/baretest}/run/spec.rb +0 -0
  51. data/test/{lib/test → suite/lib/baretest}/run/tap.rb +0 -0
  52. data/test/{lib/test → suite/lib/baretest}/run/xml.rb +0 -0
  53. data/test/{lib/test → suite/lib/baretest}/run.rb +63 -61
  54. data/test/{lib/test → suite/lib/baretest}/suite.rb +77 -54
  55. data/test/{lib/test.rb → suite/lib/baretest.rb} +37 -37
  56. metadata +61 -40
  57. data/README.markdown +0 -229
  58. data/examples/test.rb +0 -93
  59. data/lib/test/assertion.rb +0 -117
  60. data/lib/test/debug.rb +0 -34
  61. data/lib/test/irb_mode.rb +0 -104
  62. data/lib/test/run/cli.rb +0 -79
  63. data/lib/test/run/interactive.rb +0 -60
  64. data/lib/test/run/tap.rb +0 -32
  65. data/lib/test/run/xml.rb +0 -56
  66. data/lib/test/suite.rb +0 -95
  67. data/lib/test.rb +0 -118
  68. data/test/lib/test/assertion.rb +0 -142
  69. data/test/lib/test/debug.rb +0 -63
data/LICENSE.txt ADDED
@@ -0,0 +1,52 @@
1
+ The BareTest library is copyrighted free software by Stefan Rusterholz.
2
+ You can redistribute it and/or modify it under the terms o the conditions
3
+ below (also known as the 'Ruby License'):
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) rename any non-standard executables so the names do not conflict
21
+ with standard executables, which must also be provided.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or executable
26
+ form, provided that you do at least ONE of the following:
27
+
28
+ a) distribute the executables and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard executables non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial).
42
+
43
+ 5. The scripts and library files supplied as input to or produced as
44
+ output from the software do not automatically fall under the
45
+ copyright of the software, but belong to whomever generated them,
46
+ and may be sold commercially, and may be aggregated with this
47
+ software.
48
+
49
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
50
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
51
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
52
+ PURPOSE.
data/MANIFEST.txt CHANGED
@@ -1,38 +1,57 @@
1
+ LICENSE.txt
1
2
  MANIFEST.txt
2
- README.markdown
3
+ README.rdoc
3
4
  bin/baretest
5
+ doc/baretest.rdoc
6
+ doc/mocking_stubbing_test_doubles.rdoc
7
+ doc/quickref.rdoc
8
+ doc/writing_tests.rdoc
9
+ examples/tests/irb_mode/failures.rb
10
+ examples/tests/mock_developer/test/helper/mocks.rb
11
+ examples/tests/mock_developer/test/setup.rb
12
+ examples/tests/mock_developer/test/suite/mock_demo.rb
13
+ examples/tests/overview/test.rb
14
+ examples/tests/variations/variations_01.rb
15
+ examples/tests/variations/variations_02.rb
16
+ examples/tests/variations/variations_03.rb
4
17
  examples/test.rake
5
- examples/test.rb
6
- lib/test.rb
7
- lib/test/assertion.rb
8
- lib/test/assertion/failure.rb
9
- lib/test/assertion/support.rb
10
- lib/test/debug.rb
11
- lib/test/irb_mode.rb
12
- lib/test/run.rb
13
- lib/test/run/cli.rb
14
- lib/test/run/errors.rb
15
- lib/test/run/interactive.rb
16
- lib/test/run/minimal.rb
17
- lib/test/run/spec.rb
18
- lib/test/run/tap.rb
19
- lib/test/run/xml.rb
20
- lib/test/suite.rb
21
- lib/test/version.rb
18
+ lib/baretest.rb
19
+ lib/baretest/assertion.rb
20
+ lib/baretest/assertion/context.rb
21
+ lib/baretest/assertion/failure.rb
22
+ lib/baretest/assertion/skip.rb
23
+ lib/baretest/assertion/support.rb
24
+ lib/baretest/irb_mode.rb
25
+ lib/baretest/layout.rb
26
+ lib/baretest/mocha.rb
27
+ lib/baretest/run.rb
28
+ lib/baretest/run/cli.rb
29
+ lib/baretest/run/errors.rb
30
+ lib/baretest/run/minimal.rb
31
+ lib/baretest/run/profile.rb
32
+ lib/baretest/run/spec.rb
33
+ lib/baretest/run/tap.rb
34
+ lib/baretest/run/xml.rb
35
+ lib/baretest/setup.rb
36
+ lib/baretest/skipped.rb
37
+ lib/baretest/skipped/assertion.rb
38
+ lib/baretest/skipped/suite.rb
39
+ lib/baretest/suite.rb
40
+ lib/baretest/utilities.rb
41
+ lib/baretest/version.rb
22
42
  test/external/bootstraptest.rb
23
43
  test/external/bootstrapwrap.rb
24
44
  test/helper/mocks.rb
25
- test/lib/test.rb
26
- test/lib/test/assertion.rb
27
- test/lib/test/assertion/support.rb
28
- test/lib/test/debug.rb
29
- test/lib/test/irb_mode.rb
30
- test/lib/test/run.rb
31
- test/lib/test/run/cli.rb
32
- test/lib/test/run/errors.rb
33
- test/lib/test/run/interactive.rb
34
- test/lib/test/run/spec.rb
35
- test/lib/test/run/tap.rb
36
- test/lib/test/run/xml.rb
37
- test/lib/test/suite.rb
38
45
  test/setup.rb
46
+ test/suite/lib/baretest.rb
47
+ test/suite/lib/baretest/assertion.rb
48
+ test/suite/lib/baretest/assertion/support.rb
49
+ test/suite/lib/baretest/irb_mode.rb
50
+ test/suite/lib/baretest/run.rb
51
+ test/suite/lib/baretest/run/cli.rb
52
+ test/suite/lib/baretest/run/errors.rb
53
+ test/suite/lib/baretest/run/interactive.rb
54
+ test/suite/lib/baretest/run/spec.rb
55
+ test/suite/lib/baretest/run/tap.rb
56
+ test/suite/lib/baretest/run/xml.rb
57
+ test/suite/lib/baretest/suite.rb
data/README.rdoc ADDED
@@ -0,0 +1,260 @@
1
+ = Bare Test
2
+
3
+
4
+
5
+ == Summary
6
+
7
+ A testframework that doesn't stand in your way or forces you to learn a new
8
+ language. Two methods is all that is required to know.
9
+
10
+
11
+
12
+ == Also See
13
+
14
+ Executable Docs:: doc/baretest.rdoc
15
+ IRC:: The channel #ruby-lang on irc.freenode.org
16
+
17
+ I'm there under the nick apeiros.
18
+
19
+ Beware, I'm idling there 24/7, so my nick being in there doesn't
20
+ mean I'm in front of the computer.
21
+
22
+
23
+
24
+ == Description
25
+
26
+ Baretest is a Testframework that tries to stay out of your way, but support you when you want it.
27
+ In order to do so it has a load of features:
28
+
29
+ * Straightforward and terse assertions (just a block whose return value defines
30
+ success/failure)
31
+ * Easy grouping of assertions into suites
32
+ * BDD style specifications/test descriptions (NOT code), also extractable
33
+ * Uncomplicated dependency testing and skipping
34
+ * Helpers to deal painlessly with raising, throwing, float imprecision,
35
+ unordered collections etc.
36
+ * Ships with colored Shell formatter, Diagnostic-, XML- and TAP formatter
37
+ * Interactive mode - drops you into an irb session within failed assertion
38
+ with all setup methods executed, so you can inspect interactively why it
39
+ failed.
40
+ * Trivial to add new formatters (the standard formatters are only roughly 20-50
41
+ lines of code each)
42
+ * Teardown and Setup for suites
43
+ * Callbacks to integrate mock libraries
44
+ * API to use it from code, such as rake tasks (comes with an example rake-task)
45
+ * baretest executable to run tests on multiple files at once
46
+ * Diagnostic assertion helpers (e.g. same(:a, :b) will give you 'Expected
47
+ :a but got :b' as diagnostic)
48
+
49
+
50
+
51
+ == Quick Try
52
+
53
+ 1. Download from github and unpack (or clone)
54
+ 2. Change into the baretest directory: `cd the/baretest/directory`
55
+ 3. Run the examples: `./bin/baretest examples/test.rb`
56
+
57
+ That's it. Alternatively you can run baretests own tests, and play with formatters:
58
+ `./bin/baretest -f tap`
59
+
60
+
61
+
62
+ == Install
63
+
64
+ 1. run `gem install baretest`, alternatively run `sudo gem install baretest`
65
+ 2. There is no 2.
66
+
67
+ To get baretest edge, use:
68
+
69
+ 1. Download from github and unpack (or clone)
70
+ 2. Change into the baretest directory: `cd the/baretest/directory`
71
+ 3. Run the installation task: `rake gem:install` (alternatively `rake install:lib`)
72
+
73
+ If you have multiple ruby versions installed parallely, this might pick the wrong gem
74
+ executable to install the gem. You can set the GEM env variable to ensure it uses the
75
+ right one: `rake gem:install GEM=gem1.9`
76
+
77
+
78
+
79
+ == Executable
80
+
81
+ Usage:
82
+
83
+ baretest [options] [glob, ...]
84
+
85
+ Glob defaults to 'test/**/*.rb'
86
+ Providing a directory as glob is equivalent to dir/**/*.rb
87
+ Options:
88
+ -f, --format FORMAT use FORMAT for output
89
+ -F, --formats show available formats
90
+ -d, --debug set debugging flags (set $DEBUG to true)
91
+ -i, --interactive drop into IRB on error or failure
92
+ -s, --setup FILE specify setup file
93
+ -v, --version print the version and exit
94
+ -w, --warn turn warnings on for your script
95
+
96
+
97
+
98
+ == Planned Features
99
+
100
+ * Passing on flags/options for formatters
101
+ * Tagging tests to allow focusing (only run tests with/without specific tags)
102
+ * Word-wrapping for CLI runner
103
+ * Flags for color and verbose (\[no-]color and \[no-]verbose) for the executable
104
+ * baretest --init \[LAYOUT], to create the necessary directory structure
105
+ * Detect whether baretest is run from an interactive terminal or not and adjust
106
+ defaults (no-color e.g.)
107
+ * Alternative CLI runner with status implicit via colored/bg-colored descriptions
108
+ * Alternative CLI runner which prints the name of the test prior the label and rewrites
109
+ the line when the test has executed to add status & coloring.
110
+ * Simple stubbing with automatic cleanup at teardown. Example:
111
+
112
+ assert "Should require a single file listed in :requires option." do |a|
113
+ file = 'foo/bar'
114
+ stub(Kernel, :require) do |file, *args| a.touch(file) end
115
+ ::Test::Suite.create(nil, nil, :requires => file)
116
+
117
+ touched file
118
+ end
119
+
120
+ * Inline tests via Module#describe (basically the same as Test::Suite#suite)
121
+ * YARD code to extract the specifications without running the code
122
+ * A redmine plugin
123
+ * --fail-all flag, to test/review diagnostics of tests (no idea how to do that yet)
124
+
125
+
126
+
127
+ == Rejected Features
128
+
129
+ * Currently none
130
+
131
+
132
+ == A Bit of Background
133
+
134
+ Originally, bare-test started out as a project for shits & giggles on the flight
135
+ back from vegas (railsconf09), to prove that it is possible to have a fully
136
+ fledged test-framework in under 100 lines of source-code.
137
+ Later I realized that this project could become more. For one it was (still is)
138
+ dead simple to add another formatter, it is just as dead simple to embedd it
139
+ in code.
140
+ The principles are trivial to understand, embrace and extend.
141
+ Upon that it dawned me, that the project was viable and I began adding features
142
+ not found in other projects.
143
+
144
+
145
+
146
+ == Example Testsuite
147
+
148
+ From examples/test.rb:
149
+
150
+ BareTest.suite do
151
+ # assertions and refutations can be grouped in suites. They will share
152
+ # setup and teardown
153
+ # they don't have to be in suites, though
154
+ suite "Success" do
155
+ assert "An assertion returning a trueish value (non nil/false) is a success" do
156
+ true
157
+ end
158
+ end
159
+
160
+ suite "Failure" do
161
+ assert "An assertion returning a falsish value (nil/false) is a failure" do
162
+ false
163
+ end
164
+ end
165
+
166
+ suite "Pending" do
167
+ assert "An assertion without a block is pending"
168
+ end
169
+
170
+ suite "Error" do
171
+ assert "Uncaught exceptions in an assertion are an error" do
172
+ raise "Error!"
173
+ end
174
+ end
175
+
176
+ suite "Special assertions" do
177
+ assert "Assert a block to raise" do
178
+ raises do
179
+ sleep(rand()/3+0.05)
180
+ raise "If this raises then the assertion is a success"
181
+ end
182
+ end
183
+
184
+ assert "Assert a float to be close to another" do
185
+ a = 0.18 - 0.01
186
+ b = 0.17
187
+ within_delta a, b, 0.001
188
+ end
189
+
190
+ suite "Nested suite" do
191
+ assert "Assert two randomly ordered arrays to contain the same values" do
192
+ a = [*"A".."Z"] # an array with values from A to Z
193
+ b = a.sort_by { rand }
194
+ equal_unordered(a, b) # can be used with any Enumerable, uses hash-key identity
195
+ end
196
+ end
197
+ end
198
+
199
+ suite "Setup & Teardown" do
200
+ setup do
201
+ @foo = "foo"
202
+ @bar = "bar"
203
+ end
204
+
205
+ assert "@foo should be set" do
206
+ @foo == "foo"
207
+ end
208
+
209
+ suite "Nested suite" do
210
+ setup do
211
+ @bar = "inner bar"
212
+ @baz = "baz"
213
+ end
214
+
215
+ assert "@foo is inherited" do
216
+ @foo == "foo"
217
+ end
218
+
219
+ assert "@bar is overridden" do
220
+ @bar == "inner bar"
221
+ end
222
+
223
+ assert "@baz is defined only for inner" do
224
+ @baz == "baz"
225
+ end
226
+ end
227
+
228
+ teardown do
229
+ @foo = nil # not that it'd make much sense, just to demonstrate
230
+ end
231
+ end
232
+
233
+ suite "Dependencies", :requires => ['foo', 'bar'] do
234
+ assert "Will be skipped, due to unsatisfied dependencies" do
235
+ failure "Why the heck do you have a 'foo/bar' file?"
236
+ end
237
+ end
238
+ end
239
+
240
+
241
+
242
+ == Credits & Contributions
243
+
244
+ * dominikh
245
+ * adding mocha integration
246
+ * showing me every dirty little bit I did wrong
247
+ * fixes
248
+ * added line number on failures
249
+
250
+
251
+
252
+ == Known bugs
253
+
254
+ Currently none.
255
+
256
+
257
+
258
+ == Foot Notes
259
+ <sup>1</sup>:: The abbreviated form without support code and output formatters.
260
+ The normal code is expanded to more lines for readability.
data/bin/baretest CHANGED
@@ -8,19 +8,19 @@
8
8
 
9
9
 
10
10
 
11
- # Make sure the right libs are loaded, tries plain 'test' first, then a rubygem 'test', then
12
- # the relative path it'd be if it isn't installed at all and you're just testrunning it.
11
+ Version = "0.3.2"
12
+
13
+
14
+
13
15
  require 'optparse'
14
16
  begin
15
- require 'test'
17
+ # if baretest is installed as a gem, the executable is be wrapped by rubgems anyway, so we don't
18
+ # need to require rubygems ourself.
19
+ require 'baretest'
16
20
  rescue LoadError
17
- begin
18
- require 'rubygems'
19
- require 'test'
20
- rescue LoadError
21
- $LOAD_PATH.unshift(File.expand_path("#{__FILE__}/../../lib"))
22
- require 'test'
23
- end
21
+ # assume baretest is not installed and this is a cold-run from source
22
+ $LOAD_PATH.unshift(File.expand_path("#{__FILE__}/../../lib"))
23
+ require 'baretest'
24
24
  end
25
25
 
26
26
 
@@ -33,23 +33,80 @@ setup_path = nil
33
33
  opts = OptionParser.new("", 24, ' ') do |opts|
34
34
  opts.banner = "Usage: baretest [options] [glob, ...]"
35
35
 
36
- opts.separator "Glob defaults to 'test/**/*.rb'"
36
+ opts.separator "Glob defaults to 'test/{suite,unit,integration,system}/**/*.rb'"
37
37
  opts.separator "Providing a directory as glob is equivalent to dir/**/*.rb\n"
38
38
  opts.separator "Options:"
39
39
 
40
+ opts.on(nil, "--init", "create the necessary directories and files") {
41
+ core = %w[
42
+ test
43
+ test/external
44
+ test/helper
45
+ test/helper/suite
46
+ test/suite
47
+ ]
48
+ mirror = {
49
+ 'bin' => %w[test/helper/suite test/suite],
50
+ 'lib' => %w[test/helper/suite test/suite],
51
+ 'rake' => %w[test/helper/suite test/suite],
52
+ }
53
+ files = {
54
+ 'test/setup.rb' => <<-END_OF_SETUP.gsub(/^ {8}/, '')
55
+ $LOAD_PATH.unshift(File.expand_path("\#{__FILE__}/../../lib")) # Add PROJECT/lib to $LOAD_PATH
56
+ END_OF_SETUP
57
+ }
58
+
59
+ puts "Creating all directories and files needed in #{File.expand_path('.')}"
60
+ core.each do |dir|
61
+ if File.exist?(dir) then
62
+ puts "Directory #{dir} exists already -- skipping"
63
+ else
64
+ puts "Creating #{dir}"
65
+ Dir.mkdir(dir)
66
+ end
67
+ end
68
+ mirror.each do |path, destinations|
69
+ if File.exist?(path) then
70
+ destinations.each do |destination|
71
+ destination = File.join(destination,path)
72
+ if File.exist?(destination) then
73
+ puts "Mirror #{destination} of #{path} exists already -- skipping"
74
+ else
75
+ puts "Mirroring #{path} in #{destination}"
76
+ Dir.mkdir(destination)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ files.each do |path, data|
82
+ if File.exist?(path) then
83
+ puts "File #{path} exists already -- skipping"
84
+ else
85
+ puts "Writing #{path}"
86
+ File.open(path, 'wb') do |fh|
87
+ fh.write(data)
88
+ end
89
+ end
90
+ end
91
+
92
+ exit
93
+ }
94
+
40
95
  opts.on("-f", "--format FORMAT", "use FORMAT for output") { |use|
41
96
  format = use
42
97
  }
43
98
 
44
99
  opts.on("-F", "--formats", "show available formats") { |use|
45
- Dir.glob("{#{$LOAD_PATH.join(',')}}/test/run/*.rb") { |path|
100
+ puts "Available formats:"
101
+ Dir.glob("{#{$LOAD_PATH.join(',')}}/baretest/run/*.rb") { |path|
46
102
  puts "- #{File.basename(path, '.rb')}"
47
103
  }
48
104
  exit
49
105
  }
50
106
 
51
107
  opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") {
52
- $DEBUG = true
108
+ $DEBUG = true
109
+ $VERBOSE = true
53
110
  }
54
111
 
55
112
  opts.on("-i", "--interactive", "drop into IRB on error or failure") {
@@ -61,7 +118,7 @@ opts = OptionParser.new("", 24, ' ') do |opts|
61
118
  }
62
119
 
63
120
  opts.on("-v", "--version", "print the version and exit") {
64
- puts "baretest version 0.2"
121
+ puts "baretest executable version #{Version}, library version #{BareTest::VERSION}"
65
122
  exit
66
123
  }
67
124
 
@@ -76,15 +133,11 @@ end
76
133
 
77
134
  # Load the setup file, all helper files and all test files
78
135
  if ARGV.empty? then
79
- setup_path ||= 'test/setup.rb'
80
- load(setup_path) if File.exist?(setup_path)
81
- Dir.glob('test/lib/**/*.rb') { |path|
82
- helper_path = path.sub(%r{^test/lib/}, 'test/helper/')
83
- puts "Loading helper file #{helper_path}" if $VERBOSE
84
- load(helper_path) if File.exist?(helper_path)
85
- puts "Loading test file #{path}" if $VERBOSE
86
- load(path)
87
- }
136
+ BareTest.load_standard_test_files(
137
+ :verbose => $VERBOSE,
138
+ :setup_path => setup_path,
139
+ :chdir => '.'
140
+ )
88
141
  else
89
142
  load(setup_path) if setup_path && File.exist?(setup_path)
90
143
  ARGV.each { |path|
@@ -99,4 +152,9 @@ end
99
152
 
100
153
 
101
154
  # Run the tests
102
- Test.run(:format => format, :interactive => interactive)
155
+ puts if $VERBOSE
156
+ if BareTest.run(:format => format, :interactive => interactive).global_status == :success then
157
+ exit 0
158
+ else
159
+ exit 1
160
+ end
data/doc/baretest.rdoc ADDED
@@ -0,0 +1,98 @@
1
+ = The baretest executable
2
+
3
+
4
+
5
+ == 1. Usage
6
+
7
+ Basic Usage:
8
+
9
+ baretest [options] [glob, ...]"
10
+
11
+ Either you provide a `glob` (or a directory, which is equivalent to DIRECTORY/\*\*/\*.rb),
12
+ then baretest will load all the files it matches and invoke BareTest.run in the end. Or you
13
+ use the standard way and let baretest use convention. For that you should run baretest within
14
+ the project, preferably the toplevel.
15
+ Baretest will then search the directory tree upwards until it finds 'test/setup.rb'. It
16
+ will then use the default layout of a project, which should look roughly like this:
17
+
18
+ |-- bin
19
+ | `-- ...
20
+ |-- doc
21
+ | `-- ...
22
+ |-- examples
23
+ | `-- ...
24
+ |-- lib
25
+ | `-- ...
26
+ |-- rake
27
+ | `-- ...
28
+ `-- test
29
+ |-- external
30
+ | `-- ...
31
+ |-- helper
32
+ | `-- ...
33
+ |-- setup.rb
34
+ `-- suite
35
+ |-- bin
36
+ | `-- ...
37
+ `-- lib
38
+ `-- ...
39
+
40
+ The important part are the directories under 'test'. The directory 'test/suite' should mirror your
41
+ project, but instead of the real files contain the files that test their counterparts. For example,
42
+ the file 'YOURPROJECT/lib/yourproject.rb' has its tests in
43
+ 'YOURPROJECT/test/suite/lib/yourproject.rb'.
44
+ Additionally, baretest will in that mode look for a file
45
+ 'YOURPROJECT/test/helper/suite/lib/yourproject.rb' and load it if found.
46
+
47
+
48
+
49
+ == 2. Options
50
+
51
+
52
+ === Getting information about baretest:
53
+
54
+ -F, \--formats:: Lists the available output formatters
55
+
56
+ -v:: Prints the baretest executables and the libs version number
57
+
58
+
59
+ === Running tests:
60
+
61
+ -i, \--interactive:: drop into IRB on error or failure
62
+
63
+ -d, \--debug:: Set debugging flags.
64
+
65
+ This sets $DEBUG to true, same as rubys -d switch.
66
+
67
+ -f, \--format FORMAT:: Use the formatter specified in FORMAT, defaults to 'cli'
68
+
69
+ -s, \--setup FILE:: specify setup file
70
+
71
+ This option allows you to tell baretest where it finds the setup.rb file.
72
+
73
+ Defaults to test/setup.rb.
74
+
75
+ -w, \--warn:: Turn warnings on for your script.
76
+
77
+ This sets $VERBOSE to true, same as rubys -w switch.
78
+
79
+ Additionally, some formatters will provide more information
80
+ (e.g. full backtraces on errors) when $VERBOSE is set.
81
+
82
+
83
+
84
+ === 3. The interactive mode
85
+
86
+ In interactive mode, baretest will stop execution when an error or a failure is hit. It
87
+ then prints out the status, the assertions description, its code and then drops you into
88
+ an irb-shell in the context of the failed assertion, with setup already executed. You
89
+ can then try out what caused the assertion to fail.
90
+
91
+ Be aware that printing the code relies on your indentation.
92
+
93
+
94
+
95
+ === 4. Writing a formatter
96
+
97
+ This section will follow. For now, just take a look at the existing formatters.
98
+ They are pretty simple.
@@ -0,0 +1,5 @@
1
+ = Mocking, Stubbing and TestDoubles
2
+
3
+ BareTest off-the-shelf provides currently only integration with mocha.
4
+ You can use mocha (assuming you have installed the mocha gem) by requiring 'baretest/mocha'.
5
+ Best you add that to your setup.rb.