baretest 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MANIFEST.txt +38 -0
- data/README.markdown +229 -0
- data/bin/baretest +102 -0
- data/examples/test.rake +37 -0
- data/examples/test.rb +93 -0
- data/lib/test/assertion/failure.rb +14 -0
- data/lib/test/assertion/support.rb +268 -0
- data/lib/test/assertion.rb +117 -0
- data/lib/test/debug.rb +34 -0
- data/lib/test/irb_mode.rb +104 -0
- data/lib/test/run/cli.rb +79 -0
- data/lib/test/run/errors.rb +42 -0
- data/lib/test/run/interactive.rb +60 -0
- data/lib/test/run/minimal.rb +31 -0
- data/lib/test/run/spec.rb +32 -0
- data/lib/test/run/tap.rb +32 -0
- data/lib/test/run/xml.rb +56 -0
- data/lib/test/run.rb +137 -0
- data/lib/test/suite.rb +95 -0
- data/lib/test/version.rb +19 -0
- data/lib/test.rb +118 -0
- data/test/external/bootstraptest.rb +5 -0
- data/test/external/bootstrapwrap.rb +2 -0
- data/test/helper/mocks.rb +0 -0
- data/test/lib/test/assertion/support.rb +240 -0
- data/test/lib/test/assertion.rb +142 -0
- data/test/lib/test/debug.rb +63 -0
- data/test/lib/test/irb_mode.rb +10 -0
- data/test/lib/test/run/cli.rb +9 -0
- data/test/lib/test/run/errors.rb +9 -0
- data/test/lib/test/run/interactive.rb +9 -0
- data/test/lib/test/run/spec.rb +9 -0
- data/test/lib/test/run/tap.rb +9 -0
- data/test/lib/test/run/xml.rb +9 -0
- data/test/lib/test/run.rb +235 -0
- data/test/lib/test/suite.rb +275 -0
- data/test/lib/test.rb +227 -0
- data/test/setup.rb +2 -0
- metadata +99 -0
data/test/lib/test.rb
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2009 by Stefan Rusterholz.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Test.define "Test" do
|
10
|
+
suite "::extender" do
|
11
|
+
assert "Should return an Array" do
|
12
|
+
kind_of(Array, Test.extender)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
suite "::format" do
|
17
|
+
assert "Should return a Hash" do
|
18
|
+
kind_of(Hash, Test.format)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
suite "::toplevel_suite" do
|
23
|
+
assert "Should return an instance of Test::Suite" do
|
24
|
+
kind_of(::Test::Suite, ::Test.toplevel_suite)
|
25
|
+
end
|
26
|
+
|
27
|
+
assert "Should be used by Test::define" do
|
28
|
+
test = ::Test.clone # avoid interfering with the current run
|
29
|
+
test.init
|
30
|
+
suites_before = test.toplevel_suite.suites.size
|
31
|
+
test.define "A new suite" do end
|
32
|
+
suites_after = test.toplevel_suite.suites.size
|
33
|
+
|
34
|
+
equal(suites_before+1, suites_after)
|
35
|
+
end
|
36
|
+
|
37
|
+
assert "Should be used by Test::run_if_mainfile" do
|
38
|
+
test = ::Test.clone # avoid interfering with the current run
|
39
|
+
test.init
|
40
|
+
suites_before = test.toplevel_suite.suites.size
|
41
|
+
test.run_if_mainfile "A new suite" do end
|
42
|
+
suites_after = test.toplevel_suite.suites.size
|
43
|
+
|
44
|
+
equal(suites_before+1, suites_after)
|
45
|
+
end
|
46
|
+
|
47
|
+
assert "Should be run by Test::run" do
|
48
|
+
this = self # needed because touch is called in the block of another assertion, so otherwise it'd be local to that assertion
|
49
|
+
test = ::Test.clone # avoid interfering with the current run
|
50
|
+
test.init
|
51
|
+
test.define "A new suite" do assert do this.touch(:assertion_executed) end end
|
52
|
+
test.run
|
53
|
+
|
54
|
+
touched(:assertion_executed)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
suite "::define" do
|
59
|
+
assert "Should add the contained suites and asserts to Test::toplevel_suite" do
|
60
|
+
test = ::Test.clone # avoid interfering with the current run
|
61
|
+
test.init
|
62
|
+
suites_before = test.toplevel_suite.suites.size
|
63
|
+
test.define "A new suite" do end
|
64
|
+
suites_after = test.toplevel_suite.suites.size
|
65
|
+
|
66
|
+
equal(suites_before+1, suites_after)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
suite "::run_if_mainfile", :requires => ['rbconfig', 'shellwords'] do
|
71
|
+
setup do
|
72
|
+
ENV['FORMAT'] = 'minimal'
|
73
|
+
@ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
74
|
+
@test_path = Shellwords.escape(File.expand_path("#{__FILE__}/../../external/bootstraptest.rb"))
|
75
|
+
@wrap_path = Shellwords.escape(File.expand_path("#{__FILE__}/../../external/bootstrapwrap.rb"))
|
76
|
+
@inc_path = Shellwords.escape(File.dirname(Test.required_file))
|
77
|
+
end
|
78
|
+
|
79
|
+
suite "File is the program" do
|
80
|
+
assert "Should run the suite" do
|
81
|
+
IO.popen("#{@ruby} -I#{@inc_path} -rtest #{@test_path}") { |sio|
|
82
|
+
sio.read
|
83
|
+
} =~ /\ATests: 1\nSuccess: 1\nPending: 0\nFailures: 0\nErrors: 0\nTime: [^\n]+\nStatus: success\n\z/
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
suite "File is not the program" do
|
88
|
+
assert "Should not run the suite if the file is not the program" do
|
89
|
+
IO.popen("#{@ruby} -I#{@inc_path} -rtest #{@wrap_path}") { |sio|
|
90
|
+
sio.read
|
91
|
+
} =~ /\ADone\n\z/
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
suite "::run" do
|
97
|
+
assert "Should run Test's toplevel suite" do
|
98
|
+
this = self # needed because touch is called in the block of another assertion, so otherwise it'd be local to that assertion
|
99
|
+
test = ::Test.clone # avoid interfering with the current run
|
100
|
+
test.init
|
101
|
+
test.define "A new suite" do assert do this.touch(:assertion_executed) end end
|
102
|
+
test.run
|
103
|
+
|
104
|
+
touched(:assertion_executed)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
suite "Skipped" do
|
109
|
+
suite "Suite" do
|
110
|
+
setup do
|
111
|
+
parent = ::Test::Suite.new
|
112
|
+
parent.setup do end
|
113
|
+
parent.teardown do end
|
114
|
+
@suite = ::Test::Skipped::Suite.new("None", parent)
|
115
|
+
@suite.setup do end
|
116
|
+
@suite.teardown do end
|
117
|
+
end
|
118
|
+
|
119
|
+
suite "#ancestry_setup" do
|
120
|
+
assert "Should always be an empty array." do
|
121
|
+
equal([], @suite.ancestry_setup)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
suite "#setup" do
|
126
|
+
assert "Should always be an empty array." do
|
127
|
+
equal([], @suite.setup)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
suite "#ancestry_teardown" do
|
132
|
+
assert "Should always be an empty array." do
|
133
|
+
equal([], @suite.ancestry_teardown)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
suite "#teardown" do
|
138
|
+
assert "Should always be an empty array." do
|
139
|
+
equal([], @suite.teardown)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
suite "#assert" do
|
144
|
+
assert "Should add new skipped assertions to a suite." do
|
145
|
+
equal(
|
146
|
+
:expected => 0,
|
147
|
+
:actual => @suite.tests.size,
|
148
|
+
:message => "number of defined tests before adding any"
|
149
|
+
)
|
150
|
+
|
151
|
+
@suite.assert "a"
|
152
|
+
equal(
|
153
|
+
:expected => 1,
|
154
|
+
:actual => @suite.tests.size,
|
155
|
+
:message => "number of defined tests after adding one"
|
156
|
+
)
|
157
|
+
|
158
|
+
@suite.assert "b"
|
159
|
+
equal(
|
160
|
+
:expected => 2,
|
161
|
+
:actual => @suite.tests.size,
|
162
|
+
:message => "number of defined tests after adding two"
|
163
|
+
)
|
164
|
+
|
165
|
+
equal_unordered(
|
166
|
+
:expected => ['a', 'b'],
|
167
|
+
:actual => @suite.tests.map { |child| child.description },
|
168
|
+
:message => "the descriptions"
|
169
|
+
)
|
170
|
+
|
171
|
+
@suite.tests.all? { |test| kind_of(::Test::Skipped::Assertion, test) }
|
172
|
+
end
|
173
|
+
|
174
|
+
assert "Added tests should have the receiving suite as suite." do
|
175
|
+
@suite.assert "a"
|
176
|
+
assertion = @suite.tests.first
|
177
|
+
|
178
|
+
same(
|
179
|
+
:expected => @suite,
|
180
|
+
:actual => assertion.suite,
|
181
|
+
:message => "the suite"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
suite "Assertion" do
|
188
|
+
suite "#execute" do
|
189
|
+
suite "Given a test that succeeds" do
|
190
|
+
assert "Should have status :skipped" do
|
191
|
+
assertion = ::Test::Skipped::Assertion.new(nil, "") do true end
|
192
|
+
assertion.execute
|
193
|
+
|
194
|
+
equal(:skipped, assertion.status)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
suite "Given a test that is pending" do
|
199
|
+
assert "Should have status :skipped" do
|
200
|
+
assertion = ::Test::Skipped::Assertion.new(nil, "")
|
201
|
+
assertion.execute
|
202
|
+
|
203
|
+
equal(:skipped, assertion.status)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
suite "Given a test that fails" do
|
208
|
+
assert "Should have status :skipped" do
|
209
|
+
assertion = ::Test::Skipped::Assertion.new(nil, "") do false end
|
210
|
+
assertion.execute
|
211
|
+
|
212
|
+
equal(:skipped, assertion.status)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
suite "Given a test that errors" do
|
217
|
+
assert "Should have status :skipped" do
|
218
|
+
assertion = ::Test::Skipped::Assertion.new(nil, "") do raise end
|
219
|
+
assertion.execute
|
220
|
+
|
221
|
+
equal(:skipped, assertion.status)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
data/test/setup.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: baretest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Rusterholz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-16 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "Baretest is a Testframework that tries to stay out of your way, but support you when you want it. In order to do so it has a load of features:"
|
17
|
+
email: stefan.rusterholz@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- MANIFEST.txt
|
26
|
+
- README.markdown
|
27
|
+
- bin/baretest
|
28
|
+
- examples/test.rake
|
29
|
+
- examples/test.rb
|
30
|
+
- lib/test.rb
|
31
|
+
- lib/test/assertion.rb
|
32
|
+
- lib/test/assertion/failure.rb
|
33
|
+
- lib/test/assertion/support.rb
|
34
|
+
- lib/test/debug.rb
|
35
|
+
- lib/test/irb_mode.rb
|
36
|
+
- lib/test/run.rb
|
37
|
+
- lib/test/run/cli.rb
|
38
|
+
- lib/test/run/errors.rb
|
39
|
+
- lib/test/run/interactive.rb
|
40
|
+
- lib/test/run/minimal.rb
|
41
|
+
- lib/test/run/spec.rb
|
42
|
+
- lib/test/run/tap.rb
|
43
|
+
- lib/test/run/xml.rb
|
44
|
+
- lib/test/suite.rb
|
45
|
+
- lib/test/version.rb
|
46
|
+
- test/external/bootstraptest.rb
|
47
|
+
- test/external/bootstrapwrap.rb
|
48
|
+
- test/helper/mocks.rb
|
49
|
+
- test/lib/test.rb
|
50
|
+
- test/lib/test/assertion.rb
|
51
|
+
- test/lib/test/assertion/support.rb
|
52
|
+
- test/lib/test/debug.rb
|
53
|
+
- test/lib/test/irb_mode.rb
|
54
|
+
- test/lib/test/run.rb
|
55
|
+
- test/lib/test/run/cli.rb
|
56
|
+
- test/lib/test/run/errors.rb
|
57
|
+
- test/lib/test/run/interactive.rb
|
58
|
+
- test/lib/test/run/spec.rb
|
59
|
+
- test/lib/test/run/tap.rb
|
60
|
+
- test/lib/test/run/xml.rb
|
61
|
+
- test/lib/test/suite.rb
|
62
|
+
- test/setup.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --inline-source
|
70
|
+
- --line-numbers
|
71
|
+
- --charset
|
72
|
+
- utf-8
|
73
|
+
- --tab-width
|
74
|
+
- "2"
|
75
|
+
- -t
|
76
|
+
- baretest-#<Proc:0x00539b20@/Users/Shared/Development/Gems/baretest/rake/lib/silverplatter/project/bonesplitter.rb:60> Documentation
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: baretest
|
94
|
+
rubygems_version: 1.3.3
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: "A minimal Testframework. Three methods to use it, Twenty to master it, about hundred lines of code1. Bare Test, try it and you\xE2\x80\x99ll love it."
|
98
|
+
test_files: []
|
99
|
+
|