bacon 1.0.0 → 1.1.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.
@@ -0,0 +1,220 @@
1
+ Sat Oct 25 12:30:00 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
2
+ * De-metaprogram and document nested before/after
3
+
4
+ Fri Oct 24 17:20:17 2008 -0500 Yossef Mendelssohn <ymendel@pobox.com>
5
+ * Having higher-level after blocks also be run for nested contexts.
6
+
7
+ Fri Oct 24 17:14:30 2008 -0500 Yossef Mendelssohn <ymendel@pobox.com>
8
+ * Cleaning up setting of nested before blocks
9
+
10
+ Fri Oct 24 17:09:42 2008 -0500 Yossef Mendelssohn <ymendel@pobox.com>
11
+ * Ensuring that nested before blocks are run in the correct order
12
+
13
+ Fri Oct 24 17:06:18 2008 -0500 Yossef Mendelssohn <ymendel@pobox.com>
14
+ * Ensuring that before blocks don't bleed into sibling levels
15
+
16
+ Fri Oct 24 17:01:51 2008 -0500 Yossef Mendelssohn <ymendel@pobox.com>
17
+ * Letting before blocks be run from higher levels in nested context
18
+
19
+ Split up Context#initialize to let running be a separate step.
20
+ Added attr_reader for Context name and block to let the running step have access
21
+ to them without resorting to instance variables.
22
+
23
+ Sat Oct 4 13:38:23 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
24
+ * Move to git
25
+
26
+ Sun Aug 17 13:32:40 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
27
+ * Add option to disable backtraces
28
+
29
+ Sun Aug 17 12:48:29 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
30
+ * Don't %-expand twice in TAP output
31
+
32
+ Fri Aug 1 12:01:28 2008 +0200 jftucker <jftucker@gmail.com>
33
+ * pols-for-at-exit
34
+
35
+ Added an alias for summary_on_exit to summary_at_exit to save on POLS for some people (me!).
36
+
37
+ Sun Jul 6 18:47:42 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
38
+ * Add bacon_rspec.rb to avoid errors when .bacon doesn't exist
39
+
40
+ Sun Jul 6 18:05:13 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
41
+ * Push VERSION to 1.0
42
+
43
+ Sun Jul 6 18:04:55 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
44
+ * Small reformatting
45
+
46
+ Sun Jul 6 18:04:41 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
47
+ * Update README
48
+
49
+ Sun Jul 6 18:03:51 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
50
+ * Allow 50 lines more code
51
+
52
+ Sun Jul 6 17:46:07 2008 +0200 Christian Neukirchen <chneukirchen@gmail.com>
53
+ * Suppress warnings when the suite loads Bacon again
54
+
55
+ Wed Jun 25 13:56:34 2008 +0200 jftucker <jftucker@gmail.com>
56
+ * support spec/test subdirs for -a
57
+
58
+ Wed Jun 25 13:20:29 2008 +0200 jftucker <jftucker@gmail.com>
59
+ * support mappings for subdirs in autotest
60
+
61
+ Wed Jun 25 00:27:08 2008 +0200 jftucker <jftucker@gmail.com>
62
+ * adding autotest support
63
+
64
+ The autotest auto discovery uses bacons test/unit output.
65
+ It does not currently call specific examples (TODO).
66
+ It currently attempts to fix the rspec auto discovery by removing it if it
67
+ finds a .bacon under test/ or spec/. In fact, these are the only conditions
68
+ under which the bacon autotest will load.
69
+
70
+ Thu Mar 13 04:00:42 2008 +0100 Michael Fellinger m.fellinger@gmail.com <chneukirchen@gmail.com>
71
+ * Show exception instead of missing error if a spec is empty because of it.
72
+
73
+ Sun Mar 2 11:52:38 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
74
+ * Call after-blocks even if before-blocks or spec raise exceptions
75
+
76
+ Based on a patch by Keita Yamaguchi
77
+
78
+ Sun Mar 2 11:52:09 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
79
+ * Count failed requirements too
80
+
81
+ Sun Feb 10 18:45:24 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
82
+ * Reformats
83
+
84
+ Sun Feb 10 18:42:32 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
85
+ * Empty specifications are now erroneous
86
+
87
+ Sun Feb 10 14:49:58 2008 +0100 Michael Fellinger <m.fellinger@gmail.com>
88
+ * Improve require for lib/bacon
89
+
90
+ Wed Jan 23 23:59:40 2008 +0100 rff.rff <rff.rff@gmail.com>
91
+ * allows multiple arguments to #describe to allow specialized behaviours such as
92
+
93
+ describe Queue,'empty'
94
+ describe Queue,'full'
95
+
96
+ Some tests for this and manveru's latest patch are included
97
+
98
+ Sat Jan 19 23:07:25 2008 +0100 Michael Fellinger <m.fellinger@gmail.com>
99
+ * #to_s the argument to describe
100
+
101
+ Fri Jan 18 15:25:27 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
102
+ * Flunk if there are no arguments to #it
103
+
104
+ Mon Jan 14 01:34:44 2008 +0100 rff.rff <rff.rff@gmail.com>
105
+ * add should('foo') shortcut for it('should foo')
106
+
107
+ Mon Jan 7 20:24:04 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
108
+ * Last minute
109
+
110
+ Mon Jan 7 20:21:43 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
111
+ * Update copyright
112
+
113
+ Mon Jan 7 20:08:40 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
114
+ * Tighten code
115
+
116
+ Mon Jan 7 19:33:39 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
117
+ * Update README
118
+
119
+ Mon Jan 7 19:33:25 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
120
+ * Add bacon -o FORMAT
121
+
122
+ Mon Jan 7 19:33:07 2008 +0100 Christian Neukirchen <chneukirchen@gmail.com>
123
+ * Improve TAP output
124
+
125
+ Mon Dec 31 19:01:49 2007 +0100 Michael Fellinger <m.fellinger@gmail.com>
126
+ * behaves_like should take multiple names
127
+
128
+ Sun Dec 30 19:38:18 2007 +0100 Michael Fellinger <m.fellinger@gmail.com>
129
+ * Adding Proc#change? to check for changes on repeated calling of proc.
130
+
131
+ Fri Dec 28 12:42:04 2007 +0100 Michael Fellinger <m.fellinger@gmail.com>
132
+ * Patching for ruby 1.9.0 and removing useless spaces
133
+
134
+ Wed Dec 5 14:56:51 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
135
+ * Make code nicer
136
+
137
+ Wed Dec 5 14:48:06 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
138
+ * Fix Rakefile
139
+
140
+ Wed Dec 5 14:46:32 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
141
+ * Integrate Rakefile
142
+
143
+ Wed Dec 5 14:43:26 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
144
+ * Add Rakefile
145
+
146
+ Wed Dec 5 14:41:53 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
147
+ * Add README
148
+
149
+ Wed Dec 5 14:41:26 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
150
+ * Add copyright
151
+
152
+ Wed Dec 5 14:18:54 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
153
+ * Move #close? to Numeric
154
+
155
+ Wed Dec 5 14:11:34 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
156
+ * Add flunking
157
+
158
+ Wed Dec 5 13:42:13 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
159
+ * Allow using Object#should outside of contexts providing boolean return
160
+
161
+ Wed Dec 5 13:41:00 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
162
+ * Move summary outputter to lib/bacon.rb
163
+
164
+ Wed Dec 5 13:26:27 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
165
+ * Fix output of summary
166
+
167
+ Wed Dec 5 13:26:16 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
168
+ * Add identical_to/same_as
169
+
170
+ Wed Dec 5 02:12:24 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
171
+ * Remove debugging statements
172
+
173
+ Wed Dec 5 02:00:03 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
174
+ * Refactor tests
175
+
176
+ Wed Dec 5 01:58:08 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
177
+ * Test Context#should.{throw,raise}
178
+
179
+ Wed Dec 5 01:56:29 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
180
+ * Add should.throw
181
+
182
+ Wed Dec 5 01:49:33 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
183
+ * Implement -n and -t for filtering on context/specification names
184
+
185
+ Wed Dec 5 01:41:56 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
186
+ * Add shared contexts
187
+
188
+ Wed Dec 5 01:41:39 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
189
+ * Make directives belong to Kernel and private
190
+
191
+ Wed Dec 5 01:41:17 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
192
+ * Clear up error reporting
193
+
194
+ Wed Dec 5 01:23:27 2007 +0100 Christian Neukirchen <chneukirchen@gmail.com>
195
+ * Add TAP generator
196
+
197
+ Thu May 31 14:32:48 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
198
+ * Set correct $?
199
+
200
+ Thu May 31 14:28:35 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
201
+ * Add Test::Unit-like output (-q)
202
+
203
+ Thu May 31 14:18:00 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
204
+ * Add standalone runner, bin/bacon
205
+
206
+ Thu May 31 14:17:40 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
207
+ * Import test-suite
208
+
209
+ Thu May 31 14:17:05 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
210
+ * Fix for testsuite
211
+
212
+ Thu May 31 14:16:25 2007 +0200 Christian Neukirchen <chneukirchen@gmail.com>
213
+ * Fix output
214
+
215
+ Wed May 30 17:50:23 2007 +0200 Christian Neukirchen <chneukirchen��@gmail.com>
216
+ * Externalize spec/req handling
217
+
218
+ Wed May 30 17:32:15 2007 +0200 Christian Neukirchen <chneukirchen��@gmail.com>
219
+ * Import Bacon, a small spec framework
220
+
data/RDOX CHANGED
@@ -25,6 +25,15 @@ Bacon
25
25
 
26
26
  before/after
27
27
  - should run in the right order
28
+ when nested
29
+ - should run from higher level
30
+ - should run at the nested level
31
+ - should run in the right order
32
+
33
+ - should not run from lower level
34
+ when nested at a sibling level
35
+ - should not run from sibling level
36
+
28
37
 
29
38
  shared/behaves_like
30
39
  - gets called where it is included
@@ -57,4 +66,4 @@ describe arguments
57
66
  - should add new specifications
58
67
  - should have been called
59
68
 
60
- 39 specifications (359 requirements), 0 failures, 0 errors
69
+ 44 specifications (375 requirements), 0 failures, 0 errors
data/README CHANGED
@@ -6,6 +6,7 @@
6
6
  Bacon is a small RSpec clone weighing less than 350 LoC but
7
7
  nevertheless providing all essential features.
8
8
 
9
+
9
10
  == Whirl-wind tour
10
11
 
11
12
  require 'bacon'
@@ -104,6 +105,25 @@ It also supports TAP:
104
105
 
105
106
  (taptap is available from http://chneukirchen.org/repos/taptap/)
106
107
 
108
+ As of Bacon 1.1, it also supports Knock:
109
+
110
+ $ bacon -k whirlwind.rb
111
+ ok - should be empty
112
+ ok - should have zero size
113
+ ok - should raise on trying fetch any index
114
+ ok - should have an object identity
115
+ ok - should be a palindrome
116
+ not ok - should have super powers: FAILED
117
+ # Bacon::Error: no super powers found
118
+ # ./whirlwind.rb:39: A new array - should have super powers
119
+ # ./whirlwind.rb:38
120
+ # ./whirlwind.rb:3
121
+
122
+ $ bacon -k whirlwind.rb | kn-sum
123
+ 6 tests, 1 failed (83.3333% succeeded)
124
+
125
+ (knock is available from http://github.com/chneukirchen/knock/)
126
+
107
127
 
108
128
  == Implemented assertions
109
129
 
@@ -132,6 +152,8 @@ It also supports TAP:
132
152
  before and after need to be defined before the first specification in
133
153
  a context and are run before and after each specification.
134
154
 
155
+ As of Bacon 1.1, before and after do nest in nested contexts.
156
+
135
157
 
136
158
  == Shared contexts
137
159
 
@@ -174,7 +196,9 @@ contexts.
174
196
  -s, --specdox do AgileDox-like output (default)
175
197
  -q, --quiet do Test::Unit-like non-verbose output
176
198
  -p, --tap do TAP (Test Anything Protocol) output
199
+ -k, --knock do Knock output
177
200
  -o, --output FORMAT do FORMAT (SpecDox/TestUnit/Tap) output
201
+ -Q, --no-backtrace don't print backtraces
178
202
  -a, --automatic gather tests from ./test/, include ./lib/
179
203
  -n, --name NAME runs tests matching regexp NAME
180
204
  -t, --testcase TESTCASE runs tests in TestCases matching regexp TESTCASE
@@ -215,7 +239,8 @@ It can be found at http://opensource.thinkrelevance.com/wiki/spec_converter.
215
239
 
216
240
  * Michael Fellinger, for fixing Bacon for 1.9 and various improvements.
217
241
  * Gabriele Renzi, for implementing Context#should.
218
- * James Tucker, for the autotest support
242
+ * James Tucker, for the autotest support.
243
+ * Yossef Mendelssohn, for nested contexts.
219
244
  * everyone contributing bug fixes.
220
245
 
221
246
 
@@ -231,14 +256,21 @@ It can be found at http://opensource.thinkrelevance.com/wiki/spec_converter.
231
256
  * Autotest support.
232
257
  * Bug fixes.
233
258
 
259
+ * November 30th, 2008: Third public release 1.1.
260
+ * Nested before/after.
261
+ * Add -Q/--no-backtraces to not show details about failed specifications.
262
+ * Add Knock output.
263
+ * Bug fixes.
264
+
234
265
 
235
266
  == Contact
236
267
 
237
268
  Please mail bugs, suggestions and patches to
238
269
  <mailto:chneukirchen@gmail.com>.
239
270
 
240
- Darcs repository ("darcs send" is welcome for patches):
241
- http://chneukirchen.org/repos/bacon
271
+ Git repository (patches rebased on HEAD are most welcome):
272
+ http://github.com/chneukirchen/bacon
273
+ git://github.com/chneukirchen/bacon.git
242
274
 
243
275
 
244
276
  == Copying
data/Rakefile CHANGED
@@ -11,43 +11,35 @@ task :predist => [:chmod, :changelog, :rdoc]
11
11
 
12
12
 
13
13
  desc "Make an archive as .tar.gz"
14
- task :dist => :test do
15
- sh "export DARCS_REPO=#{File.expand_path "."}; " +
16
- "darcs dist -d bacon-#{get_darcs_tree_version}"
14
+ task :dist => [:test, :predist] do
15
+ sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
16
+ sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX ChangeLog doc"
17
+ sh "gzip -f -9 #{release}.tar"
17
18
  end
18
19
 
19
- # Helper to retrieve the "revision number" of the darcs tree.
20
- def get_darcs_tree_version
21
- unless File.directory? "_darcs"
20
+ # Helper to retrieve the "revision number" of the git tree.
21
+ def git_tree_version
22
+ if File.directory?(".git")
23
+ @tree_version ||= `git describe`.strip.sub('-', '.')
24
+ @tree_version << ".0" unless @tree_version.count('.') == 2
25
+ else
22
26
  $: << "lib"
23
27
  require 'bacon'
24
- return Bacon::VERSION
28
+ @tree_version = Bacon::VERSION
25
29
  end
30
+ @tree_version
31
+ end
26
32
 
27
- changes = `darcs changes`
28
- count = 0
29
- tag = "0.0"
30
-
31
- changes.each("\n\n") { |change|
32
- head, title, desc = change.split("\n", 3)
33
-
34
- if title =~ /^ \*/
35
- # Normal change.
36
- count += 1
37
- elsif title =~ /tagged (.*)/
38
- # Tag. We look for these.
39
- tag = $1
40
- break
41
- else
42
- warn "Unparsable change: #{change}"
43
- end
44
- }
33
+ def gem_version
34
+ git_tree_version.gsub(/-.*/, '')
35
+ end
45
36
 
46
- tag + "." + count.to_s
37
+ def release
38
+ "bacon-#{git_tree_version}"
47
39
  end
48
40
 
49
41
  def manifest
50
- `darcs query manifest 2>/dev/null`.split("\n").map { |f| f.gsub(/\A\.\//, '') }
42
+ `git ls-files`.split("\n") - [".gitignore"]
51
43
  end
52
44
 
53
45
 
@@ -58,7 +50,20 @@ end
58
50
 
59
51
  desc "Generate a ChangeLog"
60
52
  task :changelog do
61
- sh "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
53
+ File.open("ChangeLog", "w") { |out|
54
+ `git log -z`.split("\0").map { |chunk|
55
+ author = chunk[/Author: (.*)/, 1].strip
56
+ date = chunk[/Date: (.*)/, 1].strip
57
+ desc, detail = $'.strip.split("\n", 2)
58
+ detail ||= ""
59
+ detail = detail.gsub(/.*darcs-hash:.*/, '')
60
+ detail.rstrip!
61
+ out.puts "#{date} #{author}"
62
+ out.puts " * #{desc.strip}"
63
+ out.puts detail unless detail.empty?
64
+ out.puts
65
+ }
66
+ }
62
67
  end
63
68
 
64
69
 
@@ -67,7 +72,7 @@ task "RDOX" do
67
72
  sh "bin/bacon -Ilib --automatic --specdox >RDOX"
68
73
  end
69
74
 
70
- desc "Run all the fast tests"
75
+ desc "Run all the tests"
71
76
  task :test do
72
77
  ruby "bin/bacon -Ilib --automatic --quiet"
73
78
  end
@@ -87,7 +92,7 @@ rescue LoadError
87
92
  else
88
93
  spec = Gem::Specification.new do |s|
89
94
  s.name = "bacon"
90
- s.version = get_darcs_tree_version
95
+ s.version = gem_version
91
96
  s.platform = Gem::Platform::RUBY
92
97
  s.summary = "a small RSpec clone"
93
98
 
@@ -95,10 +100,10 @@ else
95
100
  Bacon is a small RSpec clone weighing less than 350 LoC but
96
101
  nevertheless providing all essential features.
97
102
 
98
- http://chneukirchen.org/repos/bacon
103
+ http://github.com/chneukirchen/bacon
99
104
  EOF
100
105
 
101
- s.files = manifest + %w(RDOX)
106
+ s.files = manifest + %w(RDOX ChangeLog)
102
107
  s.bindir = 'bin'
103
108
  s.executables << 'bacon'
104
109
  s.require_path = 'lib'
data/bin/bacon CHANGED
@@ -49,11 +49,17 @@ opts = OptionParser.new("", 24, ' ') { |opts|
49
49
  opts.on("-p", "--tap", "do TAP (Test Anything Protocol) output") {
50
50
  output = 'TapOutput'
51
51
  }
52
+ opts.on("-k", "--knock", "do Knock output") {
53
+ output = 'KnockOutput'
54
+ }
52
55
 
53
56
  opts.on("-o", "--output FORMAT",
54
57
  "do FORMAT (SpecDox/TestUnit/Tap) output") { |format|
55
58
  output = format + "Output"
56
59
  }
60
+ opts.on("-Q", "--no-backtrace", "don't print backtraces") {
61
+ Bacon.const_set :Backtraces, false
62
+ }
57
63
 
58
64
  opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") {
59
65
  $LOAD_PATH.unshift "lib" if File.directory? "lib"
@@ -0,0 +1,2 @@
1
+ require File.dirname(__FILE__) + '/bacon.rb'
2
+ class Autotest::BaconRspec < Autotest::Bacon; end
@@ -8,7 +8,7 @@
8
8
  # See COPYING or http://www.opensource.org/licenses/mit-license.php.
9
9
 
10
10
  module Bacon
11
- VERSION = "1.0"
11
+ VERSION = "1.1"
12
12
 
13
13
  Counter = Hash.new(0)
14
14
  ErrorLog = ""
@@ -19,6 +19,8 @@ module Bacon
19
19
  RestrictName = // unless defined? RestrictName
20
20
  RestrictContext = // unless defined? RestrictContext
21
21
 
22
+ Backtraces = true unless defined? Backtraces
23
+
22
24
  def self.summary_on_exit
23
25
  return if Counter[:installed_summary] > 0
24
26
  at_exit {
@@ -31,6 +33,7 @@ module Bacon
31
33
  }
32
34
  Counter[:installed_summary] += 1
33
35
  end
36
+ class <<self; alias summary_at_exit summary_on_exit; end
34
37
 
35
38
  module SpecDoxOutput
36
39
  def handle_specification(name)
@@ -46,7 +49,7 @@ module Bacon
46
49
  end
47
50
 
48
51
  def handle_summary
49
- print ErrorLog
52
+ print ErrorLog if Backtraces
50
53
  puts "%d specifications (%d requirements), %d failures, %d errors" %
51
54
  Counter.values_at(:specifications, :requirements, :failed, :errors)
52
55
  end
@@ -65,7 +68,8 @@ module Bacon
65
68
  end
66
69
 
67
70
  def handle_summary
68
- puts "", ErrorLog
71
+ puts
72
+ puts ErrorLog if Backtraces
69
73
  puts "%d tests, %d assertions, %d failures, %d errors" %
70
74
  Counter.values_at(:specifications, :requirements, :failed, :errors)
71
75
  end
@@ -78,11 +82,11 @@ module Bacon
78
82
  ErrorLog.replace ""
79
83
  error = yield
80
84
  if error.empty?
81
- printf "ok %-3d - %s\n" % [Counter[:specifications], description]
85
+ puts "ok %-3d - %s" % [Counter[:specifications], description]
82
86
  else
83
- printf "not ok %d - %s: %s\n" %
87
+ puts "not ok %d - %s: %s" %
84
88
  [Counter[:specifications], description, error]
85
- puts ErrorLog.strip.gsub(/^/, '# ')
89
+ puts ErrorLog.strip.gsub(/^/, '# ') if Backtraces
86
90
  end
87
91
  end
88
92
 
@@ -93,6 +97,23 @@ module Bacon
93
97
  end
94
98
  end
95
99
 
100
+ module KnockOutput
101
+ def handle_specification(name) yield end
102
+
103
+ def handle_requirement(description)
104
+ ErrorLog.replace ""
105
+ error = yield
106
+ if error.empty?
107
+ puts "ok - %s" % [description]
108
+ else
109
+ puts "not ok - %s: %s" % [description, error]
110
+ puts ErrorLog.strip.gsub(/^/, '# ') if Backtraces
111
+ end
112
+ end
113
+
114
+ def handle_summary; end
115
+ end
116
+
96
117
  extend SpecDoxOutput # default
97
118
 
98
119
  class Error < RuntimeError
@@ -105,12 +126,18 @@ module Bacon
105
126
  end
106
127
 
107
128
  class Context
129
+ attr_reader :name, :block
130
+
108
131
  def initialize(name, &block)
109
132
  @name = name
110
133
  @before, @after = [], []
111
-
134
+ @block = block
135
+ end
136
+
137
+ def run
112
138
  return unless name =~ RestrictContext
113
139
  Bacon.handle_specification(name) { instance_eval(&block) }
140
+ self
114
141
  end
115
142
 
116
143
  def before(&block); @before << block; end
@@ -181,6 +208,13 @@ module Bacon
181
208
  end
182
209
  end
183
210
 
211
+ def describe(*args, &block)
212
+ context = Bacon::Context.new(args.join(' '), &block)
213
+ @before.each { |b| context.before(&b) }
214
+ @after.each { |b| context.after(&b) }
215
+ context.run
216
+ end
217
+
184
218
  def raise?(*args, &block); block.raise?(*args); end
185
219
  def throw?(*args, &block); block.throw?(*args); end
186
220
  def change?(*args, &block); block.change?(*args); end
@@ -242,13 +276,13 @@ end
242
276
 
243
277
 
244
278
  class Object
245
- def should(*args, &block) Should.new(self).be(*args, &block) end
279
+ def should(*args, &block) Should.new(self).be(*args, &block) end
246
280
  end
247
281
 
248
282
  module Kernel
249
283
  private
250
- def describe(*args, &block) Bacon::Context.new(args.join(' '), &block) end
251
- def shared(name, &block) Bacon::Shared[name] = block end
284
+ def describe(*args, &block) Bacon::Context.new(args.join(' '), &block).run end
285
+ def shared(name, &block) Bacon::Shared[name] = block end
252
286
  end
253
287
 
254
288
 
@@ -32,7 +32,7 @@ describe "Bacon" do
32
32
  lambda { should.satisfy { 1 == 1 } }.should succeed
33
33
  lambda { should.satisfy { 1 } }.should succeed
34
34
 
35
- lambda { should.satisfy { 1 == 2 } }.should fail
35
+ lambda { should.satisfy { 1 != 1 } }.should fail
36
36
  lambda { should.satisfy { false } }.should fail
37
37
  lambda { should.satisfy { false } }.should fail
38
38
 
@@ -278,6 +278,40 @@ describe "before/after" do
278
278
  @a.should.equal 2
279
279
  @b.should.equal 2
280
280
  end
281
+
282
+ describe "when nested" do
283
+ before do
284
+ @c = 5
285
+ end
286
+
287
+ it "should run from higher level" do
288
+ @a.should.equal 2
289
+ @b.should.equal 2
290
+ end
291
+
292
+ it "should run at the nested level" do
293
+ @c.should.equal 5
294
+ end
295
+
296
+ before do
297
+ @a = 5
298
+ end
299
+
300
+ it "should run in the right order" do
301
+ @a.should.equal 5
302
+ @a = 2
303
+ end
304
+ end
305
+
306
+ it "should not run from lower level" do
307
+ @c.should.be.nil
308
+ end
309
+
310
+ describe "when nested at a sibling level" do
311
+ it "should not run from sibling level" do
312
+ @c.should.be.nil
313
+ end
314
+ end
281
315
  end
282
316
 
283
317
  shared "a shared context" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bacon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neukirchen
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-06 00:00:00 +02:00
12
+ date: 2008-11-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. http://chneukirchen.org/repos/bacon
16
+ description: Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. http://github.com/chneukirchen/bacon
17
17
  email: chneukirchen@gmail.com
18
18
  executables:
19
19
  - bacon
@@ -23,16 +23,18 @@ extra_rdoc_files:
23
23
  - README
24
24
  - RDOX
25
25
  files:
26
- - bin/bacon
27
26
  - COPYING
27
+ - README
28
+ - Rakefile
29
+ - bin/bacon
28
30
  - lib/autotest/bacon.rb
31
+ - lib/autotest/bacon_rspec.rb
29
32
  - lib/autotest/discover.rb
30
33
  - lib/bacon.rb
31
- - Rakefile
32
- - README
33
34
  - test/spec_bacon.rb
34
35
  - test/spec_should.rb
35
36
  - RDOX
37
+ - ChangeLog
36
38
  has_rdoc: true
37
39
  homepage: http://chneukirchen.org/repos/bacon
38
40
  post_install_message:
@@ -55,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
57
  requirements: []
56
58
 
57
59
  rubyforge_project:
58
- rubygems_version: 1.0.1
60
+ rubygems_version: 1.3.1
59
61
  signing_key:
60
62
  specification_version: 2
61
63
  summary: a small RSpec clone