schmurfy-bacon 1.3.3 → 1.3.4
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.md +56 -0
- data/bacon.gemspec +0 -1
- data/bin/bacon +1 -1
- data/lib/bacon.rb +2 -2
- data/lib/bacon/ext/mocha.rb +11 -0
- data/lib/bacon/version.rb +1 -1
- data/lib/output/better_output.rb +14 -1
- data/lib/output/knock_output.rb +1 -1
- data/lib/output/spec_dox_output.rb +1 -1
- data/lib/output/tap_output.rb +1 -1
- data/lib/output/test_unit_output.rb +1 -1
- data/screenshot.png +0 -0
- metadata +9 -9
- data/README +0 -290
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Bacon
|
2
|
+
|
3
|
+
This is my personal fork of the [bacon test](https://github.com/chneukirchen/bacon) framework tailored to my needs, here is
|
4
|
+
a non exhaustive list of changes worth mentioning:
|
5
|
+
|
6
|
+
- added a new default nicer output formatter, I look at tests most of my work days
|
7
|
+
and got tired of the old standard look.
|
8
|
+
- added some optional extensions:
|
9
|
+
- mocha integration: allow using mocha expectations
|
10
|
+
- eventmachine integration: make your tests run inside the eventmachine loop
|
11
|
+
|
12
|
+
# Using it
|
13
|
+
|
14
|
+
In your project add this to your Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "schmurfy-bacon"
|
18
|
+
```
|
19
|
+
|
20
|
+
And then the simplest test would be:
|
21
|
+
(you might want to split the common part to a spec_helper.rb file and requires it in your tests)
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
require "bacon"
|
27
|
+
|
28
|
+
# Without that nothing will be shown after the tests
|
29
|
+
Bacon.summary_on_exit()
|
30
|
+
|
31
|
+
# Using mocha
|
32
|
+
# require "bacon/ext/mocha"
|
33
|
+
|
34
|
+
# Using eventmachine
|
35
|
+
# require "bacon/ext/em"
|
36
|
+
|
37
|
+
describe "My test" do
|
38
|
+
before do
|
39
|
+
@v = 42
|
40
|
+
end
|
41
|
+
|
42
|
+
should "run" do
|
43
|
+
@v.should == 42
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
Check the examples directory for more.
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
# Screenshot
|
54
|
+
|
55
|
+

|
56
|
+
|
data/bacon.gemspec
CHANGED
data/bin/bacon
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/')
|
|
6
6
|
module Bacon; end
|
7
7
|
|
8
8
|
automatic = false
|
9
|
-
output = '
|
9
|
+
output = 'BetterOutput'
|
10
10
|
|
11
11
|
opts = OptionParser.new("", 24, ' ') { |opts|
|
12
12
|
opts.banner = "Usage: bacon [options] [files | -a] [-- untouched arguments]"
|
data/lib/bacon.rb
CHANGED
@@ -59,9 +59,9 @@ module Bacon
|
|
59
59
|
|
60
60
|
def self.summary_on_exit
|
61
61
|
return if Counter[:installed_summary] > 0
|
62
|
-
|
62
|
+
started_at = Time.now
|
63
63
|
at_exit {
|
64
|
-
handle_summary
|
64
|
+
handle_summary(started_at)
|
65
65
|
if $!
|
66
66
|
raise $!
|
67
67
|
elsif Counter[:errors] + Counter[:failed] > 0
|
data/lib/bacon/ext/mocha.rb
CHANGED
@@ -7,6 +7,17 @@ require 'mocha'
|
|
7
7
|
# containing only mocha expectations.
|
8
8
|
#
|
9
9
|
module Bacon
|
10
|
+
class Context
|
11
|
+
def freeze_time(t = Time.now)
|
12
|
+
Time.stubs(:now).returns(t)
|
13
|
+
if block_given?
|
14
|
+
yield
|
15
|
+
Time.unstub(:now)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
10
21
|
module MochaRequirementsCounter
|
11
22
|
def self.increment
|
12
23
|
Counter[:requirements] += 1
|
data/lib/bacon/version.rb
CHANGED
data/lib/output/better_output.rb
CHANGED
@@ -32,8 +32,10 @@ module BetterOutput
|
|
32
32
|
|
33
33
|
end
|
34
34
|
|
35
|
-
def handle_summary
|
35
|
+
def handle_summary(started_at)
|
36
|
+
elapsed_time = Time.now.to_i - started_at.to_i
|
36
37
|
print ErrorLog if Backtraces
|
38
|
+
puts "Execution time: #{human_duration(elapsed_time)}"
|
37
39
|
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
38
40
|
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
39
41
|
end
|
@@ -41,4 +43,15 @@ module BetterOutput
|
|
41
43
|
def spaces(str = " ")
|
42
44
|
str * 2 * (Counter[:context_depth] - 1)
|
43
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def human_duration(secs)
|
50
|
+
[[60, 'seconds'], [60, 'minutes'], [24, 'hours'], [1000, 'days']].map do |count, name|
|
51
|
+
if secs > 0
|
52
|
+
secs, n = secs.divmod(count)
|
53
|
+
(n > 0) ? "#{n.to_i} #{name}" : nil
|
54
|
+
end
|
55
|
+
end.compact.reverse.join(' ')
|
56
|
+
end
|
44
57
|
end
|
data/lib/output/knock_output.rb
CHANGED
@@ -11,7 +11,7 @@ module SpecDoxOutput
|
|
11
11
|
puts error.empty? ? "" : " [#{error}]"
|
12
12
|
end
|
13
13
|
|
14
|
-
def handle_summary
|
14
|
+
def handle_summary(started_at)
|
15
15
|
print ErrorLog if Backtraces
|
16
16
|
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
17
17
|
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
data/lib/output/tap_output.rb
CHANGED
@@ -13,7 +13,7 @@ module TapOutput
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def handle_summary
|
16
|
+
def handle_summary(started_at)
|
17
17
|
puts "1..#{Counter[:specifications]}"
|
18
18
|
puts "# %d tests, %d assertions, %d failures, %d errors" %
|
19
19
|
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
data/screenshot.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schmurfy-bacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70328114246540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70328114246540
|
25
25
|
description: ! 'Bacon is a small RSpec clone weighing less than 350 LoC but
|
26
26
|
|
27
27
|
nevertheless providing all essential features.
|
@@ -34,13 +34,12 @@ email: chneukirchen@gmail.com
|
|
34
34
|
executables:
|
35
35
|
- bacon
|
36
36
|
extensions: []
|
37
|
-
extra_rdoc_files:
|
38
|
-
- README
|
37
|
+
extra_rdoc_files: []
|
39
38
|
files:
|
40
39
|
- .gitignore
|
41
40
|
- COPYING
|
42
41
|
- Gemfile
|
43
|
-
- README
|
42
|
+
- README.md
|
44
43
|
- Rakefile
|
45
44
|
- bacon.gemspec
|
46
45
|
- bin/bacon
|
@@ -60,6 +59,7 @@ files:
|
|
60
59
|
- lib/output/spec_dox_output.rb
|
61
60
|
- lib/output/tap_output.rb
|
62
61
|
- lib/output/test_unit_output.rb
|
62
|
+
- screenshot.png
|
63
63
|
- test/spec_bacon.rb
|
64
64
|
- test/spec_nontrue.rb
|
65
65
|
- test/spec_should.rb
|
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
segments:
|
79
79
|
- 0
|
80
|
-
hash:
|
80
|
+
hash: -3752377546693975737
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
segments:
|
88
88
|
- 0
|
89
|
-
hash:
|
89
|
+
hash: -3752377546693975737
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
92
|
rubygems_version: 1.8.11
|
data/README
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
= Bacon -- small RSpec clone.
|
2
|
-
|
3
|
-
"Truth will sooner come out from error than from confusion."
|
4
|
-
---Francis Bacon
|
5
|
-
|
6
|
-
Bacon is a small RSpec clone weighing less than 350 LoC but
|
7
|
-
nevertheless providing all essential features.
|
8
|
-
|
9
|
-
|
10
|
-
== Whirl-wind tour
|
11
|
-
|
12
|
-
require 'bacon'
|
13
|
-
|
14
|
-
describe 'A new array' do
|
15
|
-
before do
|
16
|
-
@ary = Array.new
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should be empty' do
|
20
|
-
@ary.should.be.empty
|
21
|
-
@ary.should.not.include 1
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should have zero size' do
|
25
|
-
@ary.size.should.equal 0
|
26
|
-
@ary.size.should.be.close 0.1, 0.5
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should raise on trying fetch any index' do
|
30
|
-
lambda { @ary.fetch 0 }.
|
31
|
-
should.raise(IndexError).
|
32
|
-
message.should.match(/out of array/)
|
33
|
-
|
34
|
-
# Alternatively:
|
35
|
-
should.raise(IndexError) { @ary.fetch 0 }
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should have an object identity' do
|
39
|
-
@ary.should.not.be.same_as Array.new
|
40
|
-
end
|
41
|
-
|
42
|
-
# Custom assertions are trivial to do, they are lambdas returning a
|
43
|
-
# boolean vale:
|
44
|
-
palindrome = lambda { |obj| obj == obj.reverse }
|
45
|
-
it 'should be a palindrome' do
|
46
|
-
@ary.should.be.a palindrome
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should have super powers' do
|
50
|
-
should.flunk "no super powers found"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Now run it:
|
55
|
-
|
56
|
-
$ bacon whirlwind.rb
|
57
|
-
A new array
|
58
|
-
- should be empty
|
59
|
-
- should have zero size
|
60
|
-
- should raise on trying fetch any index
|
61
|
-
- should have an object identity
|
62
|
-
- should be a palindrome
|
63
|
-
- should have super powers [FAILED]
|
64
|
-
|
65
|
-
Bacon::Error: no super powers found
|
66
|
-
./whirlwind.rb:39: A new array - should have super powers
|
67
|
-
./whirlwind.rb:38
|
68
|
-
./whirlwind.rb:3
|
69
|
-
|
70
|
-
6 specifications (9 requirements), 1 failures, 0 errors
|
71
|
-
|
72
|
-
If you want shorter output, use the Test::Unit format:
|
73
|
-
|
74
|
-
$ bacon -q whirlwind.rb
|
75
|
-
.....F
|
76
|
-
Bacon::Error: no super powers found
|
77
|
-
./whirlwind.rb:39: A new array - should have super powers
|
78
|
-
./whirlwind.rb:38
|
79
|
-
./whirlwind.rb:3
|
80
|
-
|
81
|
-
6 tests, 9 assertions, 1 failures, 0 errors
|
82
|
-
|
83
|
-
It also supports TAP:
|
84
|
-
|
85
|
-
$ bacon -p whirlwind.rb
|
86
|
-
ok 1 - should be empty
|
87
|
-
ok 2 - should have zero size
|
88
|
-
ok 3 - should raise on trying fetch any index
|
89
|
-
ok 4 - should have an object identity
|
90
|
-
ok 5 - should be a palindrome
|
91
|
-
not ok 6 - should have super powers: FAILED
|
92
|
-
# Bacon::Error: no super powers found
|
93
|
-
# ./whirlwind.rb:39: A new array - should have super powers
|
94
|
-
# ./whirlwind.rb:38
|
95
|
-
# ./whirlwind.rb:3
|
96
|
-
1..6
|
97
|
-
# 6 tests, 9 assertions, 1 failures, 0 errors
|
98
|
-
|
99
|
-
$ bacon -p whirlwind.rb | taptap -q
|
100
|
-
Tests took 0.00 seconds.
|
101
|
-
FAILED tests 6
|
102
|
-
6) should have super powers: FAILED
|
103
|
-
|
104
|
-
Failed 1/6 tests, 83.33% okay.
|
105
|
-
|
106
|
-
(taptap is available from http://chneukirchen.org/repos/taptap/)
|
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
|
-
|
127
|
-
|
128
|
-
== Implemented assertions
|
129
|
-
|
130
|
-
* should.<predicate> and should.be.<predicate>
|
131
|
-
* should.equal
|
132
|
-
* should.match
|
133
|
-
* should.be.identical_to / should.be.same_as
|
134
|
-
* should.raise(*exceptions) { }
|
135
|
-
* should.change { }
|
136
|
-
* should.throw(symbol) { }
|
137
|
-
* should.satisfy { |object| }
|
138
|
-
|
139
|
-
|
140
|
-
== Added core predicates
|
141
|
-
|
142
|
-
* Object#true?
|
143
|
-
* Object#false?
|
144
|
-
* Proc#change?
|
145
|
-
* Proc#raise?
|
146
|
-
* Proc#throw?
|
147
|
-
* Numeric#close?
|
148
|
-
|
149
|
-
|
150
|
-
== before/after
|
151
|
-
|
152
|
-
before and after need to be defined before the first specification in
|
153
|
-
a context and are run before and after each specification.
|
154
|
-
|
155
|
-
As of Bacon 1.1, before and after do nest in nested contexts.
|
156
|
-
|
157
|
-
|
158
|
-
== Shared contexts
|
159
|
-
|
160
|
-
You can define shared contexts in Bacon like this:
|
161
|
-
|
162
|
-
shared "an empty container" do
|
163
|
-
it "should have size zero" do
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should be empty" do
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context "A new array" do
|
171
|
-
behaves_like "an empty container"
|
172
|
-
end
|
173
|
-
|
174
|
-
These contexts are not executed on their own, but can be included with
|
175
|
-
behaves_like in other contexts. You can use shared contexts to
|
176
|
-
structure suites with many recurring specifications.
|
177
|
-
|
178
|
-
|
179
|
-
== Matchers
|
180
|
-
|
181
|
-
Custom matchers are simply lambdas returning a boolean value, for
|
182
|
-
example:
|
183
|
-
|
184
|
-
def shorter_than(max_size)
|
185
|
-
lambda { |obj| obj.size < max_size }
|
186
|
-
end
|
187
|
-
|
188
|
-
[1,2,3].should.be shorter_than(5)
|
189
|
-
|
190
|
-
You can use modules and extend to group matchers for use in multiple
|
191
|
-
contexts.
|
192
|
-
|
193
|
-
|
194
|
-
== bacon standalone runner
|
195
|
-
|
196
|
-
-s, --specdox do AgileDox-like output (default)
|
197
|
-
-q, --quiet do Test::Unit-like non-verbose output
|
198
|
-
-p, --tap do TAP (Test Anything Protocol) output
|
199
|
-
-k, --knock do Knock output
|
200
|
-
-o, --output FORMAT do FORMAT (SpecDox/TestUnit/Tap) output
|
201
|
-
-Q, --no-backtrace don't print backtraces
|
202
|
-
-a, --automatic gather tests from ./test/, include ./lib/
|
203
|
-
-n, --name NAME runs tests matching regexp NAME
|
204
|
-
-t, --testcase TESTCASE runs tests in TestCases matching regexp TESTCASE
|
205
|
-
|
206
|
-
If you don't want to use the standalone runner, run
|
207
|
-
Bacon.summary_on_exit to install an exit handler showing the summary.
|
208
|
-
|
209
|
-
|
210
|
-
== Object#should
|
211
|
-
|
212
|
-
You can use Object#should outside of contexts, where the result of
|
213
|
-
assertion will be returned as a boolean. This is nice for
|
214
|
-
demonstrations, quick checks and doctest tests.
|
215
|
-
|
216
|
-
>> require 'bacon'
|
217
|
-
>> (1 + 1).should.equal 2
|
218
|
-
=> true
|
219
|
-
>> (6*9).should.equal 42
|
220
|
-
=> false
|
221
|
-
|
222
|
-
|
223
|
-
== Bacon with autotest
|
224
|
-
|
225
|
-
Since version 1.0, there is autotest support. You need to tag your
|
226
|
-
test directories (test/ or spec/) by creating an .bacon file there.
|
227
|
-
Autotest then will find it. bin/bacon needs to be in PATH or RUBYPATH.
|
228
|
-
|
229
|
-
|
230
|
-
== Converting specs
|
231
|
-
|
232
|
-
spec-converter is a simple tool to convert test-unit or dust style
|
233
|
-
tests to test/spec specs.
|
234
|
-
|
235
|
-
It can be found at http://opensource.thinkrelevance.com/wiki/spec_converter.
|
236
|
-
|
237
|
-
|
238
|
-
== Thanks to
|
239
|
-
|
240
|
-
* Michael Fellinger, for fixing Bacon for 1.9 and various improvements.
|
241
|
-
* Gabriele Renzi, for implementing Context#should.
|
242
|
-
* James Tucker, for the autotest support.
|
243
|
-
* Yossef Mendelssohn, for nested contexts.
|
244
|
-
* everyone contributing bug fixes.
|
245
|
-
|
246
|
-
|
247
|
-
== History
|
248
|
-
|
249
|
-
* January 7, 2008: First public release 0.9.
|
250
|
-
|
251
|
-
* July 6th, 2008: Second public release 1.0.
|
252
|
-
* Add Context#should as a shortcut for Context#it('should ' + _).
|
253
|
-
* describe now supports multiple arguments for better organization.
|
254
|
-
* Empty specifications are now erroneous.
|
255
|
-
* after-blocks run in the case of exceptions too.
|
256
|
-
* Autotest support.
|
257
|
-
* Bug fixes.
|
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
|
-
|
265
|
-
|
266
|
-
== Contact
|
267
|
-
|
268
|
-
Please mail bugs, suggestions and patches to
|
269
|
-
<mailto:chneukirchen@gmail.com>.
|
270
|
-
|
271
|
-
Git repository (patches rebased on HEAD are most welcome):
|
272
|
-
http://github.com/chneukirchen/bacon
|
273
|
-
git://github.com/chneukirchen/bacon.git
|
274
|
-
|
275
|
-
|
276
|
-
== Copying
|
277
|
-
|
278
|
-
Copyright (C) 2007, 2008 Christian Neukirchen <purl.org/net/chneukirchen>
|
279
|
-
|
280
|
-
Bacon is freely distributable under the terms of an MIT-style license.
|
281
|
-
See COPYING or http://www.opensource.org/licenses/mit-license.php.
|
282
|
-
|
283
|
-
|
284
|
-
== Links
|
285
|
-
|
286
|
-
Behavior-Driven Development:: <http://behaviour-driven.org/>
|
287
|
-
RSpec:: <http://rspec.rubyforge.org/>
|
288
|
-
test/spec:: <http://test-spec.rubyforge.org/>
|
289
|
-
|
290
|
-
Christian Neukirchen:: <http://chneukirchen.org/>
|