scampi 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +91 -0
- data/exe/scampi +1 -1
- data/lib/scampi/monkey_patches.rb +12 -0
- data/lib/scampi/version.rb +1 -1
- data/scampi.gemspec +1 -1
- metadata +3 -3
- data/README.rdoc +0 -290
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ab326398426699068726dee799fa312709c6d44bfffb607de4c467d0a52a2ad
|
|
4
|
+
data.tar.gz: e3937c018adbf534d156bffc262001cee773ac741abb5a0b7d950b075e125153
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 719acff10a6ca528087b0b5dde1b375e85c33c9c9aa16a1eab184cd26073f845d1c3a4a96c2dcdaf71d5480e74ccd8a8c7c3feeaed9bf908f7442d380bd15af9
|
|
7
|
+
data.tar.gz: 5a23a60fae7c9181bb425799ce76f5c9555739ad2748270ec3a1066fbed54ccdaf424f0aa100813eaa93cbab03a8ade669d8fbeb0ddb109dfcd95851ea4a5fee
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
scampi (0.1.
|
|
4
|
+
scampi (0.1.2)
|
|
5
5
|
colorize-extended
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -22,7 +22,7 @@ DEPENDENCIES
|
|
|
22
22
|
CHECKSUMS
|
|
23
23
|
colorize (1.1.0) sha256=30b5237f0603f6662ab8d1fc2bd4a96142b806c6415d79e45ef5fdc6a0cfc837
|
|
24
24
|
colorize-extended (0.1.0) sha256=e8c39986e41ee2e14623c8fa02cf851ef4b83d2fe1392daa2b4d81f0df7bedc9
|
|
25
|
-
scampi (0.1.
|
|
25
|
+
scampi (0.1.2)
|
|
26
26
|
|
|
27
27
|
BUNDLED WITH
|
|
28
28
|
4.0.7
|
data/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Scampi
|
|
2
|
+
|
|
3
|
+
A small Ruby test framework forked from [Bacon](https://github.com/chneukirchen/bacon) with built-in [TAP (Test Anything Protocol)](https://testanything.org/) output.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Tests can live alongside your code using the `test` block — it only runs when the file is executed directly or via `scampi`:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# greet.rb
|
|
11
|
+
def greet(name) = "hello #{name}"
|
|
12
|
+
|
|
13
|
+
test do
|
|
14
|
+
it "equality and matching" do
|
|
15
|
+
greet("world").should == "hello world"
|
|
16
|
+
greet("world").should.equal "hello world"
|
|
17
|
+
greet("world").should =~ /hello/
|
|
18
|
+
greet("world").should.match(/hello/)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "negation" do
|
|
22
|
+
greet("world").should.not == "goodbye"
|
|
23
|
+
greet("world").should.not.match(/goodbye/)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "predicates" do
|
|
27
|
+
[].should.be.empty
|
|
28
|
+
nil.should.be.nil
|
|
29
|
+
true.should.be.true
|
|
30
|
+
false.should.be.false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "type checks" do
|
|
34
|
+
"hello".should.be.kind_of String
|
|
35
|
+
"hello".should.be.instance_of String
|
|
36
|
+
"hello".should.respond_to :upcase
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "identity" do
|
|
40
|
+
s = "hello"
|
|
41
|
+
s.should.be.identical_to s
|
|
42
|
+
s.should.be.same_as s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "comparisons" do
|
|
46
|
+
5.should.be > 3
|
|
47
|
+
5.should.be >= 5
|
|
48
|
+
3.should.be < 5
|
|
49
|
+
5.should.be <= 5
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "collections" do
|
|
53
|
+
[1, 2, 3].should.include 2
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "numeric closeness" do
|
|
57
|
+
3.14.should.be.close 3.1, 0.05
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "custom matchers" do
|
|
61
|
+
palindrome = lambda { |obj| obj == obj.reverse }
|
|
62
|
+
"racecar".should.be.a palindrome
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "satisfy" do
|
|
66
|
+
10.should.satisfy { |n| n.even? }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "exceptions and flow" do
|
|
70
|
+
it "raises" do
|
|
71
|
+
lambda { raise "boom" }.should.raise
|
|
72
|
+
lambda { raise "boom" }.should.raise(RuntimeError)
|
|
73
|
+
lambda { 1 + 1 }.should.not.raise
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "throws" do
|
|
77
|
+
lambda { throw :halt }.should.throw(:halt)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "detects change" do
|
|
81
|
+
i = 0
|
|
82
|
+
lambda { i += 1 }.should.change { i }
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
$ ruby greet.rb
|
|
90
|
+
$ scampi greet.rb
|
|
91
|
+
```
|
data/exe/scampi
CHANGED
|
@@ -58,4 +58,16 @@ module Kernel
|
|
|
58
58
|
def shared(name, &block)
|
|
59
59
|
Scampi::Shared[name] = block
|
|
60
60
|
end
|
|
61
|
+
|
|
62
|
+
# Allow `it` at the top level (outside a describe block).
|
|
63
|
+
# Wraps the spec in an anonymous context derived from the caller's filename.
|
|
64
|
+
def it(description, &block)
|
|
65
|
+
loc = caller_locations(1, 1).first
|
|
66
|
+
file = loc.path || loc.absolute_path || "(unknown)"
|
|
67
|
+
ctx_name = File.basename(file, File.extname(file))
|
|
68
|
+
ctx = Scampi::Context.new(ctx_name) {}
|
|
69
|
+
ctx.it(description, &block)
|
|
70
|
+
ctx.register
|
|
71
|
+
Scampi.queue << ctx
|
|
72
|
+
end
|
|
61
73
|
end
|
data/lib/scampi/version.rb
CHANGED
data/scampi.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ http://github.com/general-intelligence-systems/scampi
|
|
|
19
19
|
s.bindir = 'exe'
|
|
20
20
|
s.executables = ['scampi']
|
|
21
21
|
s.require_path = 'lib'
|
|
22
|
-
s.extra_rdoc_files = ['README.
|
|
22
|
+
s.extra_rdoc_files = ['README.md']
|
|
23
23
|
s.test_files = []
|
|
24
24
|
|
|
25
25
|
s.add_dependency 'colorize-extended'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scampi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan K
|
|
@@ -34,13 +34,13 @@ executables:
|
|
|
34
34
|
- scampi
|
|
35
35
|
extensions: []
|
|
36
36
|
extra_rdoc_files:
|
|
37
|
-
- README.
|
|
37
|
+
- README.md
|
|
38
38
|
files:
|
|
39
39
|
- ".envrc"
|
|
40
40
|
- COPYING
|
|
41
41
|
- Gemfile
|
|
42
42
|
- Gemfile.lock
|
|
43
|
-
- README.
|
|
43
|
+
- README.md
|
|
44
44
|
- Rakefile
|
|
45
45
|
- bin/increment-version
|
|
46
46
|
- bin/release-gem
|
data/README.rdoc
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 included with scampi)
|
|
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
|
-
== Converting specs
|
|
224
|
-
|
|
225
|
-
spec-converter is a simple tool to convert test-unit or dust style
|
|
226
|
-
tests to test/spec specs.
|
|
227
|
-
|
|
228
|
-
It can be found at https://github.com/relevance/spec_converter.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
== Thanks to
|
|
232
|
-
|
|
233
|
-
* Michael Fellinger, for fixing Bacon for 1.9 and various improvements.
|
|
234
|
-
* Gabriele Renzi, for implementing Context#should.
|
|
235
|
-
* Yossef Mendelssohn, for nested contexts.
|
|
236
|
-
* everyone contributing bug fixes.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
== History
|
|
240
|
-
|
|
241
|
-
* January 7, 2008: First public release 0.9.
|
|
242
|
-
|
|
243
|
-
* July 6th, 2008: Second public release 1.0.
|
|
244
|
-
* Add Context#should as a shortcut for Context#it('should ' + _).
|
|
245
|
-
* describe now supports multiple arguments for better organization.
|
|
246
|
-
* Empty specifications are now erroneous.
|
|
247
|
-
* after-blocks run in the case of exceptions too.
|
|
248
|
-
* Bug fixes.
|
|
249
|
-
|
|
250
|
-
* November 30th, 2008: Third public release 1.1.
|
|
251
|
-
* Nested before/after.
|
|
252
|
-
* Add -Q/--no-backtraces to not show details about failed specifications.
|
|
253
|
-
* Add Knock output.
|
|
254
|
-
* Bug fixes.
|
|
255
|
-
|
|
256
|
-
* December 21th, 2012: Fourth public release 1.2.0.
|
|
257
|
-
* #satisfy will not pass arguments anymore to the block, use lexical scope.
|
|
258
|
-
* Fixed Context#change?.
|
|
259
|
-
* Add support for finding specs named like spec/**/*_spec.rb.
|
|
260
|
-
* Contexts nest properly.
|
|
261
|
-
* Timer in TestUnitOutput.
|
|
262
|
-
* Nested output for SpecDoxOutput.
|
|
263
|
-
* Small cleanups and more tests.
|
|
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, 2012 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/>
|