lemon 0.8.5 → 0.9.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/{lemon.gemspec → .gemspec} +0 -0
- data/.ruby +4 -11
- data/Assembly +5 -11
- data/HISTORY.rdoc +31 -0
- data/MANIFEST +45 -55
- data/PROFILE +6 -6
- data/README.md +113 -0
- data/Rakefile +12 -3
- data/VERSION +1 -1
- data/bin/lemonade +8 -0
- data/lib/lemon.rb +52 -2
- data/lib/lemon.yml +4 -11
- data/lib/lemon/{model/ae.rb → ae.rb} +0 -0
- data/lib/lemon/cli.rb +28 -279
- data/lib/lemon/cli/base.rb +139 -0
- data/lib/lemon/cli/coverage.rb +52 -0
- data/lib/lemon/cli/generate.rb +51 -0
- data/lib/lemon/cli/test.rb +50 -0
- data/lib/lemon/core_ext.rb +7 -0
- data/lib/lemon/core_ext/kernel.rb +20 -0
- data/lib/lemon/core_ext/omission.rb +18 -0
- data/lib/lemon/{controller/coverage_analyzer.rb → coverage/analyzer.rb} +41 -19
- data/lib/lemon/{model → coverage}/cover_unit.rb +0 -0
- data/lib/lemon/{view/cover_reports → coverage/formats}/abstract.rb +0 -0
- data/lib/lemon/{view/cover_reports → coverage/formats}/compact.rb +1 -1
- data/lib/lemon/{view/cover_reports → coverage/formats}/outline.rb +1 -1
- data/lib/lemon/{view/cover_reports → coverage/formats}/verbose.rb +1 -1
- data/lib/lemon/{view/cover_reports → coverage/formats}/yaml.rb +1 -1
- data/lib/lemon/{model → coverage}/snapshot.rb +0 -0
- data/lib/lemon/{model → coverage}/source_parser.rb +0 -0
- data/lib/lemon/{controller/scaffold_generator.rb → generator.rb} +53 -14
- data/lib/lemon/test_advice.rb +63 -0
- data/lib/lemon/test_case.rb +270 -0
- data/lib/lemon/test_class.rb +28 -0
- data/lib/lemon/test_method.rb +207 -0
- data/lib/lemon/test_module.rb +114 -0
- data/lib/lemon/test_proc.rb +140 -0
- data/lib/lemon/test_setup.rb +54 -0
- data/lib/lemon/test_world.rb +9 -0
- data/notes/{2010-05-06-files_not_classes.rdoc → 2010-05-06-files-not-classes.rdoc} +0 -0
- data/notes/{2010-07-11-acid_testing.rdoc → 2010-07-11-acid-testing.rdoc} +0 -0
- data/notes/2011-07-07-nailing-down-the-nomenclature.md +6 -0
- data/site/index.html +7 -6
- data/{qed → spec}/applique/fs.rb +0 -0
- data/{qed → spec}/coverage/01_complete.rdoc +26 -16
- data/{qed → spec}/coverage/02_incomplete.rdoc +10 -7
- data/{qed → spec}/coverage/03_extensions.rdoc +10 -6
- data/spec/coverage/applique/lemon.rb +1 -0
- data/try/.test +8 -0
- data/try/case_error.rb +18 -0
- data/try/case_fail.rb +19 -0
- data/try/case_pass.rb +42 -0
- data/try/case_pending.rb +18 -0
- data/try/case_singleton.rb +18 -0
- data/try/case_untested.rb +14 -0
- data/try/fixtures/calculator.rb +15 -0
- data/{demo/fixture → try/fixtures}/example-use.rb +0 -0
- data/{demo/fixture → try/fixtures}/example.rb +0 -0
- data/try/helpers/loadpath.rb +1 -0
- data/{.config → work/deprecated}/cucumber.yml +0 -0
- data/{features → work/deprecated/features}/coverage.feature +0 -0
- data/{features → work/deprecated/features}/generate.feature +0 -0
- data/{features → work/deprecated/features}/step_definitions/coverage_steps.rb +0 -0
- data/{features → work/deprecated/features}/support/ae.rb +0 -0
- data/{features → work/deprecated/features}/support/aruba.rb +0 -0
- data/{features → work/deprecated/features}/test.feature +0 -0
- data/work/deprecated/model/dsl/advice.rb +78 -0
- data/work/deprecated/model/dsl/subject.rb +40 -0
- data/{lib/lemon → work/deprecated}/model/main.rb +40 -29
- data/work/deprecated/model/test.rb +54 -0
- data/work/deprecated/model/test_base_dsl.rb +88 -0
- data/work/deprecated/model/test_clause.rb +112 -0
- data/{lib/lemon → work/deprecated}/model/test_context.rb +24 -24
- data/work/deprecated/model/test_feature.rb +128 -0
- data/work/deprecated/model/test_scenario.rb +137 -0
- data/{lib/lemon → work/deprecated}/model/test_suite.rb +113 -32
- data/work/deprecated/rake.rb +103 -0
- data/{test → work/deprecated/test}/case_coverage_analyzer.rb +0 -0
- data/{test → work/deprecated/test}/case_test_case_dsl.rb +2 -2
- data/{test → work/deprecated/test}/fixtures/case_complete.rb +0 -0
- data/{test → work/deprecated/test}/fixtures/case_inclusion.rb +0 -0
- data/{test → work/deprecated/test}/fixtures/case_incomplete.rb +0 -0
- data/{test → work/deprecated/test}/fixtures/example.rb +0 -0
- data/{test → work/deprecated/test}/fixtures/helper.rb +0 -0
- data/{test → work/deprecated/test}/runner +0 -0
- data/work/old-tests/case_example.rb +15 -0
- data/work/old-tests/feature_example.rb +40 -0
- data/work/reference/dsl2.rb +4 -0
- metadata +101 -98
- data/README.rdoc +0 -103
- data/bin/lemon +0 -4
- data/demo/case_example_error.rb +0 -10
- data/demo/case_example_fail.rb +0 -15
- data/demo/case_example_pass.rb +0 -32
- data/demo/case_example_pending.rb +0 -14
- data/demo/case_example_untested.rb +0 -10
- data/lib/lemon/controller/test_runner.rb +0 -299
- data/lib/lemon/model/pending.rb +0 -10
- data/lib/lemon/model/test_case.rb +0 -305
- data/lib/lemon/model/test_unit.rb +0 -147
- data/lib/lemon/view/test_reports/abstract.rb +0 -256
- data/lib/lemon/view/test_reports/dotprogress.rb +0 -73
- data/lib/lemon/view/test_reports/html.rb +0 -146
- data/lib/lemon/view/test_reports/outline.rb +0 -118
- data/lib/lemon/view/test_reports/summary.rb +0 -131
- data/lib/lemon/view/test_reports/tap.rb +0 -49
- data/lib/lemon/view/test_reports/tapj.rb +0 -130
- data/lib/lemon/view/test_reports/tapy.rb +0 -141
- data/lib/lemon/view/test_reports/verbose.rb +0 -197
- data/work/sandbox/lib/sample.rb +0 -13
- data/work/sandbox/test/sample_case.rb +0 -12
- data/work/trash/example-cover.rb +0 -5
- data/work/trash/example.rb +0 -16
|
@@ -12,14 +12,18 @@ Given an example script in 'lib/extensions_example.rb' as follows:
|
|
|
12
12
|
|
|
13
13
|
And given a test case in 'test/extensions_example_case.rb' as follows:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Covers 'extensions_example.rb'
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
TestCase Kernel do
|
|
18
|
+
method :f1 do
|
|
19
|
+
test do
|
|
20
|
+
fl.assert == "f1"
|
|
21
|
+
end
|
|
20
22
|
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
method :f2 do
|
|
24
|
+
test do
|
|
25
|
+
f2.assert == "f2"
|
|
26
|
+
end
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
29
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'lemon/coverage/analyzer'
|
data/try/.test
ADDED
data/try/case_error.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
covers 'example.rb'
|
|
2
|
+
|
|
3
|
+
test_case Example do
|
|
4
|
+
|
|
5
|
+
method :f do
|
|
6
|
+
|
|
7
|
+
test "one and one is two" do
|
|
8
|
+
ExampleUnknown.new.f(1,1).assert == 2
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "two and two is four" do
|
|
12
|
+
ExampleUnknown.new.f(2,2).assert == 4
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
data/try/case_fail.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
covers 'example.rb'
|
|
2
|
+
|
|
3
|
+
test_case Example do
|
|
4
|
+
|
|
5
|
+
method :f do
|
|
6
|
+
|
|
7
|
+
test "one and one is two" do
|
|
8
|
+
Example.new.f(1,1).assert == 2
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "two and two is four" do
|
|
12
|
+
ex = Example.new
|
|
13
|
+
ex.f(1,2).assert == 4
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
data/try/case_pass.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
covers 'example.rb'
|
|
2
|
+
|
|
3
|
+
test_case Example do
|
|
4
|
+
|
|
5
|
+
method :f do
|
|
6
|
+
|
|
7
|
+
setup "without multipler" do
|
|
8
|
+
@ex = Example.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "1,2" do
|
|
12
|
+
@ex.f(1,2).assert == 3
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "2,2" do
|
|
16
|
+
@ex.f(2,2).assert == 4
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
setup "with multipler" do
|
|
21
|
+
@ex = Example.new(2)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "1,2" do
|
|
25
|
+
@ex.f(1,2).assert == 4
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "2,2" do
|
|
29
|
+
@ex.f(2,2).assert == 6
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
teardown do
|
|
33
|
+
# ...
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#class_method :m do
|
|
37
|
+
# Example.m(1,1).assert == 1
|
|
38
|
+
#end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
data/try/case_pending.rb
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../fixtures')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module Lemon
|
|
2
|
+
|
|
3
|
+
module DSL
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
#--
|
|
7
|
+
# TODO: Allow Before and After to handle before and after
|
|
8
|
+
# concerns in addition to units?
|
|
9
|
+
#++
|
|
10
|
+
module Advice
|
|
11
|
+
|
|
12
|
+
# Define a _complex_ before procedure. The #before method allows
|
|
13
|
+
# before procedures to be defined that are triggered by a match
|
|
14
|
+
# against the unit's target method name or _aspect_ description.
|
|
15
|
+
# This allows groups of tests to be defined that share special
|
|
16
|
+
# setup code.
|
|
17
|
+
#
|
|
18
|
+
# @example
|
|
19
|
+
# Method :puts do
|
|
20
|
+
# Test "standard output (@stdout)" do
|
|
21
|
+
# puts "Hello"
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# Before /@stdout/ do
|
|
25
|
+
# $stdout = StringIO.new
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
# After /@stdout/ do
|
|
29
|
+
# $stdout = STDOUT
|
|
30
|
+
# end
|
|
31
|
+
# end
|
|
32
|
+
#
|
|
33
|
+
# @param [Array<Symbol,Regexp>] matches
|
|
34
|
+
# List of match critera that must _all_ be matched
|
|
35
|
+
# to trigger the before procedure.
|
|
36
|
+
#
|
|
37
|
+
def Before(*matches, &procedure)
|
|
38
|
+
@context.advice[:before][matches] = procedure
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
alias_method :before, :Before
|
|
42
|
+
|
|
43
|
+
# Define a _complex_ after procedure. The #before method allows
|
|
44
|
+
# before procedures to be defined that are triggered by a match
|
|
45
|
+
# against the unit's target method name or _aspect_ description.
|
|
46
|
+
# This allows groups of tests to be defined that share special
|
|
47
|
+
# teardown code.
|
|
48
|
+
#
|
|
49
|
+
# @example
|
|
50
|
+
# Method :puts do
|
|
51
|
+
# Test "standard output (@stdout)" do
|
|
52
|
+
# puts "Hello"
|
|
53
|
+
# end
|
|
54
|
+
#
|
|
55
|
+
# Before /@stdout/ do
|
|
56
|
+
# $stdout = StringIO.new
|
|
57
|
+
# end
|
|
58
|
+
#
|
|
59
|
+
# After /@stdout/ do
|
|
60
|
+
# $stdout = STDOUT
|
|
61
|
+
# end
|
|
62
|
+
# end
|
|
63
|
+
#
|
|
64
|
+
# @param [Array<Symbol,Regexp>] matches
|
|
65
|
+
# List of match critera that must _all_ be matched
|
|
66
|
+
# to trigger the after procedure.
|
|
67
|
+
#
|
|
68
|
+
def After(*matches, &procedure)
|
|
69
|
+
@context.advice[:after][matches] = procedure
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
alias_method :after, :After
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Lemon
|
|
2
|
+
|
|
3
|
+
module DSL
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
module Subject
|
|
7
|
+
|
|
8
|
+
# Setup is used to set things up for each unit test.
|
|
9
|
+
# The setup procedure is run before each unit.
|
|
10
|
+
#
|
|
11
|
+
# @param [String] description
|
|
12
|
+
# A brief description of what the setup procedure sets-up.
|
|
13
|
+
#
|
|
14
|
+
def Setup(description=nil, &procedure)
|
|
15
|
+
if procedure
|
|
16
|
+
@subject = TestSubject.new(@test_case, description, &procedure)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias_method :setup, :Setup
|
|
21
|
+
|
|
22
|
+
alias_method :Concern, :Setup
|
|
23
|
+
alias_method :concern, :Setup
|
|
24
|
+
|
|
25
|
+
alias_method :Subject, :Setup
|
|
26
|
+
alias_method :subject, :Setup
|
|
27
|
+
|
|
28
|
+
# Teardown procedure is used to clean-up after each unit test.
|
|
29
|
+
#
|
|
30
|
+
def Teardown(&procedure)
|
|
31
|
+
@subject.teardown = procedure
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
alias_method :teardown, :Teardown
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -3,38 +3,49 @@
|
|
|
3
3
|
|
|
4
4
|
require 'lemon/model/test_suite'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
#def Before(match=nil, &block)
|
|
8
|
-
# Lemon.suite.Before(match, &block)
|
|
9
|
-
#end
|
|
6
|
+
class << self
|
|
10
7
|
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
#
|
|
9
|
+
def Covers(script)
|
|
10
|
+
Lemon.suite.dsl.covers(script)
|
|
11
|
+
end
|
|
12
|
+
alias :Coverage :Covers
|
|
15
13
|
|
|
16
|
-
#
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
alias :TestCase :testcase
|
|
21
|
-
alias :Case :testcase
|
|
22
|
-
alias :tests :testcase # can't use test b/c of kernel method
|
|
14
|
+
# Define a general test case.
|
|
15
|
+
def Case(target, &block)
|
|
16
|
+
Lemon.suite.dsl.test_case(target, &block)
|
|
17
|
+
end
|
|
23
18
|
|
|
24
|
-
#
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
alias :Covers :covers
|
|
19
|
+
# Define a class test.
|
|
20
|
+
def Class(target_class, &block)
|
|
21
|
+
Lemon.suite.dsl.test_class(target_class, &block)
|
|
22
|
+
end
|
|
29
23
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
# Define a module test.
|
|
25
|
+
def Module(target_module, &block)
|
|
26
|
+
Lemon.suite.dsl.test_module(target_module, &block)
|
|
27
|
+
end
|
|
34
28
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
# Define a test feature.
|
|
30
|
+
def Feature(target, &block)
|
|
31
|
+
Lemon.suite.dsl.test_feature(target, &block)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
#def Before(match=nil, &block)
|
|
36
|
+
# Lemon.suite.Before(match, &block)
|
|
37
|
+
#end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
#def After(match=nil, &block)
|
|
41
|
+
# Lemon.suite.After(match, &block)
|
|
42
|
+
#end
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
#def Helper(script)
|
|
46
|
+
# Lemon.suite.Helper(script)
|
|
47
|
+
#end
|
|
48
|
+
end
|
|
38
49
|
|
|
39
50
|
=begin
|
|
40
51
|
# FIXME: This is a BIG FAT HACK! For the life of me I cannot find
|
|
@@ -49,7 +60,7 @@ alias :Covers :covers
|
|
|
49
60
|
def Object.const_missing(name)
|
|
50
61
|
if unit = Lemon.test_stack.last
|
|
51
62
|
begin
|
|
52
|
-
(class << unit.
|
|
63
|
+
(class << unit.test_case; self; end).const_get(name)
|
|
53
64
|
rescue NameError
|
|
54
65
|
super(name)
|
|
55
66
|
end
|
|
@@ -60,7 +71,7 @@ end
|
|
|
60
71
|
|
|
61
72
|
#def Object.const_missing(name)
|
|
62
73
|
# if unit = Lemon.test_stack.last
|
|
63
|
-
# klass = (class << unit.
|
|
74
|
+
# klass = (class << unit.test_case; self; end)
|
|
64
75
|
# if klass.const_defined?(name)
|
|
65
76
|
# return klass.const_get(name)
|
|
66
77
|
# end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'lemon/model/test_suite'
|
|
2
|
+
|
|
3
|
+
module Test
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
def covers(script)
|
|
8
|
+
Lemon.suite.dsl.covers(script)
|
|
9
|
+
end
|
|
10
|
+
alias :Covers :covers
|
|
11
|
+
|
|
12
|
+
alias :coverage :covers
|
|
13
|
+
alias :Coverage :covers
|
|
14
|
+
|
|
15
|
+
# Define a general test case.
|
|
16
|
+
def case(target, &block)
|
|
17
|
+
Lemon.suite.dsl.test_case(target, &block)
|
|
18
|
+
end
|
|
19
|
+
alias :Case :case
|
|
20
|
+
|
|
21
|
+
# Define a class test.
|
|
22
|
+
def class(target_class, &block)
|
|
23
|
+
Lemon.suite.dsl.test_class(target_class, &block)
|
|
24
|
+
end
|
|
25
|
+
alias :Class :class
|
|
26
|
+
|
|
27
|
+
# Define a module test.
|
|
28
|
+
def module(target_module, &block)
|
|
29
|
+
Lemon.suite.dsl.test_module(target_module, &block)
|
|
30
|
+
end
|
|
31
|
+
alias :Module :module
|
|
32
|
+
|
|
33
|
+
# Define a test feature.
|
|
34
|
+
def feature(target, &block)
|
|
35
|
+
Lemon.suite.dsl.test_feature(target, &block)
|
|
36
|
+
end
|
|
37
|
+
alias :Feature :feature
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
#def Before(match=nil, &block)
|
|
41
|
+
# Lemon.suite.Before(match, &block)
|
|
42
|
+
#end
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
#def After(match=nil, &block)
|
|
46
|
+
# Lemon.suite.After(match, &block)
|
|
47
|
+
#end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
#def Helper(script)
|
|
51
|
+
# Lemon.suite.Helper(script)
|
|
52
|
+
#end
|
|
53
|
+
|
|
54
|
+
end
|