citron 0.1.0 → 0.2.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.
- data/.gitignore +1 -1
- data/.ruby +3 -3
- data/.yardopts +2 -2
- data/Assembly +10 -0
- data/HISTORY.rdoc +10 -0
- data/MANIFEST +4 -2
- data/PROFILE +6 -4
- data/README.rdoc +65 -0
- data/VERSION +1 -1
- data/bm/minitest_example.rb +33 -0
- data/lib/citron.rb +11 -11
- data/lib/citron/test_case.rb +67 -69
- data/lib/citron/{test_unit.rb → test_proc.rb} +11 -10
- data/lib/citron/world.rb +7 -0
- data/site/assets/images/citrons-are-good.png +0 -0
- data/site/assets/images/cut-citron.png +0 -0
- data/site/assets/images/forkme.png +0 -0
- data/site/assets/images/github-logo.png +0 -0
- data/site/assets/images/opensource.png +0 -0
- data/site/assets/images/ruby-logo.png +0 -0
- data/site/assets/images/skin.jpg +0 -0
- data/site/assets/images/skin1.jpg +0 -0
- data/site/assets/images/tap.png +0 -0
- data/site/assets/images/title.png +0 -0
- data/site/assets/images/title2.png +0 -0
- data/site/assets/styles/reset.css +17 -0
- data/site/assets/styles/site.css +47 -0
- data/site/index.html +147 -0
- data/try/.test +2 -0
- data/try/case_setup.rb +23 -0
- metadata +25 -5
- data/README.md +0 -58
data/.gitignore
CHANGED
data/.ruby
CHANGED
@@ -43,8 +43,8 @@ alternatives: []
|
|
43
43
|
revision: 0
|
44
44
|
name: citron
|
45
45
|
title: Citron
|
46
|
-
suite: RubyWorks
|
47
46
|
summary: Classic Unit-style Test Framework
|
48
47
|
description: Citron is a unit testing framework with a classic test-case/test-unit style.
|
49
|
-
|
50
|
-
|
48
|
+
organization: RubyWorks
|
49
|
+
version: 0.2.0
|
50
|
+
date: "2011-08-12"
|
data/.yardopts
CHANGED
data/Assembly
CHANGED
data/HISTORY.rdoc
ADDED
data/MANIFEST
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
.ruby
|
3
3
|
lib/citron/test_advice.rb
|
4
4
|
lib/citron/test_case.rb
|
5
|
+
lib/citron/test_proc.rb
|
5
6
|
lib/citron/test_setup.rb
|
6
|
-
lib/citron/
|
7
|
+
lib/citron/world.rb
|
7
8
|
lib/citron.rb
|
9
|
+
HISTORY.rdoc
|
8
10
|
PROFILE
|
9
11
|
LICENSE.txt
|
10
|
-
README.
|
12
|
+
README.rdoc
|
11
13
|
VERSION
|
12
14
|
COPYING.rdoc
|
data/PROFILE
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
---
|
2
2
|
name : citron
|
3
3
|
title : Citron
|
4
|
-
suite : RubyWorks
|
5
4
|
summary: Classic Unit-style Test Framework
|
6
5
|
authors:
|
7
6
|
- Thomas Sawyer <transfire@gmail.com>
|
@@ -17,9 +16,6 @@ resources:
|
|
17
16
|
repositories:
|
18
17
|
upstream: git://github.com/proutils/citron.git
|
19
18
|
|
20
|
-
copyrights:
|
21
|
-
- 2011 Thomas Sawyer (BSD-2-Clause)
|
22
|
-
|
23
19
|
requirements:
|
24
20
|
- test
|
25
21
|
- ae
|
@@ -27,3 +23,9 @@ requirements:
|
|
27
23
|
- reap (build)
|
28
24
|
- qed (test)
|
29
25
|
|
26
|
+
organization: RubyWorks
|
27
|
+
|
28
|
+
copyrights:
|
29
|
+
- 2011 Thomas Sawyer (BSD-2-Clause)
|
30
|
+
|
31
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
= Citron
|
2
|
+
|
3
|
+
{Homepage}[http://rubyworks.github.com/citron] -
|
4
|
+
{Development}[http://github.com/rubyworks/citron]
|
5
|
+
|
6
|
+
Author:: Thomas Sawyer
|
7
|
+
License:: FreeBSD
|
8
|
+
Copyright:: (c) 2011 Thomas Sawyer, Rubyworks
|
9
|
+
|
10
|
+
|
11
|
+
== Description
|
12
|
+
|
13
|
+
Citron is a classic unit test framework. It defines a simple
|
14
|
+
domain language for create classic-style tests.
|
15
|
+
|
16
|
+
|
17
|
+
== Example
|
18
|
+
|
19
|
+
Here's a fun example.
|
20
|
+
|
21
|
+
TestCase "Show them how to Beat It" do
|
22
|
+
|
23
|
+
setup do
|
24
|
+
@funky = "funky"
|
25
|
+
@right = "right"
|
26
|
+
end
|
27
|
+
|
28
|
+
# fail
|
29
|
+
test "show them how to funky" do
|
30
|
+
@funky.assert != "funky"
|
31
|
+
end
|
32
|
+
|
33
|
+
# pass
|
34
|
+
test "show them what's right" do
|
35
|
+
@right.assert == "right"
|
36
|
+
end
|
37
|
+
|
38
|
+
# error
|
39
|
+
test "no one wants to be defeated" do
|
40
|
+
raise SyntaxError
|
41
|
+
end
|
42
|
+
|
43
|
+
# todo
|
44
|
+
test "better do what you can" do
|
45
|
+
raise NotImplementedError
|
46
|
+
end
|
47
|
+
|
48
|
+
# omit
|
49
|
+
test "just beat it" do
|
50
|
+
e = NotImplementedError.new
|
51
|
+
e.set_assertion(true)
|
52
|
+
raise e
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
== License
|
59
|
+
|
60
|
+
Copyright (c) 2011 Thomas Sawyer, Rubyworks
|
61
|
+
|
62
|
+
Citron is distributed according to the terms of the FreeBSD license.
|
63
|
+
|
64
|
+
See COPYING.rd for details.
|
65
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class ShowThemHowToBeatIt < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
# will fail
|
7
|
+
def test_show_them_how_to_funky
|
8
|
+
refute_equal("funky", "funky")
|
9
|
+
end
|
10
|
+
|
11
|
+
# will pass
|
12
|
+
def test_show_them_whats_right
|
13
|
+
assert_equal("right", "right")
|
14
|
+
end
|
15
|
+
|
16
|
+
# will error
|
17
|
+
def test_no_one_wants_to_be_defeated
|
18
|
+
raise SyntaxError
|
19
|
+
end
|
20
|
+
|
21
|
+
# pending
|
22
|
+
def test_better_do_what_you_can
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
|
26
|
+
# omit
|
27
|
+
def test_just_beat_it
|
28
|
+
e = NotImplementedError.new
|
29
|
+
#e.set_assertion(true)
|
30
|
+
raise e
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/citron.rb
CHANGED
@@ -2,22 +2,22 @@ module Citron
|
|
2
2
|
$TEST_SUITE ||= []
|
3
3
|
|
4
4
|
require 'citron/test_case'
|
5
|
-
require 'citron/
|
5
|
+
require 'citron/test_proc'
|
6
6
|
require 'citron/test_advice'
|
7
7
|
require 'citron/test_setup'
|
8
8
|
end
|
9
9
|
|
10
|
-
module
|
11
|
-
|
10
|
+
module Citron
|
11
|
+
module DSL
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
# Define a general test case.
|
14
|
+
def test_case(label, &block)
|
15
|
+
$TEST_SUITE << Citron::TestCase.new(:label=>label, &block)
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
alias :TestCase :test_case
|
19
|
+
alias :testcase :test_case
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
|
-
extend
|
23
|
+
extend Citron::DSL
|
data/lib/citron/test_case.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
#require 'citron/test_context'
|
3
3
|
require 'citron/test_advice'
|
4
4
|
require 'citron/test_setup'
|
5
|
+
require 'citron/test_proc'
|
6
|
+
require 'citron/world'
|
5
7
|
|
6
8
|
module Citron
|
7
9
|
|
@@ -22,8 +24,7 @@ module Citron
|
|
22
24
|
# The setup and teardown advice.
|
23
25
|
attr :setup
|
24
26
|
|
25
|
-
#
|
26
|
-
# and after advice.
|
27
|
+
# Pattern mathing before and after advice.
|
27
28
|
attr :advice
|
28
29
|
|
29
30
|
# Module for evaluating tests.
|
@@ -31,27 +32,23 @@ module Citron
|
|
31
32
|
|
32
33
|
# A test case +target+ is a class or module.
|
33
34
|
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
def initialize(settings={}, &block)
|
36
|
+
@context = settings[:context]
|
37
|
+
@label = settings[:label]
|
38
|
+
@setup = settings[:setup]
|
39
|
+
@skip = settings[:skip]
|
40
|
+
|
41
|
+
if @context
|
42
|
+
@advice = context.advice.clone
|
41
43
|
else
|
42
|
-
@
|
43
|
-
@advice = TestAdvice.new
|
44
|
+
@advice = TestAdvice.new
|
44
45
|
end
|
45
46
|
|
46
|
-
@
|
47
|
-
@setup = settings[:setup]
|
48
|
-
@skip = settings[:skip]
|
47
|
+
@tests = []
|
49
48
|
|
50
|
-
@
|
49
|
+
@scope = Scope.new(self)
|
51
50
|
|
52
|
-
|
53
|
-
@scope = Module.new
|
54
|
-
@scope.extend domain
|
51
|
+
@scope.module_eval(&block) if block
|
55
52
|
end
|
56
53
|
|
57
54
|
#
|
@@ -77,7 +74,7 @@ module Citron
|
|
77
74
|
|
78
75
|
#
|
79
76
|
def to_s
|
80
|
-
|
77
|
+
label.to_s
|
81
78
|
end
|
82
79
|
|
83
80
|
#
|
@@ -86,8 +83,8 @@ module Citron
|
|
86
83
|
end
|
87
84
|
|
88
85
|
#
|
89
|
-
def skip=(
|
90
|
-
@skip =
|
86
|
+
def skip=(reason)
|
87
|
+
@skip = reason
|
91
88
|
end
|
92
89
|
|
93
90
|
# Run test in the context of this case.
|
@@ -112,56 +109,48 @@ module Citron
|
|
112
109
|
end
|
113
110
|
|
114
111
|
#
|
115
|
-
|
116
|
-
# TODO: Change so that the scope is the DSL
|
117
|
-
# and ** includes the DSL of the context ** !!!
|
118
|
-
#++
|
119
|
-
#def scope
|
120
|
-
# @scope ||= (
|
121
|
-
# scope = Object.new
|
122
|
-
# scope.extend(domain)
|
123
|
-
# scope
|
124
|
-
# )
|
125
|
-
#end
|
126
|
-
|
127
|
-
#
|
128
|
-
class DSL < Module
|
112
|
+
class Scope < World
|
129
113
|
|
130
|
-
#
|
131
|
-
def initialize(testcase
|
114
|
+
# Setup new evaluation scope.
|
115
|
+
def initialize(testcase) #, &code)
|
132
116
|
@_case = testcase
|
133
117
|
@_setup = testcase.setup
|
118
|
+
@_skip = false
|
134
119
|
|
135
120
|
if testcase.context
|
136
121
|
extend(testcase.context.scope)
|
137
122
|
end
|
138
|
-
|
139
|
-
module_eval(&code)
|
140
123
|
end
|
141
124
|
|
142
|
-
# Create a sub-case.
|
143
125
|
#--
|
144
|
-
#
|
145
|
-
#
|
126
|
+
# TODO: Instead of reusing TestCase can we have a TestContext
|
127
|
+
# that more generically mimics it's context context?
|
146
128
|
#++
|
129
|
+
|
130
|
+
# Create a sub-case.
|
147
131
|
def Context(label, &block)
|
148
132
|
settings = {
|
149
|
-
:
|
150
|
-
:setup
|
133
|
+
:context => @_case,
|
134
|
+
:setup => @_setup,
|
135
|
+
:skip => @_skip,
|
136
|
+
:label => label
|
151
137
|
}
|
152
|
-
testcase = TestCase.new(
|
138
|
+
testcase = TestCase.new(settings, &block)
|
153
139
|
@_case.tests << testcase
|
154
140
|
testcase
|
155
141
|
end
|
156
|
-
|
142
|
+
|
143
|
+
alias :context :Context
|
157
144
|
|
158
145
|
# Create a test.
|
159
146
|
def Test(label=nil, &procedure)
|
160
147
|
settings = {
|
161
|
-
:
|
162
|
-
:setup
|
148
|
+
:context => @_case,
|
149
|
+
:setup => @_setup,
|
150
|
+
:skip => @_skip,
|
151
|
+
:label => label
|
163
152
|
}
|
164
|
-
testunit =
|
153
|
+
testunit = TestProc.new(settings, &procedure)
|
165
154
|
if procedure.arity == 0
|
166
155
|
@_case.tests << testunit
|
167
156
|
else
|
@@ -169,9 +158,9 @@ module Citron
|
|
169
158
|
end
|
170
159
|
testunit
|
171
160
|
end
|
172
|
-
alias_method :test, :Test
|
173
161
|
|
174
|
-
|
162
|
+
alias :test :Test
|
163
|
+
|
175
164
|
#
|
176
165
|
#
|
177
166
|
def Ok(*args)
|
@@ -182,7 +171,8 @@ module Citron
|
|
182
171
|
return test
|
183
172
|
end
|
184
173
|
|
185
|
-
|
174
|
+
alias :ok :Ok
|
175
|
+
|
186
176
|
#
|
187
177
|
#
|
188
178
|
def No(*args)
|
@@ -194,33 +184,30 @@ module Citron
|
|
194
184
|
return test
|
195
185
|
end
|
196
186
|
|
187
|
+
alias :no :No
|
188
|
+
|
197
189
|
# Setup is used to set things up for each unit test.
|
198
190
|
# The setup procedure is run before each unit.
|
199
191
|
#
|
200
|
-
# @param [String]
|
192
|
+
# @param [String] label
|
201
193
|
# A brief description of what the setup procedure sets-up.
|
202
194
|
#
|
203
|
-
def Setup(
|
204
|
-
|
205
|
-
@_setup = TestSetup.new(@_case, description, &procedure)
|
206
|
-
end
|
195
|
+
def Setup(label=nil, &proc)
|
196
|
+
@_setup = TestSetup.new(@_case, label, &proc)
|
207
197
|
end
|
208
198
|
|
209
|
-
|
199
|
+
alias :setup :Setup
|
210
200
|
|
211
201
|
#alias_method :Concern, :Setup
|
212
202
|
#alias_method :concern, :Setup
|
213
203
|
|
214
|
-
#alias_method :Subject, :Setup
|
215
|
-
#alias_method :subject, :Setup
|
216
|
-
|
217
204
|
# Teardown procedure is used to clean-up after each unit test.
|
218
205
|
#
|
219
|
-
def Teardown(&
|
220
|
-
@_setup.teardown =
|
206
|
+
def Teardown(&proc)
|
207
|
+
@_setup.teardown = proc
|
221
208
|
end
|
222
209
|
|
223
|
-
|
210
|
+
alias :teardown :Teardown
|
224
211
|
|
225
212
|
# Define a _complex_ before procedure. The #before method allows
|
226
213
|
# before procedures to be defined that are triggered by a match
|
@@ -251,7 +238,7 @@ module Citron
|
|
251
238
|
@_case.advice[:before][matches] = procedure
|
252
239
|
end
|
253
240
|
|
254
|
-
|
241
|
+
alias :before :Before
|
255
242
|
|
256
243
|
# Define a _complex_ after procedure. The #before method allows
|
257
244
|
# before procedures to be defined that are triggered by a match
|
@@ -282,14 +269,25 @@ module Citron
|
|
282
269
|
@_case.advice[:after][matches] = procedure
|
283
270
|
end
|
284
271
|
|
285
|
-
|
272
|
+
alias :after :After
|
286
273
|
|
287
|
-
# Mark
|
274
|
+
# Mark tests or subcases to be skipped.
|
288
275
|
#
|
289
|
-
|
290
|
-
|
276
|
+
# @example
|
277
|
+
# skip("reason for skipping") do
|
278
|
+
# test "some test" do
|
279
|
+
# ...
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
#
|
283
|
+
def Skip(reason=true, &block)
|
284
|
+
@_skip = reason
|
285
|
+
block.call
|
286
|
+
@_skip = false
|
291
287
|
end
|
292
288
|
|
289
|
+
alias :skip :Skip
|
290
|
+
|
293
291
|
end
|
294
292
|
|
295
293
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Citron
|
2
2
|
|
3
3
|
#
|
4
|
-
class
|
4
|
+
class TestProc
|
5
5
|
|
6
6
|
# New unit test procedure.
|
7
7
|
#
|
8
|
-
def initialize(
|
9
|
-
@context
|
10
|
-
|
8
|
+
def initialize(options={}, &procedure)
|
9
|
+
@context = options[:context]
|
11
10
|
@setup = options[:setup]
|
12
11
|
@label = options[:label]
|
13
12
|
@skip = options[:skip]
|
@@ -40,15 +39,15 @@ module Citron
|
|
40
39
|
|
41
40
|
#
|
42
41
|
def type
|
43
|
-
'
|
42
|
+
'Test'
|
44
43
|
end
|
45
44
|
|
46
45
|
#
|
47
46
|
def skip? ; @skip ; end
|
48
47
|
|
49
48
|
#
|
50
|
-
def skip=(
|
51
|
-
@skip =
|
49
|
+
def skip=(reason)
|
50
|
+
@skip = reason
|
52
51
|
end
|
53
52
|
|
54
53
|
#
|
@@ -58,7 +57,7 @@ module Citron
|
|
58
57
|
|
59
58
|
#
|
60
59
|
def tested=(boolean)
|
61
|
-
@tested = boolean
|
60
|
+
@tested = !!boolean
|
62
61
|
end
|
63
62
|
|
64
63
|
#
|
@@ -71,8 +70,10 @@ module Citron
|
|
71
70
|
@setup
|
72
71
|
end
|
73
72
|
|
74
|
-
#
|
75
|
-
|
73
|
+
# Ruby Test looks for `topic` as the desciption of a test's setup.
|
74
|
+
def topic
|
75
|
+
@setup.to_s
|
76
|
+
end
|
76
77
|
|
77
78
|
#
|
78
79
|
def scope
|
data/lib/citron/world.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
html { font-family: sans-serif; font-size: 16px; color: black; }
|
2
|
+
body { padding: 0; margin: 0; font-family: sans-serif; font-size: 12px; background: #fff; }
|
3
|
+
|
4
|
+
h1 { font-size: 90px; margin: 20px; }
|
5
|
+
|
6
|
+
p { font-size: 110%; text-align: justify; margin: 20px 0; line-height: 150%; }
|
7
|
+
|
8
|
+
a { text-decoration: none; font-size: 100%; }
|
9
|
+
a:hover { text-decoration: underline; }
|
10
|
+
|
11
|
+
ul { margin: 0 auto; list-style-type: none; width: 300px; }
|
12
|
+
li { float: left; padding: 10px; text-align: center; }
|
13
|
+
|
14
|
+
pre { font-size: 130%; padding: 10px 0 0 0; -moz-border-radius: 10px; font-family: courier, monospace; color: #000; }
|
15
|
+
code { font-family: courier, monospace; }
|
16
|
+
|
17
|
+
img { border: none; }
|
@@ -0,0 +1,47 @@
|
|
1
|
+
html { font-size: 16px; }
|
2
|
+
|
3
|
+
h1 { font-family: times; font-size: 400%; margin: 20px 0; color: #f7d901; }
|
4
|
+
h2 { font-size: 220%; margin-top: 30px; color: #444; }
|
5
|
+
h3 { font-size: 190%; color: green; }
|
6
|
+
|
7
|
+
p { color: #222; font-weight: normal; font-size: 110%; }
|
8
|
+
a { color: #262; }
|
9
|
+
a:hover { text-decoration: underline; }
|
10
|
+
|
11
|
+
pre { background: #ffffff; -moz-border-radius: 10px; line-height: 140%; font-size: 0.9em; }}
|
12
|
+
code { color: #222; font-weight: bold; }
|
13
|
+
tt { color: #222; font-weight: bold; }
|
14
|
+
|
15
|
+
#nav { padding: 0 30px 20px 60px; text-align: left; color: pink; float: right; }
|
16
|
+
#nav a { font-size: 160%; font-weight: bold; line-height: 150%; color: orange; }
|
17
|
+
#nav a:hover { color: #FFF; text-decoration: none; }
|
18
|
+
|
19
|
+
#header { height: 250px; text-align: left; }
|
20
|
+
#header h1 { font-size: 100px; margin-bottom: 0; padding: 40px 0 0 0; color: #f7d901; margin-left: -10px; }
|
21
|
+
#header h2 { padding: 0 0 0 110px; margin-top: 0; }
|
22
|
+
|
23
|
+
#main { color: white; padding: 20px 0 30px 0; background: url(../images/skin.jpg) #f7e931; }
|
24
|
+
#main p { font-weight: bold; font-family: sans-serif; font-size: 1.8em; color: #222; font-weight: bold; text-shadow: 1px 1px white; }
|
25
|
+
#main h2 { color: #333333; }
|
26
|
+
#main h3 { color: #333333; }
|
27
|
+
|
28
|
+
#example p { font-size: 2em; }
|
29
|
+
|
30
|
+
#footer { margin-top: 40px; padding: 40px 0; text-align: center; background: url(../images/skin.jpg) #f7e931; }
|
31
|
+
#footer .copyright { padding-top: 0; }
|
32
|
+
#footer .copyright p { color: #222; font-weight: normal; font-size: 80%; line-height: 150%; }
|
33
|
+
|
34
|
+
#forkme {
|
35
|
+
position: absolute;
|
36
|
+
top: 0; right: 0;
|
37
|
+
width: 150px;
|
38
|
+
}
|
39
|
+
|
40
|
+
.page { width: 730px; margin: 0 auto; }
|
41
|
+
|
42
|
+
.bordered { border-top: 2px solid #99ff99; border-bottom: 2px solid #99ff99; }
|
43
|
+
|
44
|
+
.copyright { padding: 0; text-align: left; }
|
45
|
+
.copyright td { font-size: 10px; color: #444; }
|
46
|
+
|
47
|
+
|
data/site/index.html
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Citron</title>
|
4
|
+
<link href="assets/styles/reset.css" rel="stylesheet" type="text/css"/>
|
5
|
+
<link href="assets/styles/site.css" rel="stylesheet" type="text/css"/>
|
6
|
+
<link href="assets/images/citron.jpg" rel="shortcut icon"/>
|
7
|
+
|
8
|
+
<!-- syntax highlighing -->
|
9
|
+
<script src="http://rubyworks.github.com/assets/includes/shjs/sh_main.min.js"></script>
|
10
|
+
<script src="http://rubyworks.github.com/assets/includes/shjs/lang/sh_ruby.min.js"></script>
|
11
|
+
<script src="http://rubyworks.github.com/assets/includes/shjs/lang/sh_sh.min.js"></script>
|
12
|
+
<link href="http://rubyworks.github.com/assets/includes/shjs/css/sh_acid.min.css" rel="stylesheet" type="text/css" />
|
13
|
+
</head>
|
14
|
+
<body onload="sh_highlightDocument();">
|
15
|
+
|
16
|
+
<div id="forkme">
|
17
|
+
<a href="http://github.com/rubyworks/citron"><img src="assets/images/forkme.png" /></a>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div id="header">
|
21
|
+
<div class="page">
|
22
|
+
<img src="assets/images/cut-citron.png" height="200px" align="right" style="padding-top: 15px;"/>
|
23
|
+
<h1><img src="assets/images/title.png"/></h1>
|
24
|
+
<h2>Clean Classic Testing</h2>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div id="main" class="bordered">
|
29
|
+
<div class="page">
|
30
|
+
|
31
|
+
<p>Citron is classic unit testing framework with a clear domain specific language
|
32
|
+
notating testcase and test procedure, that runs on top of the Ruby Universal Test
|
33
|
+
Harness, <a href="http://rubyworks.github.com/test">Ruby Test</a>.</p>
|
34
|
+
|
35
|
+
<!--
|
36
|
+
<p>Citron uses the <a href="http://rubyworks.github.com/ae">Assertive Expressive</a>
|
37
|
+
assertions framework. This is the same verstile framework used by <a href="http://rubyworks.github.com/qed">Q.E.D.</a>.
|
38
|
+
By default Citron test support the standard <code>#assert</code> and <code>#expect</code> assertion methods.
|
39
|
+
If you wish to use subjunctive terms, either <code>#should</code> or <code>#must</code>, you can load these
|
40
|
+
via a helper script (eg. <code>require 'ae/should'</code>).</p>
|
41
|
+
-->
|
42
|
+
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="example">
|
47
|
+
<div class="page">
|
48
|
+
|
49
|
+
<div id="nav">
|
50
|
+
<!-- <a href="guide/doc.en/index.html">English Manual</a> · -->
|
51
|
+
<a href="http://wiki.github.com/rubyworks/citron">Wiki</a>
|
52
|
+
<a href="http://rubydoc.info/gems/citron/frames">API</a>
|
53
|
+
<a href="http://googlegroups.com/group/rubyworks-mailinglist">Email</a>
|
54
|
+
<a href="http://github.com/rubyworks/citron/issues">Issue</a>
|
55
|
+
<a href="http://github.com/rubyworks/citron">Code</a>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<h3>Example</h3>
|
59
|
+
|
60
|
+
<p>Citron tests are organized into test cases and test procedures.
|
61
|
+
Here is an example:</p>
|
62
|
+
|
63
|
+
<pre class="sh_ruby">
|
64
|
+
TestCase "Show them how to Beat It" do
|
65
|
+
|
66
|
+
# will fail
|
67
|
+
test "show them how to funky" do
|
68
|
+
"funky".assert != "funky"
|
69
|
+
end
|
70
|
+
|
71
|
+
# will pass
|
72
|
+
test "show them what's right" do
|
73
|
+
"right".assert == "right"
|
74
|
+
end
|
75
|
+
|
76
|
+
# will error
|
77
|
+
test "no one wants to be defeated" do
|
78
|
+
raise SyntaxError
|
79
|
+
end
|
80
|
+
|
81
|
+
# pending
|
82
|
+
test "better do what you can" do
|
83
|
+
raise NotImplementedError
|
84
|
+
end
|
85
|
+
|
86
|
+
# omit
|
87
|
+
test "just beat it" do
|
88
|
+
e = NotImplementedError.new
|
89
|
+
e.set_assertion(true)
|
90
|
+
raise e
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
</pre>
|
95
|
+
|
96
|
+
<p>The assertion framework is actually independent of the test framework,
|
97
|
+
so almost any assertion system will work. In the example above we are using
|
98
|
+
<a href="http://rubyworks.github.com/ae">A.E.</a></p>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div id="footer" class="bordered">
|
104
|
+
<div class="page">
|
105
|
+
<script type="text/javascript"><!--
|
106
|
+
google_ad_client = "ca-pub-1126154564663472";
|
107
|
+
/* RUBYWORKS 09-10-02 728x90 */
|
108
|
+
google_ad_slot = "0788888658";
|
109
|
+
google_ad_width = 728;
|
110
|
+
google_ad_height = 90;
|
111
|
+
//-->
|
112
|
+
</script>
|
113
|
+
<script type="text/javascript"
|
114
|
+
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
115
|
+
</script>
|
116
|
+
|
117
|
+
<br/><br/><br/>
|
118
|
+
|
119
|
+
<div class="copyright" width="100%">
|
120
|
+
<a href="http://rubyworks.github.com/">
|
121
|
+
<img src="assets/images/ruby-logo.png" height="110px" align="left" style="margin: 0 5px; padding: 0 10px" />
|
122
|
+
</a>
|
123
|
+
<a href="http://www.apache.org/licenses/LICENSE-2.0.html">
|
124
|
+
<img src="assets/images/opensource.png" height="120px" align="left" style="padding: 0 10px;" />
|
125
|
+
</a>
|
126
|
+
<a href="github.com/rubyworks/citron">
|
127
|
+
<img src="assets/images/github-logo.png" height="115px" align="left" style="margin: 0; padding: 0 10px;" />
|
128
|
+
</a>
|
129
|
+
<a href="http://testanything.org/wiki/index.php/Main_Page">
|
130
|
+
<img src="assets/images/tap.png" height="113px" align="left" style="margin: 0; padding: 0 20px;" />
|
131
|
+
</a>
|
132
|
+
<a href="">
|
133
|
+
<img src="assets/images/citrons-are-good.png" height="117px" align="left" style="margin: 0; padding: 0 10px;" />
|
134
|
+
</a>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<br style="clear: both;" />
|
138
|
+
|
139
|
+
<div style="margin-top: 30px;">
|
140
|
+
<b>Citron</b>, Copyright © 2009 Thomas Sawyer ·
|
141
|
+
<b>Contact:</b> transfire @ gmail.com
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
</body>
|
147
|
+
</html>
|
data/try/.test
ADDED
data/try/case_setup.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
test_case "Example of using setup in a testcase" do
|
2
|
+
|
3
|
+
setup do
|
4
|
+
@x = 1
|
5
|
+
end
|
6
|
+
|
7
|
+
test "has setup without a topic" do
|
8
|
+
@x.assert == 1
|
9
|
+
end
|
10
|
+
|
11
|
+
setup "has a topic" do
|
12
|
+
@x = 10
|
13
|
+
end
|
14
|
+
|
15
|
+
test "has setup with a topic" do
|
16
|
+
@x.assert == 10
|
17
|
+
end
|
18
|
+
|
19
|
+
test "alos has setup with a topic" do
|
20
|
+
@x.assert! == 5
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: citron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Sawyer
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: test
|
@@ -76,8 +76,9 @@ extensions: []
|
|
76
76
|
|
77
77
|
extra_rdoc_files:
|
78
78
|
- LICENSE.txt
|
79
|
+
- HISTORY.rdoc
|
80
|
+
- README.rdoc
|
79
81
|
- COPYING.rdoc
|
80
|
-
- README.md
|
81
82
|
files:
|
82
83
|
- .gemspec
|
83
84
|
- .gitignore
|
@@ -85,17 +86,36 @@ files:
|
|
85
86
|
- .yardopts
|
86
87
|
- Assembly
|
87
88
|
- COPYING.rdoc
|
89
|
+
- HISTORY.rdoc
|
88
90
|
- LICENSE.txt
|
89
91
|
- MANIFEST
|
90
92
|
- PROFILE
|
91
|
-
- README.
|
93
|
+
- README.rdoc
|
92
94
|
- VERSION
|
95
|
+
- bm/minitest_example.rb
|
93
96
|
- lib/citron.rb
|
94
97
|
- lib/citron/test_advice.rb
|
95
98
|
- lib/citron/test_case.rb
|
99
|
+
- lib/citron/test_proc.rb
|
96
100
|
- lib/citron/test_setup.rb
|
97
|
-
- lib/citron/
|
101
|
+
- lib/citron/world.rb
|
102
|
+
- site/assets/images/citrons-are-good.png
|
103
|
+
- site/assets/images/cut-citron.png
|
104
|
+
- site/assets/images/forkme.png
|
105
|
+
- site/assets/images/github-logo.png
|
106
|
+
- site/assets/images/opensource.png
|
107
|
+
- site/assets/images/ruby-logo.png
|
108
|
+
- site/assets/images/skin.jpg
|
109
|
+
- site/assets/images/skin1.jpg
|
110
|
+
- site/assets/images/tap.png
|
111
|
+
- site/assets/images/title.png
|
112
|
+
- site/assets/images/title2.png
|
113
|
+
- site/assets/styles/reset.css
|
114
|
+
- site/assets/styles/site.css
|
115
|
+
- site/index.html
|
116
|
+
- try/.test
|
98
117
|
- try/case_example.rb
|
118
|
+
- try/case_setup.rb
|
99
119
|
homepage: http://rubyworks.github.com/citron
|
100
120
|
licenses: []
|
101
121
|
|
data/README.md
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# Citron
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr><td><b>Author </b></td><td>Thomas Sawyer</td></tr>
|
5
|
-
<tr><td><b>License </b></td><td>FreeBSD</td></tr>
|
6
|
-
<tr><td><b>Copyright</b></td><td>(c) 2011 Thomas Sawyer, Rubyworks</td></tr>
|
7
|
-
</table>
|
8
|
-
|
9
|
-
## Description
|
10
|
-
|
11
|
-
Citron is a classic unit test framework. It defines a simple
|
12
|
-
domain language for create classic-style tests.
|
13
|
-
|
14
|
-
## Example
|
15
|
-
|
16
|
-
Here's a fun example.
|
17
|
-
|
18
|
-
``` ruby
|
19
|
-
TestCase "Show them how to Beat It" do
|
20
|
-
|
21
|
-
# fail
|
22
|
-
test "show them how to funky" do
|
23
|
-
"funky".assert != "funky"
|
24
|
-
end
|
25
|
-
|
26
|
-
# pass
|
27
|
-
test "show them what's right" do
|
28
|
-
"right".assert == "right"
|
29
|
-
end
|
30
|
-
|
31
|
-
# error
|
32
|
-
test "no one wants to be defeated" do
|
33
|
-
raise SyntaxError
|
34
|
-
end
|
35
|
-
|
36
|
-
# todo
|
37
|
-
test "better do what you can" do
|
38
|
-
raise NotImplementedError
|
39
|
-
end
|
40
|
-
|
41
|
-
# omit
|
42
|
-
test "just beat it" do
|
43
|
-
e = NotImplementedError.new
|
44
|
-
e.set_assertion(true)
|
45
|
-
raise e
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
```
|
50
|
-
|
51
|
-
## License
|
52
|
-
|
53
|
-
Copyright (c) 2011 Thomas Sawyer, Rubyworks
|
54
|
-
|
55
|
-
Citron is distributed according to the terms of the FreeBSD license.
|
56
|
-
|
57
|
-
See COPYING.rd for details.
|
58
|
-
|