lemon 0.8.1 → 0.8.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.
Files changed (79) hide show
  1. data/HISTORY.rdoc +15 -0
  2. data/README.rdoc +32 -14
  3. data/bin/lemon +3 -2
  4. data/demo/case_example_fail.rb +15 -0
  5. data/demo/case_example_pass.rb +32 -0
  6. data/demo/case_example_pending.rb +14 -0
  7. data/demo/case_example_untested.rb +10 -0
  8. data/demo/fixture/example-use.rb +5 -0
  9. data/demo/fixture/example.rb +20 -0
  10. data/lib/lemon.rb +2 -2
  11. data/lib/lemon/cli.rb +281 -0
  12. data/lib/lemon/controller/coverage_analyzer.rb +343 -0
  13. data/lib/lemon/controller/scaffold_generator.rb +110 -0
  14. data/lib/lemon/controller/test_runner.rb +284 -0
  15. data/lib/lemon/meta/data.rb +29 -0
  16. data/lib/lemon/meta/gemfile +24 -0
  17. data/{PROFILE → lib/lemon/meta/profile} +6 -5
  18. data/lib/lemon/model/ae.rb +4 -0
  19. data/lib/lemon/model/cover_unit.rb +75 -0
  20. data/lib/lemon/{dsl.rb → model/main.rb} +22 -28
  21. data/lib/lemon/model/pending.rb +10 -0
  22. data/lib/lemon/model/snapshot.rb +203 -0
  23. data/lib/lemon/model/source_parser.rb +198 -0
  24. data/lib/lemon/model/test_case.rb +221 -0
  25. data/lib/lemon/model/test_context.rb +90 -0
  26. data/lib/lemon/model/test_suite.rb +216 -0
  27. data/lib/lemon/{test/unit.rb → model/test_unit.rb} +40 -28
  28. data/lib/lemon/{coversheet → view/cover_reports}/abstract.rb +19 -20
  29. data/lib/lemon/view/cover_reports/compact.rb +37 -0
  30. data/lib/lemon/view/cover_reports/outline.rb +45 -0
  31. data/lib/lemon/view/cover_reports/verbose.rb +51 -0
  32. data/lib/lemon/view/cover_reports/yaml.rb +15 -0
  33. data/lib/lemon/view/test_reports/abstract.rb +149 -0
  34. data/lib/lemon/view/test_reports/dotprogress.rb +73 -0
  35. data/lib/lemon/view/test_reports/html.rb +146 -0
  36. data/lib/lemon/view/test_reports/outline.rb +118 -0
  37. data/lib/lemon/view/test_reports/summary.rb +131 -0
  38. data/lib/lemon/view/test_reports/tap.rb +49 -0
  39. data/lib/lemon/view/test_reports/verbose.rb +197 -0
  40. data/meta/data.rb +29 -0
  41. data/meta/gemfile +24 -0
  42. data/meta/profile +17 -0
  43. data/test/api/applique/fs.rb +18 -0
  44. data/test/api/coverage/complete.rdoc +136 -0
  45. data/test/api/coverage/extensions.rdoc +61 -0
  46. data/test/api/coverage/incomplete.rdoc +97 -0
  47. data/{features → test/cli}/coverage.feature +4 -4
  48. data/{features → test/cli}/generate.feature +2 -2
  49. data/{features → test/cli}/step_definitions/coverage_steps.rb +0 -0
  50. data/{features → test/cli}/support/ae.rb +0 -0
  51. data/{features → test/cli}/support/aruba.rb +0 -0
  52. data/{features → test/cli}/test.feature +0 -0
  53. data/test/fixtures/case_complete.rb +17 -4
  54. data/test/fixtures/case_inclusion.rb +18 -0
  55. data/test/fixtures/case_incomplete.rb +4 -4
  56. data/test/fixtures/example.rb +5 -0
  57. data/test/fixtures/helper.rb +13 -0
  58. data/test/runner +3 -0
  59. data/test/unit/case_coverage_analyzer.rb +25 -0
  60. data/test/unit/case_test_case_dsl.rb +46 -0
  61. metadata +87 -42
  62. data/REQUIRE +0 -9
  63. data/VERSION +0 -6
  64. data/lib/lemon/command.rb +0 -184
  65. data/lib/lemon/coverage.rb +0 -260
  66. data/lib/lemon/coversheet/outline.rb +0 -47
  67. data/lib/lemon/kernel.rb +0 -24
  68. data/lib/lemon/reporter.rb +0 -22
  69. data/lib/lemon/reporter/abstract.rb +0 -97
  70. data/lib/lemon/reporter/dotprogress.rb +0 -68
  71. data/lib/lemon/reporter/outline.rb +0 -105
  72. data/lib/lemon/reporter/verbose.rb +0 -143
  73. data/lib/lemon/runner.rb +0 -308
  74. data/lib/lemon/snapshot.rb +0 -185
  75. data/lib/lemon/test/case.rb +0 -139
  76. data/lib/lemon/test/concern.rb +0 -52
  77. data/lib/lemon/test/suite.rb +0 -229
  78. data/test/case_coverage.rb +0 -26
  79. data/test/case_testcase.rb +0 -58
@@ -1,68 +0,0 @@
1
- module Lemon
2
- module Reporter
3
- require 'lemon/reporter/abstract'
4
-
5
- # Generic Reporter
6
- class DotProgress < Abstract
7
-
8
- def report_start(suite)
9
- end
10
-
11
- def report_concern(concern)
12
- end
13
-
14
- def report_success(testunit)
15
- print "."; $stdout.flush
16
- end
17
-
18
- def report_failure(testunit, exception)
19
- print "F"
20
- end
21
-
22
- def report_error(testunit, exception)
23
- print "E"
24
- end
25
-
26
- def report_pending(testunit, exception)
27
- print "P"
28
- end
29
-
30
- def report_finish #(successes, failures, errors, pendings)
31
- puts; puts
32
-
33
- unless failures.empty?
34
- puts "FAILURES:\n\n"
35
- failures.each do |testunit, exception|
36
- puts " #{testunit}"
37
- puts " #{exception}"
38
- puts " #{exception.backtrace[0]}"
39
- puts
40
- end
41
- end
42
-
43
- unless errors.empty?
44
- puts "ERRORS:\n\n"
45
- errors.each do |testunit, exception|
46
- puts " #{testunit}"
47
- puts " #{exception}"
48
- puts " #{exception.backtrace[0]}"
49
- puts
50
- end
51
- end
52
-
53
- unless pendings.empty?
54
- puts "PENDING:\n\n"
55
- pendings.each do |testunit, exception|
56
- puts " #{testunit}"
57
- end
58
- puts
59
- end
60
-
61
- puts tally
62
- end
63
-
64
- end
65
-
66
- end
67
- end
68
-
@@ -1,105 +0,0 @@
1
- module Lemon
2
- module Reporter
3
- require 'lemon/reporter/abstract'
4
-
5
- # Outline Reporter
6
- class Outline < Abstract
7
-
8
- #
9
- def report_start(suite)
10
- end
11
-
12
- #
13
- def report_concern(concern)
14
- puts
15
- puts "#{concern.description}\n\n" unless concern.description.empty?
16
- end
17
-
18
- #
19
- def report_success(testunit)
20
- puts green("* #{testunit}")
21
- end
22
-
23
- #
24
- def report_failure(testunit, exception)
25
- puts red("* #{testunit} (FAILURE)")
26
- #puts
27
- #puts " FAIL #{exception.backtrace[0]}"
28
- #puts " #{exception}"
29
- #puts
30
- end
31
-
32
- #
33
- def report_error(testunit, exception)
34
- puts red("* #{testunit} (ERROR)")
35
- #puts
36
- #puts " ERROR #{exception.backtrace[0]}"
37
- #puts " #{exception}"
38
- #puts
39
- end
40
-
41
- #
42
- def report_pending(testunit, exception)
43
- puts yellow("* #{testunit} (PENDING)")
44
- #puts
45
- #puts " PENDING #{exception.backtrace[0]}"
46
- #puts
47
- end
48
-
49
- #
50
- def report_finish
51
- puts
52
-
53
- unless failures.empty?
54
- puts "FAILURES:\n\n"
55
- failures.each do |testunit, exception|
56
- puts " #{testunit}"
57
- puts " #{exception}"
58
- puts " #{exception.backtrace[0]}"
59
- puts
60
- end
61
- end
62
-
63
- unless errors.empty?
64
- puts "ERRORS:\n\n"
65
- errors.each do |testunit, exception|
66
- puts " #{testunit}"
67
- puts " #{exception}"
68
- puts " #{exception.backtrace[0]}"
69
- puts
70
- end
71
- end
72
-
73
- #unless pendings.empty?
74
- # puts "PENDING:\n\n"
75
- # pendings.each do |testunit, exception|
76
- # puts " #{testunit}"
77
- # end
78
- #end
79
-
80
- unless uncovered.empty?
81
- puts "UNCOVERED:\n\n"
82
- unc = uncovered.map do |testunit|
83
- yellow("* " +testunit.join('#'))
84
- end.join("\n")
85
- puts unc
86
- puts
87
- end
88
-
89
- unless undefined.empty?
90
- puts "UNDEFINED:\n\n"
91
- unc = undefined.map do |testunit|
92
- yellow("* " + testunit.join('#'))
93
- end.join("\n")
94
- puts unc
95
- puts
96
- end
97
-
98
- puts tally
99
- end
100
-
101
- end
102
-
103
- end
104
- end
105
-
@@ -1,143 +0,0 @@
1
- module Lemon
2
- module Reporter
3
- require 'lemon/reporter/abstract'
4
-
5
- # Verbose Reporter
6
- class Verbose < Abstract
7
-
8
- #
9
- def report_start(suite)
10
- timer_reset
11
- end
12
-
13
- #
14
- def report_concern(concern)
15
- puts
16
- puts "== #{concern.description}\n\n" unless concern.description.empty?
17
- timer_reset
18
- end
19
-
20
- #
21
- def report_success(testunit)
22
- puts "%12s %s %s" % [timer, green("SUCCESS"), green("#{testunit}")]
23
- end
24
-
25
- #
26
- def report_failure(testunit, exception)
27
- puts "%12s %s %s" % [timer, red("FAILURE"), red("#{testunit}")]
28
- puts
29
- puts " FAIL #{exception.backtrace[0]}"
30
- puts " #{exception}"
31
- puts
32
- end
33
-
34
- #
35
- def report_error(testunit, exception)
36
- puts "%12s %s %s" % [timer, red("ERRORED"), red("#{testunit}")]
37
- puts
38
- puts " ERROR #{exception.backtrace[0]}"
39
- puts " #{exception}"
40
- puts
41
- end
42
-
43
- #
44
- def report_pending(testunit, exception)
45
- puts "%12s %s %s" % [timer, yellow("PENDING"), yellow("#{testunit}")]
46
- #puts
47
- #puts " PENDING #{exception.backtrace[1]}"
48
- #puts
49
- end
50
-
51
- #
52
- def report_finish
53
- #puts
54
-
55
- #unless failures.empty?
56
- # puts "FAILURES:\n\n"
57
- # failures.each do |testunit, exception|
58
- # puts " #{testunit}"
59
- # puts " #{exception}"
60
- # puts " #{exception.backtrace[0]}"
61
- # puts
62
- # end
63
- #end
64
-
65
- #unless errors.empty?
66
- # puts "ERRORS:\n\n"
67
- # errors.each do |testunit, exception|
68
- # puts " #{testunit}"
69
- # puts " #{exception}"
70
- # puts " #{exception.backtrace[0]}"
71
- # puts
72
- # end
73
- #end
74
-
75
- #unless pendings.empty?
76
- # puts "PENDING:\n\n"
77
- # pendings.each do |testunit, exception|
78
- # puts " #{testunit}"
79
- # end
80
- # puts
81
- #end
82
-
83
- =begin
84
- if cover?
85
-
86
- unless uncovered_cases.empty?
87
- unc = uncovered_cases.map do |mod|
88
- yellow(mod.name)
89
- end.join(", ")
90
- puts "\nUncovered Cases: " + unc
91
- end
92
-
93
- unless uncovered_units.empty?
94
- unc = uncovered_units.map do |unit|
95
- yellow(unit)
96
- end.join(", ")
97
- puts "\nUncovered Units: " + unc
98
- end
99
-
100
- #unless uncovered.empty?
101
- # unc = uncovered.map do |unit|
102
- # yellow(unit)
103
- # end.join(", ")
104
- # puts "\nUncovered: " + unc
105
- #end
106
-
107
- unless undefined_units.empty?
108
- unc = undefined_units.map do |unit|
109
- yellow(unit)
110
- end.join(", ")
111
- puts "\nUndefined Units: " + unc
112
- end
113
-
114
- end
115
- =end
116
-
117
- #total = successes.size + failures.size + errors.size + pendings.size
118
- #tally = "\n#{total} tests: #{successes.size} pass, #{failures.size} fail, #{errors.size} err, #{pendings.size} pending"
119
- #if cover?
120
- # tally += " (#{uncovered.size} uncovered, #{undefined.size} undefined)"
121
- #end
122
-
123
- puts
124
- puts tally
125
- end
126
-
127
- #
128
- def timer
129
- secs = Time.now - @time
130
- @time = Time.now
131
- return "%0.5fs" % [secs.to_s]
132
- end
133
-
134
- #
135
- def timer_reset
136
- @time = Time.now
137
- end
138
-
139
- end
140
-
141
- end
142
- end
143
-
data/lib/lemon/runner.rb DELETED
@@ -1,308 +0,0 @@
1
- module Lemon
2
-
3
- require 'ae'
4
- require 'ae/expect'
5
- require 'ae/should'
6
-
7
- require 'lemon/kernel'
8
- require 'lemon/test/suite'
9
- require 'lemon/reporter'
10
-
11
- #
12
- class Runner
13
-
14
- # Test suite to run.
15
- attr :suite
16
-
17
- # Report format.
18
- attr :format
19
-
20
- # Record of successful tests.
21
- attr :successes
22
-
23
- # Record of failed tests.
24
- attr :failures
25
-
26
- # Record of errors.
27
- attr :errors
28
-
29
- # Record of pending tests.
30
- attr :pendings
31
-
32
- # New Runner.
33
- def initialize(suite, options={})
34
- @suite = suite
35
- @options = options
36
-
37
- @successes = []
38
- @failures = []
39
- @errors = []
40
- @pendings = []
41
- end
42
-
43
- #
44
- def format
45
- @options[:format]
46
- end
47
-
48
- #
49
- #def cover?
50
- # @options[:cover]
51
- #end
52
-
53
- # Namespaces option specifies the selection of test cases
54
- # to run. Is is an array of strings which are matched
55
- # against the module/class names using #start_wtih?
56
- def namespaces
57
- @options[:namespaces] || []
58
- end
59
-
60
- # Run tests.
61
- def run
62
- #prepare
63
-
64
- reporter.report_start(suite)
65
-
66
- each do |testcase|
67
- testcase.each do |concern|
68
- reporter.report_concern(concern)
69
- run_concern_procedures(concern, suite, testcase)
70
- concern.each do |testunit|
71
- #mark_coverage(testcase, testunit)
72
- run_pretest_procedures(testunit, suite, testcase)
73
- begin
74
- testunit.call
75
- reporter.report_success(testunit)
76
- successes << testunit
77
- rescue Pending => exception
78
- reporter.report_pending(testunit, exception)
79
- pendings << [testunit, exception]
80
- rescue Assertion => exception
81
- reporter.report_failure(testunit, exception)
82
- failures << [testunit, exception]
83
- rescue Exception => exception
84
- reporter.report_error(testunit, exception)
85
- errors << [testunit, exception]
86
- end
87
- run_postest_procedures(testunit, suite, testcase)
88
- end
89
- end
90
- end
91
-
92
- reporter.report_finish #(successes, failures, errors, pendings)
93
- end
94
-
95
- # Iterate overs suite testcases, filtering out unselected testcases
96
- # if any namespaces are provided.
97
- def each(&block)
98
- if namespaces.empty?
99
- suite.each do |testcase|
100
- block.call(testcase)
101
- end
102
- else
103
- suite.each do |testcase|
104
- next unless namespaces.any?{ |n| testcase.target.name.start_with?(n) }
105
- block.call(testcase)
106
- end
107
- end
108
- end
109
-
110
- # All output is handled by a reporter.
111
- def reporter
112
- @reporter ||= Reporter.factory(format, self)
113
- end
114
-
115
- #
116
- #def uncovered
117
- # c = []
118
- # @testcase_coverage.each do |testcase, testunits|
119
- # testunits.each do |testunit, coverage|
120
- # c << [testcase, testunit] if coverage == false
121
- # end
122
- # end
123
- # c
124
- #end
125
-
126
- =begin
127
- #
128
- def prepare
129
- if cover?
130
- coverage.canonical!
131
- end
132
-
133
- suite.load_covered_files
134
-
135
- if cover?
136
- @uncovered = calculate_uncovered
137
- @undefined = calculate_undefined
138
- end
139
- end
140
- =end
141
-
142
- =begin
143
- #
144
- def uncovered_cases
145
- @uncovered_cases ||= coverage.uncovered_cases
146
- end
147
-
148
- #
149
- def uncovered_units
150
- @uncovered_units ||= coverage.uncovered_units
151
- end
152
-
153
- #
154
- def undefined_units
155
- @undefined_units ||= coverage.undefined_units
156
- end
157
- =end
158
-
159
- =begin
160
- #
161
- def uncovered
162
- @uncovered ||= calculate_uncovered
163
- end
164
-
165
- #
166
- def undefined
167
- @undefined ||= calculate_undefined
168
- end
169
-
170
- #
171
- def calculate_uncovered
172
- uncovered_targets = []
173
- coverage.checklist.each do |mod, meths|
174
- meths.each do |meth, covered|
175
- if !covered
176
- if /^::/ =~ meth.to_s
177
- uncovered_targets << "#{mod}#{meth}"
178
- else
179
- uncovered_targets << "#{mod}##{meth}"
180
- end
181
- end
182
- end
183
- end
184
- uncovered_targets
185
- end
186
-
187
- #
188
- def calculate_undefined
189
- covered_testunits = successes + (failures + errors + pendings).map{ |tu, e| tu }
190
- covered_targets = covered_testunits.map{ |tu| tu.fullname }
191
-
192
- targets = []
193
- coverage.each do |mod, meths|
194
- meths.each do |meth, cov|
195
- if /^::/ =~ meth.to_s
196
- targets << "#{mod}#{meth}"
197
- else
198
- targets << "#{mod}##{meth}"
199
- end
200
- end
201
- end
202
-
203
- covered_targets - targets
204
- end
205
- =end
206
-
207
- private
208
-
209
- #
210
- def run_concern_procedures(concern, suite, testcase)
211
- suite.when_clauses.each do |match, block|
212
- if match.nil? or match === concern.to_s
213
- block.call(testcase)
214
- end
215
- end
216
- testcase.when_clauses.each do |match, block|
217
- if match.nil? or match === concern.to_s
218
- block.call(testcase) if match === concern.to_s
219
- end
220
- end
221
- concern.call
222
- end
223
-
224
- # Run pre-test advice.
225
- def run_pretest_procedures(testunit, suite, testcase)
226
- suite.before_clauses.each do |match, block|
227
- if match.nil? or testunit.match?(match)
228
- block.call(testunit)
229
- end
230
- end
231
- testcase.before_clauses.each do |match, block|
232
- if match.nil? or testunit.match?(match)
233
- block.call(testunit)
234
- end
235
- end
236
- end
237
-
238
- # Run post-test advice.
239
- def run_postest_procedures(testunit, suite, testcase)
240
- testcase.after_clauses.each do |match, block|
241
- if match.nil? or testunit.match?(match)
242
- block.call(testunit)
243
- end
244
- end
245
- suite.after_clauses.each do |match, block|
246
- if match.nil? or testunit.match?(match)
247
- block.call(testunit)
248
- end
249
- end
250
- end
251
-
252
- #def coverage
253
- # @coverage ||= Lemon::Coverage.new(suite, namespaces) #, :public => public_only?)
254
- #end
255
-
256
- =begin
257
- # TODO: I would think all this should be gained form the Coverage class.
258
-
259
- # TODO: options to include non-public and superclasses less Object and Kernel.
260
- def mark_coverage(testcase, testunit)
261
- testunit = testunit.target.to_sym
262
- profile = testcase_profile(testcase)
263
- coverage = testcase_coverage(testcase)
264
-
265
- if profile[:public].include?(testunit) || profile[:meta_public].include?(testunit)
266
- coverage[testunit] = :public
267
- elsif profile[:private].include?(testunit) || profile[:meta_private].include?(testunit)
268
- coverage[testunit] = :private
269
- elsif profile[:protected].include?(testunit) || profile[:meta_protected].include?(testunit)
270
- coverage[testunit] = :protected
271
- else
272
- coverage[testunit] = nil # nil means does not exist, while false means not covered.
273
- end
274
- end
275
-
276
- #
277
- def testcase_coverage(testcase)
278
- target = testcase.target
279
- @testcase_coverage ||= {}
280
- @testcase_coverage[target] ||= (
281
- h = {}
282
- target.public_instance_methods(false).each{|unit| h[unit] = false }
283
- (target.public_methods(false) - Object.public_methods(false)).each{|unit| h[unit] = false }
284
- #target.private_instance_method(false)
285
- #target.protected_instance_method(false)
286
- h
287
- )
288
- end
289
-
290
- #
291
- def testcase_profile(testcase)
292
- target = testcase.target
293
- @testcase_profile ||= {}
294
- @testcase_profile[target] ||= {
295
- :public => target.public_instance_methods(false).map{|s|s.to_sym},
296
- :private => target.private_instance_methods(false).map{|s|s.to_sym},
297
- :protected => target.protected_instance_methods(false).map{|s|s.to_sym},
298
- :meta_public => (target.public_methods(false) - Object.public_methods(false)).map{|s|s.to_sym},
299
- :meta_private => (target.private_methods(false) - Object.private_methods(false)).map{|s|s.to_sym},
300
- :meta_protected => (target.protected_methods(false)- Object.protected_methods(false)).map{|s|s.to_sym}
301
- }
302
- end
303
- =end
304
-
305
- end
306
-
307
- end
308
-