lemon 0.8.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,52 @@
|
|
1
|
+
module Lemon
|
2
|
+
|
3
|
+
module CLI
|
4
|
+
|
5
|
+
require 'lemon/cli/base'
|
6
|
+
|
7
|
+
# Coverage Command
|
8
|
+
class Coverage < Base
|
9
|
+
|
10
|
+
# Ouput coverage report.
|
11
|
+
def command_run(test_files)
|
12
|
+
require 'lemon/coverage/analyzer'
|
13
|
+
|
14
|
+
#loadpath = options[:loadpath] || []
|
15
|
+
#requires = options[:requires] || []
|
16
|
+
|
17
|
+
#loadpath.each{ |path| $LOAD_PATH.unshift(path) }
|
18
|
+
#requires.each{ |path| require(path) }
|
19
|
+
|
20
|
+
$stderr.print "Calculating... "
|
21
|
+
$stderr.flush
|
22
|
+
|
23
|
+
cover = Lemon::CoverageAnalyzer.new(test_files, options)
|
24
|
+
|
25
|
+
cover.calculate # this just helps calcs get done up front
|
26
|
+
|
27
|
+
$stderr.puts
|
28
|
+
|
29
|
+
cover.render
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
def command_parse(argv)
|
34
|
+
option_parser.banner = "Usage: lemonade coverage [options] [files ...]"
|
35
|
+
#option_parser.separator("Check test coverage.")
|
36
|
+
|
37
|
+
option_namespaces
|
38
|
+
option_private
|
39
|
+
option_zealous
|
40
|
+
option_output
|
41
|
+
option_format
|
42
|
+
option_loadpath
|
43
|
+
option_requires
|
44
|
+
|
45
|
+
option_parser.parse!(argv)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Lemon
|
2
|
+
|
3
|
+
module CLI
|
4
|
+
|
5
|
+
require 'lemon/cli/base'
|
6
|
+
|
7
|
+
# Generate Command
|
8
|
+
class Generate < Base
|
9
|
+
|
10
|
+
# Generate test templates.
|
11
|
+
def command_run(test_files)
|
12
|
+
require 'lemon/generator'
|
13
|
+
|
14
|
+
loadpath = options[:loadpath] || []
|
15
|
+
requires = options[:requires] || []
|
16
|
+
|
17
|
+
loadpath.each{ |path| $LOAD_PATH.unshift(path) }
|
18
|
+
requires.each{ |path| require(path) }
|
19
|
+
|
20
|
+
#cover = options[:uncovered]
|
21
|
+
#suite = Lemon::TestSuite.new(test_files, :cover=>cover) #, :cover_all=>true)
|
22
|
+
generator = Lemon::Generator.new(test_files, options)
|
23
|
+
|
24
|
+
#if uncovered
|
25
|
+
# puts cover.generate_uncovered #(output)
|
26
|
+
#else
|
27
|
+
puts generator.generate #(output)
|
28
|
+
#end
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
def command_parse(argv)
|
33
|
+
option_parser.banner = "Usage: lemonade generate [options] [files ...]"
|
34
|
+
#option_parser.separator("Generate test scaffolding.")
|
35
|
+
|
36
|
+
option_namespaces
|
37
|
+
option_covered
|
38
|
+
option_uncovered
|
39
|
+
option_all
|
40
|
+
option_private
|
41
|
+
option_loadpath
|
42
|
+
option_requires
|
43
|
+
|
44
|
+
option_parser.parse!(argv)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Lemon
|
2
|
+
|
3
|
+
module CLI
|
4
|
+
|
5
|
+
require 'lemon/cli/base'
|
6
|
+
|
7
|
+
# Test Command
|
8
|
+
class Test < Base
|
9
|
+
|
10
|
+
# Run unit tests.
|
11
|
+
def command_run(scripts)
|
12
|
+
require 'lemon/runner'
|
13
|
+
|
14
|
+
loadpath = options[:loadpath] || ['lib'] # + ['lib'] ?
|
15
|
+
requires = options[:requires] || []
|
16
|
+
|
17
|
+
loadpath.each{ |path| $LOAD_PATH.unshift(path) }
|
18
|
+
requires.each{ |path| require(path) }
|
19
|
+
|
20
|
+
#suite = Lemon::Test::Suite.new(files, :cover=>cover)
|
21
|
+
#runner = Lemon::Runner.new(suite, :format=>format, :cover=>cover, :namespaces=>namespaces)
|
22
|
+
|
23
|
+
runner = Lemon::TestRunner.new(
|
24
|
+
scripts, :format=>options[:format], :namespaces=>options[:namespaces]
|
25
|
+
)
|
26
|
+
|
27
|
+
success = runner.run
|
28
|
+
|
29
|
+
exit -1 unless success
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
def command_parse(argv)
|
34
|
+
option_parser.banner = "Usage: lemonade test [options] [files ...]"
|
35
|
+
#option_parser.separator("Run unit tests.")
|
36
|
+
|
37
|
+
option_format
|
38
|
+
option_verbose
|
39
|
+
option_namespaces
|
40
|
+
option_loadpath
|
41
|
+
option_requires
|
42
|
+
|
43
|
+
option_parser.parse!(argv)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kernel
|
2
|
+
|
3
|
+
unless method_defined?(:qua_class)
|
4
|
+
|
5
|
+
def qua_class(&block)
|
6
|
+
if block_given?
|
7
|
+
(class << self; self; end).class_eval(&block)
|
8
|
+
else
|
9
|
+
(class << self; self; end)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
alias :quaclass :qua_class
|
14
|
+
end
|
15
|
+
|
16
|
+
unless method_defined?(:singleton_class)
|
17
|
+
alias :singleton_class :quaclass
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'lemon
|
2
|
-
require 'lemon/
|
1
|
+
require 'lemon'
|
2
|
+
require 'lemon/coverage/snapshot'
|
3
3
|
|
4
4
|
module Lemon
|
5
5
|
|
@@ -38,13 +38,15 @@ module Lemon
|
|
38
38
|
|
39
39
|
@reporter = reporter_find(@format)
|
40
40
|
|
41
|
+
reset_suite
|
42
|
+
|
41
43
|
initialize_prerequisites(options)
|
42
44
|
|
43
|
-
@canonical
|
45
|
+
@canonical = Snapshot.capture #system #@suite.canonical
|
44
46
|
|
45
47
|
#@suite = Lemon.suite
|
46
|
-
|
47
|
-
Lemon.suite = @suite
|
48
|
+
#@suite = Lemon::TestSuite.new(files, :cover=>true) #@suite = suite
|
49
|
+
#Lemon.suite = @suite
|
48
50
|
|
49
51
|
files = files.map{ |f| Dir[f] }.flatten
|
50
52
|
files = files.map{ |f|
|
@@ -57,6 +59,8 @@ module Lemon
|
|
57
59
|
files = files.map{ |f| File.expand_path(f) }
|
58
60
|
|
59
61
|
files.each{ |s| load s } #require s }
|
62
|
+
|
63
|
+
@suite = $TEST_SUITE.dup
|
60
64
|
end
|
61
65
|
|
62
66
|
# Load in prerequisites
|
@@ -69,7 +73,14 @@ module Lemon
|
|
69
73
|
end
|
70
74
|
|
71
75
|
#
|
72
|
-
|
76
|
+
def reset_suite
|
77
|
+
$TEST_SUITE = []
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
def suite
|
82
|
+
@suite
|
83
|
+
end
|
73
84
|
|
74
85
|
# Paths of lemon tests and/or ruby scripts to be compared and covered.
|
75
86
|
# This can include directories too, in which case all .rb scripts below
|
@@ -131,19 +142,31 @@ module Lemon
|
|
131
142
|
def covered_units
|
132
143
|
@covered_units ||= (
|
133
144
|
list = []
|
134
|
-
suite.each do |
|
135
|
-
|
136
|
-
list << Snapshot::Unit.new(
|
137
|
-
unit.testcase.target,
|
138
|
-
unit.target,
|
139
|
-
:function=>unit.function?
|
140
|
-
)
|
141
|
-
end
|
145
|
+
suite.each do |test|
|
146
|
+
covered_unit(test, list)
|
142
147
|
end
|
143
148
|
list.uniq
|
144
149
|
)
|
145
150
|
end
|
146
151
|
|
152
|
+
#
|
153
|
+
def covered_unit(test, list)
|
154
|
+
case test
|
155
|
+
when Lemon::TestModule
|
156
|
+
test.each do |t|
|
157
|
+
covered_unit(t, list)
|
158
|
+
end
|
159
|
+
when Lemon::TestMethod
|
160
|
+
list << Snapshot::Unit.new(
|
161
|
+
test.context.target,
|
162
|
+
test.target,
|
163
|
+
:function=>test.function?
|
164
|
+
)
|
165
|
+
else
|
166
|
+
# ignore
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
147
170
|
#
|
148
171
|
def covered_namespaces
|
149
172
|
@covered_namespaces ||= covered_units.map{ |u| u.namespace }.uniq
|
@@ -325,19 +348,18 @@ module Lemon
|
|
325
348
|
/^#{format}/ =~ name
|
326
349
|
end
|
327
350
|
raise "unsupported format" unless format
|
328
|
-
require "lemon/
|
351
|
+
require "lemon/coverage/formats/#{format}"
|
329
352
|
reporter = Lemon::CoverReports.const_get(format.capitalize)
|
330
353
|
reporter.new(self)
|
331
354
|
end
|
332
355
|
|
333
356
|
#
|
334
357
|
def reporter_list
|
335
|
-
Dir[File.dirname(__FILE__) + '
|
358
|
+
Dir[File.dirname(__FILE__) + '/formats/*.rb'].map do |rb|
|
336
359
|
File.basename(rb).chomp('.rb')
|
337
360
|
end
|
338
361
|
end
|
339
362
|
|
340
|
-
end
|
341
|
-
|
342
|
-
end#module Lemon
|
363
|
+
end
|
343
364
|
|
365
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,12 +1,33 @@
|
|
1
|
-
require 'lemon/controller/coverage_analyzer'
|
2
|
-
|
3
1
|
module Lemon
|
4
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.
|
5
11
|
#
|
6
|
-
class
|
12
|
+
class Generator
|
7
13
|
|
8
14
|
# New Scaffold Generator.
|
9
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
|
+
#
|
10
31
|
def initialize(files, options={})
|
11
32
|
@files = files
|
12
33
|
|
@@ -15,8 +36,16 @@ module Lemon
|
|
15
36
|
|
16
37
|
@namespaces = options[:namespaces]
|
17
38
|
@private = options[:private]
|
39
|
+
@covered = options[:covered]
|
18
40
|
@uncovered = options[:uncovered]
|
19
41
|
@all = options[:all]
|
42
|
+
|
43
|
+
if @namespaces
|
44
|
+
unless @covered or @uncovered
|
45
|
+
@all = true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
20
49
|
end
|
21
50
|
|
22
51
|
# Returns CoverageAnalyzer instance.
|
@@ -24,22 +53,22 @@ module Lemon
|
|
24
53
|
@coverage
|
25
54
|
end
|
26
55
|
|
27
|
-
#
|
56
|
+
# List of class and module namespaces to limit scaffolding.
|
28
57
|
def namespaces
|
29
58
|
@namespaces
|
30
59
|
end
|
31
60
|
|
32
|
-
#
|
61
|
+
# Include all targets.
|
33
62
|
def all?
|
34
63
|
@all
|
35
64
|
end
|
36
65
|
|
37
|
-
#
|
66
|
+
# Include targets that are already covered.
|
38
67
|
def covered?
|
39
68
|
@covered
|
40
69
|
end
|
41
70
|
|
42
|
-
# Include only uncovered
|
71
|
+
# Include only uncovered targrts.
|
43
72
|
def uncovered?
|
44
73
|
@uncovered
|
45
74
|
end
|
@@ -60,22 +89,22 @@ module Lemon
|
|
60
89
|
end
|
61
90
|
end
|
62
91
|
|
63
|
-
#
|
92
|
+
# Generate code template for covered.
|
64
93
|
def generate_target
|
65
94
|
render(filter(coverage.target.units))
|
66
95
|
end
|
67
96
|
|
68
|
-
#
|
97
|
+
# Generate code template for uncovered.
|
69
98
|
def generate_uncovered
|
70
99
|
render(filter(coverage.uncovered))
|
71
100
|
end
|
72
101
|
|
73
|
-
# Generate code template.
|
102
|
+
# Generate code template for all.
|
74
103
|
def generate_all
|
75
104
|
render(Snapshot.capture(namespaces).units)
|
76
105
|
end
|
77
106
|
|
78
|
-
#
|
107
|
+
# Filter targets to include only specified namespaces.
|
79
108
|
def filter(units)
|
80
109
|
return units if namespaces.nil? or namespaces.empty?
|
81
110
|
units.select do |u|
|
@@ -90,13 +119,23 @@ module Lemon
|
|
90
119
|
code = []
|
91
120
|
mods = units.group_by{ |u| u.namespace }
|
92
121
|
mods.each do |mod, units|
|
93
|
-
|
122
|
+
if Class === mod
|
123
|
+
code << "TestClass #{mod} do"
|
124
|
+
else
|
125
|
+
code << "TestModule #{mod} do"
|
126
|
+
end
|
94
127
|
units.each do |unit|
|
95
128
|
next unless private? or unit.public?
|
96
129
|
if unit.function?
|
97
|
-
code << "\n
|
130
|
+
code << "\n ClassMethod :#{unit.method} do"
|
131
|
+
code << "\n Test '' do"
|
132
|
+
code << "\n end"
|
133
|
+
code << "end"
|
98
134
|
else
|
99
|
-
code << "\n
|
135
|
+
code << "\n Method :#{unit.method} do"
|
136
|
+
code << "\n Test '' do"
|
137
|
+
code << "\n end"
|
138
|
+
code << "\n end"
|
100
139
|
end
|
101
140
|
end
|
102
141
|
code << "\nend\n"
|