lemon 0.9.0 → 0.9.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 +7 -0
- data/{HISTORY.rdoc → HISTORY.md} +42 -11
- data/LICENSE.txt +27 -0
- data/README.md +48 -34
- data/{spec/coverage/01_complete.rdoc → demo/coverage/01_complete.md} +3 -3
- data/{spec/coverage/02_incomplete.rdoc → demo/coverage/02_incomplete.md} +2 -2
- data/{spec/coverage/03_extensions.rdoc → demo/coverage/03_extensions.md} +2 -2
- data/lib/lemon/cli/base.rb +50 -20
- data/lib/lemon/cli/generate.rb +51 -16
- data/lib/lemon/cli/lemon.ascii +84 -0
- data/lib/lemon/cli/obrother.rb +35 -0
- data/lib/lemon/cli/scaffold.rb +116 -0
- data/lib/lemon/cli.rb +19 -8
- data/lib/lemon/core_ext/module.rb +9 -0
- data/lib/lemon/core_ext.rb +2 -2
- data/lib/lemon/coverage/analyzer.rb +76 -5
- data/lib/lemon/coverage/cover_unit.rb +38 -14
- data/lib/lemon/coverage/formats/verbose.rb +1 -1
- data/lib/lemon/coverage/generator.rb +196 -0
- data/lib/lemon/coverage/snapshot.rb +16 -16
- data/lib/lemon/coverage/source_parser.rb +103 -37
- data/lib/lemon/ignore_callers.rb +19 -0
- data/lib/lemon/test_case.rb +135 -26
- data/lib/lemon/test_class.rb +16 -3
- data/lib/lemon/test_class_method.rb +58 -0
- data/lib/lemon/test_method.rb +57 -68
- data/lib/lemon/test_module.rb +47 -44
- data/lib/lemon/test_proc.rb +28 -2
- data/lib/lemon/test_scope.rb +14 -0
- data/lib/lemon/test_setup.rb +1 -1
- data/lib/lemon/test_world.rb +7 -0
- data/lib/lemon.rb +1 -15
- metadata +71 -147
- data/.gemspec +0 -152
- data/.gitignore +0 -8
- data/.reap/digest +0 -678
- data/.reap/test.reap +0 -7
- data/.ruby +0 -49
- data/Assembly +0 -37
- data/COPYING.rdoc +0 -33
- data/MANIFEST +0 -55
- data/PROFILE +0 -30
- data/Rakefile +0 -23
- data/VERSION +0 -1
- data/lib/lemon/core_ext/omission.rb +0 -18
- data/lib/lemon/generator.rb +0 -149
- data/lib/lemon.yml +0 -49
- data/notes/2010-05-05-coverage.rdoc +0 -47
- data/notes/2010-05-06-files-not-classes.rdoc +0 -19
- data/notes/2010-07-11-acid-testing.rdoc +0 -52
- data/notes/2010-08-02-enforcing-the-unit.md +0 -68
- data/notes/2010-08-03-new-api.md +0 -37
- data/notes/2011-07-07-nailing-down-the-nomenclature.md +0 -6
- data/site/.rsync-filter +0 -8
- data/site/assets/images/cut-lemon.png +0 -0
- data/site/assets/images/forkme.png +0 -0
- data/site/assets/images/github-logo.png +0 -0
- data/site/assets/images/lemon.jpg +0 -0
- data/site/assets/images/lemon.svg +0 -39
- data/site/assets/images/lemons-are-good.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/styles/class.css +0 -6
- data/site/assets/styles/reset.css +0 -17
- data/site/assets/styles/site.css +0 -33
- data/site/index.html +0 -218
- data/try/.test +0 -8
- data/try/case_error.rb +0 -18
- data/try/case_fail.rb +0 -19
- data/try/case_pass.rb +0 -42
- data/try/case_pending.rb +0 -18
- data/try/case_singleton.rb +0 -18
- data/try/case_untested.rb +0 -14
- data/try/fixtures/calculator.rb +0 -15
- data/try/fixtures/example-use.rb +0 -5
- data/try/fixtures/example.rb +0 -20
- data/try/helpers/loadpath.rb +0 -1
- data/work/deprecated/command/abstract.rb +0 -29
- data/work/deprecated/command/coverage.rb +0 -115
- data/work/deprecated/command/generate.rb +0 -124
- data/work/deprecated/command/test.rb +0 -112
- data/work/deprecated/cucumber.yml +0 -3
- data/work/deprecated/features/coverage.feature +0 -65
- data/work/deprecated/features/generate.feature +0 -66
- data/work/deprecated/features/step_definitions/coverage_steps.rb +0 -1
- data/work/deprecated/features/support/aruba.rb +0 -1
- data/work/deprecated/features/test.feature +0 -67
- data/work/deprecated/model/dsl/advice.rb +0 -78
- data/work/deprecated/model/dsl/subject.rb +0 -40
- data/work/deprecated/model/main.rb +0 -87
- data/work/deprecated/model/test.rb +0 -54
- data/work/deprecated/model/test_base_dsl.rb +0 -88
- data/work/deprecated/model/test_clause.rb +0 -112
- data/work/deprecated/model/test_context.rb +0 -90
- data/work/deprecated/model/test_feature.rb +0 -128
- data/work/deprecated/model/test_scenario.rb +0 -137
- data/work/deprecated/model/test_suite.rb +0 -297
- data/work/deprecated/rake.rb +0 -103
- data/work/deprecated/test/case_coverage_analyzer.rb +0 -25
- data/work/deprecated/test/case_test_case_dsl.rb +0 -46
- data/work/deprecated/test/fixtures/case_complete.rb +0 -25
- data/work/deprecated/test/fixtures/case_inclusion.rb +0 -18
- data/work/deprecated/test/fixtures/case_incomplete.rb +0 -12
- data/work/deprecated/test/fixtures/example.rb +0 -13
- data/work/deprecated/test/fixtures/helper.rb +0 -13
- data/work/deprecated/test/runner +0 -2
- data/work/old-tests/case_example.rb +0 -15
- data/work/old-tests/feature_example.rb +0 -40
- data/work/reference/dsl2.rb +0 -140
- data/work/reference/dynamic_constant_lookup.rb +0 -76
- /data/bin/{lemonade → lemons} +0 -0
- /data/{work/deprecated/features/support → demo/applique}/ae.rb +0 -0
- /data/{spec → demo}/applique/fs.rb +0 -0
- /data/{spec → demo}/coverage/applique/lemon.rb +0 -0
data/.reap/test.reap
DELETED
data/.ruby
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
authors:
|
|
3
|
-
- name: Thomas Sawyer
|
|
4
|
-
email: transfire@gmail.com
|
|
5
|
-
copyrights:
|
|
6
|
-
- holder: Thomas Sawyer
|
|
7
|
-
year: '2009'
|
|
8
|
-
license: BSD-2-Clause
|
|
9
|
-
replacements: []
|
|
10
|
-
conflicts: []
|
|
11
|
-
requirements:
|
|
12
|
-
- name: test
|
|
13
|
-
- name: ae
|
|
14
|
-
- name: ansi
|
|
15
|
-
version: 1.3+
|
|
16
|
-
- name: detroit
|
|
17
|
-
groups:
|
|
18
|
-
- build
|
|
19
|
-
development: true
|
|
20
|
-
- name: reap
|
|
21
|
-
groups:
|
|
22
|
-
- build
|
|
23
|
-
development: true
|
|
24
|
-
- name: qed
|
|
25
|
-
groups:
|
|
26
|
-
- test
|
|
27
|
-
development: true
|
|
28
|
-
dependencies: []
|
|
29
|
-
repositories:
|
|
30
|
-
- uri: git://github.com/proutils/lemon.git
|
|
31
|
-
scm: git
|
|
32
|
-
name: origin
|
|
33
|
-
resources:
|
|
34
|
-
home: http://rubyworks.github.com/lemon
|
|
35
|
-
code: http://github.com/rubyworks/lemon
|
|
36
|
-
load_path:
|
|
37
|
-
- lib
|
|
38
|
-
extra:
|
|
39
|
-
manifest: MANIFEST
|
|
40
|
-
alternatives: []
|
|
41
|
-
revision: 0
|
|
42
|
-
title: Lemon
|
|
43
|
-
summary: Pucker-tight Unit Testing
|
|
44
|
-
description: Lemon is a unit testing framework that tightly correlates class to test
|
|
45
|
-
case and method to test unit.
|
|
46
|
-
organization: RubyWorks
|
|
47
|
-
version: 0.9.0
|
|
48
|
-
name: lemon
|
|
49
|
-
date: '2011-08-11'
|
data/Assembly
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
email:
|
|
3
|
-
service : Email
|
|
4
|
-
file : ~
|
|
5
|
-
subject : ~
|
|
6
|
-
mailto :
|
|
7
|
-
- ruby-talk@ruby-lang.org
|
|
8
|
-
- rubyworks-mailinglist@googlegroups.com
|
|
9
|
-
#parts : [readme]
|
|
10
|
-
active : true
|
|
11
|
-
|
|
12
|
-
gem:
|
|
13
|
-
active : true
|
|
14
|
-
|
|
15
|
-
github: {}
|
|
16
|
-
|
|
17
|
-
dnote:
|
|
18
|
-
labels : ~
|
|
19
|
-
output : log/DNOTE.rdoc
|
|
20
|
-
|
|
21
|
-
yard:
|
|
22
|
-
yardopts: true
|
|
23
|
-
priority: 2
|
|
24
|
-
|
|
25
|
-
qed:
|
|
26
|
-
files: spec
|
|
27
|
-
|
|
28
|
-
qedoc:
|
|
29
|
-
title: Lemony Testing
|
|
30
|
-
files: spec
|
|
31
|
-
output: QED.rdoc
|
|
32
|
-
|
|
33
|
-
vclog:
|
|
34
|
-
output:
|
|
35
|
-
- log/AHISTORY.rdoc
|
|
36
|
-
- log/CHANGELOG.rdoc
|
|
37
|
-
|
data/COPYING.rdoc
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
= COPYRIGHT NOTICES
|
|
2
|
-
|
|
3
|
-
== Lemon
|
|
4
|
-
|
|
5
|
-
Copyright:: (c)2009 Thomas Sawyer
|
|
6
|
-
License:: BSD-2-Clause
|
|
7
|
-
Website:: http://rubyworks.github.com/lemon
|
|
8
|
-
|
|
9
|
-
Copyright 2009 Thomas Sawyer. All rights reserved.
|
|
10
|
-
|
|
11
|
-
Redistribution and use in source and binary forms, with or without modification, are
|
|
12
|
-
permitted provided that the following conditions are met:
|
|
13
|
-
|
|
14
|
-
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
15
|
-
conditions and the following disclaimer.
|
|
16
|
-
|
|
17
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
18
|
-
of conditions and the following disclaimer in the documentation and/or other materials
|
|
19
|
-
provided with the distribution.
|
|
20
|
-
|
|
21
|
-
THIS SOFTWARE IS PROVIDED BY Thomas Sawyer ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
22
|
-
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Thomas Sawyer OR
|
|
24
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
27
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
28
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
29
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
|
|
31
|
-
The views and conclusions contained in the software and documentation are those of the
|
|
32
|
-
authors and should not be interpreted as representing official policies, either expressed
|
|
33
|
-
or implied, of Thomas Sawyer.
|
data/MANIFEST
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!mast .yardopts .ruby bin demo lib man qed spec test try [A-Z][A-Z]*
|
|
2
|
-
.yardopts
|
|
3
|
-
.ruby
|
|
4
|
-
bin/lemonade
|
|
5
|
-
lib/lemon/ae.rb
|
|
6
|
-
lib/lemon/cli/base.rb
|
|
7
|
-
lib/lemon/cli/coverage.rb
|
|
8
|
-
lib/lemon/cli/generate.rb
|
|
9
|
-
lib/lemon/cli/test.rb
|
|
10
|
-
lib/lemon/cli.rb
|
|
11
|
-
lib/lemon/core_ext/kernel.rb
|
|
12
|
-
lib/lemon/core_ext/omission.rb
|
|
13
|
-
lib/lemon/core_ext.rb
|
|
14
|
-
lib/lemon/coverage/analyzer.rb
|
|
15
|
-
lib/lemon/coverage/cover_unit.rb
|
|
16
|
-
lib/lemon/coverage/formats/abstract.rb
|
|
17
|
-
lib/lemon/coverage/formats/compact.rb
|
|
18
|
-
lib/lemon/coverage/formats/outline.rb
|
|
19
|
-
lib/lemon/coverage/formats/verbose.rb
|
|
20
|
-
lib/lemon/coverage/formats/yaml.rb
|
|
21
|
-
lib/lemon/coverage/snapshot.rb
|
|
22
|
-
lib/lemon/coverage/source_parser.rb
|
|
23
|
-
lib/lemon/generator.rb
|
|
24
|
-
lib/lemon/test_advice.rb
|
|
25
|
-
lib/lemon/test_case.rb
|
|
26
|
-
lib/lemon/test_class.rb
|
|
27
|
-
lib/lemon/test_method.rb
|
|
28
|
-
lib/lemon/test_module.rb
|
|
29
|
-
lib/lemon/test_proc.rb
|
|
30
|
-
lib/lemon/test_setup.rb
|
|
31
|
-
lib/lemon/test_world.rb
|
|
32
|
-
lib/lemon.rb
|
|
33
|
-
lib/lemon.yml
|
|
34
|
-
spec/applique/fs.rb
|
|
35
|
-
spec/coverage/01_complete.rdoc
|
|
36
|
-
spec/coverage/02_incomplete.rdoc
|
|
37
|
-
spec/coverage/03_extensions.rdoc
|
|
38
|
-
spec/coverage/applique/lemon.rb
|
|
39
|
-
try/.test
|
|
40
|
-
try/case_error.rb
|
|
41
|
-
try/case_fail.rb
|
|
42
|
-
try/case_pass.rb
|
|
43
|
-
try/case_pending.rb
|
|
44
|
-
try/case_singleton.rb
|
|
45
|
-
try/case_untested.rb
|
|
46
|
-
try/fixtures/calculator.rb
|
|
47
|
-
try/fixtures/example-use.rb
|
|
48
|
-
try/fixtures/example.rb
|
|
49
|
-
try/helpers/loadpath.rb
|
|
50
|
-
HISTORY.rdoc
|
|
51
|
-
PROFILE
|
|
52
|
-
QED.rdoc
|
|
53
|
-
README.md
|
|
54
|
-
VERSION
|
|
55
|
-
COPYING.rdoc
|
data/PROFILE
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title : Lemon
|
|
3
|
-
summary: Pucker-tight Unit Testing
|
|
4
|
-
authors:
|
|
5
|
-
- Thomas Sawyer <transfire@gmail.com>
|
|
6
|
-
|
|
7
|
-
description:
|
|
8
|
-
Lemon is a unit testing framework that tightly correlates
|
|
9
|
-
class to test case and method to test unit.
|
|
10
|
-
|
|
11
|
-
resources:
|
|
12
|
-
home: http://rubyworks.github.com/lemon
|
|
13
|
-
code: http://github.com/rubyworks/lemon
|
|
14
|
-
|
|
15
|
-
repositories:
|
|
16
|
-
origin: git://github.com/proutils/lemon.git
|
|
17
|
-
|
|
18
|
-
requirements:
|
|
19
|
-
- test
|
|
20
|
-
- ae
|
|
21
|
-
- ansi 1.3+
|
|
22
|
-
- detroit (build)
|
|
23
|
-
- reap (build)
|
|
24
|
-
- qed (test)
|
|
25
|
-
|
|
26
|
-
organization: RubyWorks
|
|
27
|
-
|
|
28
|
-
copyright: Copyright 2009 Thomas Sawyer
|
|
29
|
-
license: BSD-2-Clause
|
|
30
|
-
|
data/Rakefile
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'test/rake'
|
|
4
|
-
|
|
5
|
-
Test::Rake::TestTask.new do |t|
|
|
6
|
-
t.libs << 'test/fixtures'
|
|
7
|
-
t.tests << 'test/*.rb'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
namespace :test do
|
|
11
|
-
|
|
12
|
-
desc 'run lemon unit tests (via shell command)'
|
|
13
|
-
task :unit do
|
|
14
|
-
sh 'lemonade test -Itest/fixtures test/*.rb'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
desc 'run qed demonstration tests'
|
|
18
|
-
task :qed do
|
|
19
|
-
sh 'qed -Ilib spec/'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.9.0
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# The Omission class is a subclass of NotImplementedError with
|
|
2
|
-
# it's assertion flag set to true. This will be recognized by
|
|
3
|
-
# Ruby Test as a test omission.
|
|
4
|
-
#
|
|
5
|
-
# @example
|
|
6
|
-
# test "some feature" do
|
|
7
|
-
# raise Omission, "feature can't be tested"
|
|
8
|
-
# end
|
|
9
|
-
#
|
|
10
|
-
class Omission < NotImplementedError
|
|
11
|
-
def assertion?
|
|
12
|
-
true
|
|
13
|
-
end
|
|
14
|
-
def to_proc
|
|
15
|
-
error = self
|
|
16
|
-
lambda{ raise error }
|
|
17
|
-
end
|
|
18
|
-
end
|
data/lib/lemon/generator.rb
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
module Lemon
|
|
2
|
-
|
|
3
|
-
require 'lemon/coverage/analyzer'
|
|
4
|
-
|
|
5
|
-
#--
|
|
6
|
-
# TODO: Generator options for selecting all, covered and uncovered still
|
|
7
|
-
# need some clarification.
|
|
8
|
-
#++
|
|
9
|
-
|
|
10
|
-
# Test Scaffold Generator.
|
|
11
|
-
#
|
|
12
|
-
class Generator
|
|
13
|
-
|
|
14
|
-
# New Scaffold Generator.
|
|
15
|
-
#
|
|
16
|
-
# @option options [Array] :namespaces
|
|
17
|
-
# List of class/module names to limit scaffolding.
|
|
18
|
-
#
|
|
19
|
-
# @option options [Boolean] :private
|
|
20
|
-
# Include private methods in scaffolding.
|
|
21
|
-
#
|
|
22
|
-
# @option options [Boolean] :covered
|
|
23
|
-
# Include covered targets in scaffolding.
|
|
24
|
-
#
|
|
25
|
-
# @option options [Boolean] :uncovered
|
|
26
|
-
# Include uncovered targets in scaffolding.
|
|
27
|
-
#
|
|
28
|
-
# @option options [Boolean] :all
|
|
29
|
-
# Include all possible targets in scaffolding.
|
|
30
|
-
#
|
|
31
|
-
def initialize(files, options={})
|
|
32
|
-
@files = files
|
|
33
|
-
|
|
34
|
-
@coverage = CoverageAnalyzer.new(files, options)
|
|
35
|
-
@suite = @coverage.suite
|
|
36
|
-
|
|
37
|
-
@namespaces = options[:namespaces]
|
|
38
|
-
@private = options[:private]
|
|
39
|
-
@covered = options[:covered]
|
|
40
|
-
@uncovered = options[:uncovered]
|
|
41
|
-
@all = options[:all]
|
|
42
|
-
|
|
43
|
-
if @namespaces
|
|
44
|
-
unless @covered or @uncovered
|
|
45
|
-
@all = true
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Returns CoverageAnalyzer instance.
|
|
52
|
-
def coverage
|
|
53
|
-
@coverage
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# List of class and module namespaces to limit scaffolding.
|
|
57
|
-
def namespaces
|
|
58
|
-
@namespaces
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Include all targets.
|
|
62
|
-
def all?
|
|
63
|
-
@all
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Include targets that are already covered.
|
|
67
|
-
def covered?
|
|
68
|
-
@covered
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Include only uncovered targrts.
|
|
72
|
-
def uncovered?
|
|
73
|
-
@uncovered
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Include private and protected methods.
|
|
77
|
-
def private?
|
|
78
|
-
@private
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Generate test template(s).
|
|
82
|
-
def generate
|
|
83
|
-
if all?
|
|
84
|
-
generate_all
|
|
85
|
-
elsif uncovered?
|
|
86
|
-
generate_uncovered
|
|
87
|
-
else
|
|
88
|
-
generate_target
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Generate code template for covered.
|
|
93
|
-
def generate_target
|
|
94
|
-
render(filter(coverage.target.units))
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Generate code template for uncovered.
|
|
98
|
-
def generate_uncovered
|
|
99
|
-
render(filter(coverage.uncovered))
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# Generate code template for all.
|
|
103
|
-
def generate_all
|
|
104
|
-
render(Snapshot.capture(namespaces).units)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# Filter targets to include only specified namespaces.
|
|
108
|
-
def filter(units)
|
|
109
|
-
return units if namespaces.nil? or namespaces.empty?
|
|
110
|
-
units.select do |u|
|
|
111
|
-
namespaces.any? do |ns|
|
|
112
|
-
/^#{ns}/ =~ u.namespace.to_s
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Generate code template.
|
|
118
|
-
def render(units)
|
|
119
|
-
code = []
|
|
120
|
-
mods = units.group_by{ |u| u.namespace }
|
|
121
|
-
mods.each do |mod, units|
|
|
122
|
-
if Class === mod
|
|
123
|
-
code << "TestClass #{mod} do"
|
|
124
|
-
else
|
|
125
|
-
code << "TestModule #{mod} do"
|
|
126
|
-
end
|
|
127
|
-
units.each do |unit|
|
|
128
|
-
next unless private? or unit.public?
|
|
129
|
-
if unit.function?
|
|
130
|
-
code << "\n ClassMethod :#{unit.method} do"
|
|
131
|
-
code << "\n Test '' do"
|
|
132
|
-
code << "\n end"
|
|
133
|
-
code << "end"
|
|
134
|
-
else
|
|
135
|
-
code << "\n Method :#{unit.method} do"
|
|
136
|
-
code << "\n Test '' do"
|
|
137
|
-
code << "\n end"
|
|
138
|
-
code << "\n end"
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
code << "\nend\n"
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
code.join("\n")
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
end
|
data/lib/lemon.yml
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
authors:
|
|
3
|
-
- name: Thomas Sawyer
|
|
4
|
-
email: transfire@gmail.com
|
|
5
|
-
copyrights:
|
|
6
|
-
- holder: Thomas Sawyer
|
|
7
|
-
year: '2009'
|
|
8
|
-
license: BSD-2-Clause
|
|
9
|
-
replacements: []
|
|
10
|
-
conflicts: []
|
|
11
|
-
requirements:
|
|
12
|
-
- name: test
|
|
13
|
-
- name: ae
|
|
14
|
-
- name: ansi
|
|
15
|
-
version: 1.3+
|
|
16
|
-
- name: detroit
|
|
17
|
-
groups:
|
|
18
|
-
- build
|
|
19
|
-
development: true
|
|
20
|
-
- name: reap
|
|
21
|
-
groups:
|
|
22
|
-
- build
|
|
23
|
-
development: true
|
|
24
|
-
- name: qed
|
|
25
|
-
groups:
|
|
26
|
-
- test
|
|
27
|
-
development: true
|
|
28
|
-
dependencies: []
|
|
29
|
-
repositories:
|
|
30
|
-
- uri: git://github.com/proutils/lemon.git
|
|
31
|
-
scm: git
|
|
32
|
-
name: origin
|
|
33
|
-
resources:
|
|
34
|
-
home: http://rubyworks.github.com/lemon
|
|
35
|
-
code: http://github.com/rubyworks/lemon
|
|
36
|
-
load_path:
|
|
37
|
-
- lib
|
|
38
|
-
extra:
|
|
39
|
-
manifest: MANIFEST
|
|
40
|
-
alternatives: []
|
|
41
|
-
revision: 0
|
|
42
|
-
title: Lemon
|
|
43
|
-
summary: Pucker-tight Unit Testing
|
|
44
|
-
description: Lemon is a unit testing framework that tightly correlates class to test
|
|
45
|
-
case and method to test unit.
|
|
46
|
-
organization: RubyWorks
|
|
47
|
-
version: 0.9.0
|
|
48
|
-
name: lemon
|
|
49
|
-
date: '2011-08-11'
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
= 2010-05-05 Getting Good Coverage
|
|
2
|
-
|
|
3
|
-
Getting good coverage analysis is not easy. The difficulty comes
|
|
4
|
-
is determining what is of interest to the tests and what
|
|
5
|
-
is not. That isn't so hard with completely new code, but
|
|
6
|
-
core extensions, for instance, are challenging to isolate
|
|
7
|
-
from original methods.
|
|
8
|
-
|
|
9
|
-
Thee issue can mostly be taken care of by taking a canonical
|
|
10
|
-
snapshot of the system before loading the tests. Then taking
|
|
11
|
-
a snapshot after loading the tests and comparing the two.
|
|
12
|
-
For the most part the difference will be the code in need of
|
|
13
|
-
coverage.
|
|
14
|
-
|
|
15
|
-
Unfortunately helper code still gets in the way of taking these
|
|
16
|
-
snapshots. As a result I have determined there are only four
|
|
17
|
-
possible complete solutions.
|
|
18
|
-
|
|
19
|
-
1) Use a Ruby lexer/parser to syntatically deconstruct the
|
|
20
|
-
target libraries. This is a complex solution, and not one
|
|
21
|
-
I relish trying.
|
|
22
|
-
|
|
23
|
-
2) All helpers must go in special files that are preloaded so
|
|
24
|
-
the snapshot can isolate it from the actual target code. This
|
|
25
|
-
means any mocks, for instance, would have to be defined in
|
|
26
|
-
separate files for the the test(s) that might use them. This
|
|
27
|
-
solution it good in that it actually encourges the writing
|
|
28
|
-
reusable helper code, but it can be annoying when writting
|
|
29
|
-
one-off mocks and such.
|
|
30
|
-
|
|
31
|
-
3) As an alternate to #2, Lemon could provide a method
|
|
32
|
-
for specifying that a class/module or method is a helper
|
|
33
|
-
and can simply be ignored when analysing coverage.
|
|
34
|
-
|
|
35
|
-
4) Lastly, the library file being covered can be specified
|
|
36
|
-
with a special method, e.g. #Covers. The method would act
|
|
37
|
-
just like +#require+ except that it takes a snapshot before and
|
|
38
|
-
after the loading the library, and in this way builds up
|
|
39
|
-
a table of proper coverage targets.
|
|
40
|
-
|
|
41
|
-
Options #2 and #3 have proven lack luster. It's simply too
|
|
42
|
-
much overhead involved to get good coverage. Option #4 is the most
|
|
43
|
-
robust choice. Unfortunately coverage reports can be very slow
|
|
44
|
-
if there are lot of files to cover --Snapshots can take a second
|
|
45
|
-
or two to create. Hopefully it can be sped up with refinement,
|
|
46
|
-
but at the very least the coverage reporting if optional.
|
|
47
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
= 2010-05-06 Files, Not Classes
|
|
2
|
-
|
|
3
|
-
Just had a realization about my approch to Lemon tests.
|
|
4
|
-
Until now I have equated the test-case to the class/module
|
|
5
|
-
and the test-unit to the method. That makes sense, but it means
|
|
6
|
-
I have left out a very important factor in the the design
|
|
7
|
-
of tests: the file.
|
|
8
|
-
|
|
9
|
-
I had defined a test-suite as the entire set of tests to
|
|
10
|
-
be run. But I think now I am mistaken. The suite should
|
|
11
|
-
correspond to the fiel being tested. Often that will mean
|
|
12
|
-
one test-case per test-suite, but that's okay.
|
|
13
|
-
|
|
14
|
-
After the next release, 0.7.0, I will implement this
|
|
15
|
-
refactorization. I beleive it should ultimately help
|
|
16
|
-
improve test coverage as well.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
= 2010-07-11 | Kool-Aid
|
|
2
|
-
|
|
3
|
-
Taking Unit Testing to the next level with a dab of DBC.
|
|
4
|
-
|
|
5
|
-
Say we have,
|
|
6
|
-
|
|
7
|
-
class K
|
|
8
|
-
|
|
9
|
-
def f1(a1)
|
|
10
|
-
g1(a1)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def g1(a1)
|
|
14
|
-
a1 + 1
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
Now what do we want to say about K#f1?
|
|
20
|
-
|
|
21
|
-
unit K, :f1 do |a|
|
|
22
|
-
case a
|
|
23
|
-
when 1
|
|
24
|
-
result do |r|
|
|
25
|
-
r.assert == 2
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Now later we induce labor.
|
|
31
|
-
|
|
32
|
-
k = K.new
|
|
33
|
-
k.f1(1)
|
|
34
|
-
|
|
35
|
-
It does't really matter what the result class contains, or how it
|
|
36
|
-
even gets called. Thus it can test side-effects as well as simple
|
|
37
|
-
functional results.
|
|
38
|
-
|
|
39
|
-
Okay, so how do we implement this?
|
|
40
|
-
|
|
41
|
-
class K
|
|
42
|
-
|
|
43
|
-
alias "f1:lemon", :f1
|
|
44
|
-
|
|
45
|
-
def f1(a1)
|
|
46
|
-
Lemon.verify_unit(binding) do
|
|
47
|
-
send("f1:lemon", a1)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
2010-08-02 | Enforcing the Unit
|
|
2
|
-
|
|
3
|
-
The current API for creating a Lemon unit testcase looks like this:
|
|
4
|
-
|
|
5
|
-
covers 'someclass'
|
|
6
|
-
|
|
7
|
-
testcase SomeClass do
|
|
8
|
-
|
|
9
|
-
unit :some_method => "does something or another" do
|
|
10
|
-
# ...
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
As it currentlt standa the current design is little more than a means of
|
|
16
|
-
organization, orienting the developer to think in terms of test units.
|
|
17
|
-
What is does not do is enforce the actual testing the the unit referenced.
|
|
18
|
-
We could put any old mess in the unit block and as long as it did not raise
|
|
19
|
-
an exception, it would get a *pass*.
|
|
20
|
-
|
|
21
|
-
Taking some time to consider this in depth, I've concieved of a way in which
|
|
22
|
-
that use of the method could in fact be enforced.
|
|
23
|
-
|
|
24
|
-
covers 'someclass'
|
|
25
|
-
|
|
26
|
-
testcase SomeClass do
|
|
27
|
-
|
|
28
|
-
setup do
|
|
29
|
-
SomeClass.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
unit :some_method => "does something or another" do |unit|
|
|
33
|
-
unit.object # object from setup
|
|
34
|
-
unit.call(...) # calls #some_method on unit.object
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
What is intersting about this, beyond that fact that it enforces the use of
|
|
40
|
-
the class or module and method involved, but that it also does so in
|
|
41
|
-
a way naturally suited to mocking --the `unit` delegator could even have
|
|
42
|
-
mocking methods built-in.
|
|
43
|
-
|
|
44
|
-
unit :some_method => "does something or another" do |unit|
|
|
45
|
-
unit.receives.foo(:bar) # object from setup would receive this call
|
|
46
|
-
unit.returns(:baz) # the subsequent #call will return this
|
|
47
|
-
unit.call(...) # calls #some_method on unit.object
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
On the downside this approach limits what can be done in the unit block.
|
|
51
|
-
One _has_ to utilize the object as defined in `setup` and one _has_ to invoke
|
|
52
|
-
the unit method via the `#call` interface. Though, I suppose one could argue
|
|
53
|
-
that these limitations are a good thing, as they help the unit stay narrowly
|
|
54
|
-
focused on that goal at hand.
|
|
55
|
-
|
|
56
|
-
I think this approach is worth considering for a possible furture version.
|
|
57
|
-
Perhaps a "Lemon 2.0". For the time being I believe we can enforce the unit
|
|
58
|
-
without resorting this major API change.
|
|
59
|
-
|
|
60
|
-
The next release of Lemon will temporarily override the unit method on the
|
|
61
|
-
target class for each unit execution. If the unit method gets called within
|
|
62
|
-
the unit block, then it will be noted by the overridden method before passing
|
|
63
|
-
off to the original definition. The approach is perhaps a bit draconian, and
|
|
64
|
-
is certainly only possible thanks to the remarkable dynamicism of Ruby, but
|
|
65
|
-
it should work perfectly well. So now, if the target method is not called within
|
|
66
|
-
the taget block, the unit will raise a Pending exception, regardless of the
|
|
67
|
-
code in the block. Unit Enforced!
|
|
68
|
-
|
data/notes/2010-08-03-new-api.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# 2010-08-03 | A New API
|
|
2
|
-
|
|
3
|
-
Simplified API. There is one main method.
|
|
4
|
-
|
|
5
|
-
unit_test SomeClass, :some_method, "description" do
|
|
6
|
-
# test ...
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
It will be a global method. The block notations would still work, but
|
|
10
|
-
they would simple become wrappers for the main method.
|
|
11
|
-
|
|
12
|
-
testcase SomeClass do
|
|
13
|
-
|
|
14
|
-
unit :some_method, "description" do
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
If I can make it backward compatible, I may also allow something like:
|
|
21
|
-
|
|
22
|
-
testcase SomeClass do
|
|
23
|
-
|
|
24
|
-
unit :some_method do
|
|
25
|
-
|
|
26
|
-
concern "description" do
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
By using this global method, I should be able to simplify the underlying
|
|
35
|
-
implementation a great deal, which has been major concern about Lemon
|
|
36
|
-
as of late.
|
|
37
|
-
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# 2011-07-07 | Nailing Down the Nomenclature
|
|
2
|
-
|
|
3
|
-
I have finally settled on `test_class` and `test_module` as thew new toplevel method for defining Lemon test cases. I decided against reusing `test_case` from Citron b/c I determined it is best that these types of test cases not be mixed together, but rather stay cleanly separated.
|
|
4
|
-
|
|
5
|
-
I also decided against the original KO inspired nomenclature of `Test.case`. Though it looks very cool at first glance, in the end it goes against the grain. For instance, would one design an RSpec-stlye nomenclature as `Test.describe`, or a Cucumber-style nomenclature using `Test.feature`? While one could do so, it's completely uneccessry.
|
|
6
|
-
|