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
@@ -0,0 +1,118 @@
1
+ require 'lemon/view/test_reports/abstract'
2
+
3
+ module Lemon::TestReports
4
+
5
+ # Outline Reporter
6
+ class Outline < Abstract
7
+
8
+ #
9
+ def start_case(testcase)
10
+ puts "* #{testcase.target}".ansi(:bold)
11
+ end
12
+
13
+ #
14
+ def context(context)
15
+ if context
16
+ if context.to_s.empty?
17
+ puts " * general context")
18
+ else
19
+ puts " * #{context}"
20
+ end
21
+ else
22
+ puts " * general context"
23
+ end
24
+ end
25
+
26
+ #
27
+ def start_unit(unit)
28
+ instance = unit.instance
29
+ if @context != context
30
+ @context = context
31
+ context(context)
32
+ end
33
+ end
34
+
35
+ #
36
+ def pass(unit)
37
+ puts " * #{unit.name} #{unit.aspect}".ansi(:green)
38
+ end
39
+
40
+ #
41
+ def fail(unit, exception)
42
+ puts " * #{unit.name} #{unit.aspect} (FAIL)".ansi(:red)
43
+ end
44
+
45
+ #
46
+ def error(unit, exception)
47
+ puts " * #{unit.name} #{unit.aspect} (ERROR)".ansi(:red)
48
+ end
49
+
50
+ #
51
+ def omit(unit)
52
+ puts " * #{unit.name} #{unit.aspect} (OMIT)".ansi(:cyan)
53
+ end
54
+
55
+ #
56
+ def pending(unit, exception)
57
+ puts " * #{unit.name} #{unit.aspect} (PENDING)".ansi(:yellow)
58
+ #puts
59
+ #puts " PENDING #{exception.backtrace[0]}"
60
+ #puts
61
+ end
62
+
63
+ #
64
+ def finish_suite(suite)
65
+ puts
66
+
67
+ unless record[:fail].empty?
68
+ puts "FAILURES:\n\n"
69
+ record[:fail].each do |testunit, exception|
70
+ puts " #{testunit}"
71
+ puts " #{exception}"
72
+ puts " #{exception.backtrace[0]}"
73
+ puts
74
+ end
75
+ end
76
+
77
+ unless record[:error].empty?
78
+ puts "ERRORS:\n\n"
79
+ record[:error].each do |testunit, exception|
80
+ puts " #{testunit}"
81
+ puts " #{exception}"
82
+ puts " #{exception.backtrace[0]}"
83
+ puts
84
+ end
85
+ end
86
+
87
+ #unless record[:pending].empty?
88
+ # puts "PENDING:\n\n"
89
+ # record[:pending].each do |testunit, exception|
90
+ # puts " #{testunit}"
91
+ # end
92
+ #end
93
+
94
+ #unless uncovered.empty?
95
+ # puts "UNCOVERED:\n\n"
96
+ # unc = uncovered.map do |testunit|
97
+ # yellow("* " +testunit.join('#'))
98
+ # end.join("\n")
99
+ # puts unc
100
+ # puts
101
+ #end
102
+
103
+ #unless undefined.empty?
104
+ # puts "UNDEFINED:\n\n"
105
+ # unc = undefined.map do |testunit|
106
+ # yellow("* " + testunit.join('#'))
107
+ # end.join("\n")
108
+ # puts unc
109
+ # puts
110
+ #end
111
+
112
+ puts tally
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
@@ -0,0 +1,131 @@
1
+ require 'lemon/view/test_reports/abstract'
2
+
3
+ module Lemon::TestReports
4
+
5
+ # Summary Reporter
6
+ class Summary < Abstract
7
+
8
+ #
9
+ def start_suite(suite)
10
+ timer_reset
11
+ end
12
+
13
+ #
14
+ #def start_case(tc)
15
+ # puts
16
+ # puts tc.to_s.ansi(:bold)
17
+ #end
18
+
19
+ #
20
+ #def report_instance(instance)
21
+ # puts
22
+ # puts instance #"== #{concern.description}\n\n" unless concern.description.empty?
23
+ # #timer_reset
24
+ #end
25
+
26
+ #
27
+ def omit(unit)
28
+ puts " %s %s %s" % [" OMIT".ansi(:cyan), unit.name, unit.aspect]
29
+ end
30
+
31
+ #
32
+ #def start_unit(unit)
33
+ # context = unit.context
34
+ # if @instance != context
35
+ # @context = context
36
+ # puts
37
+ # puts " #{context}"
38
+ # puts
39
+ # end
40
+ #end
41
+
42
+ #
43
+ def omit(unit)
44
+ puts " %s %s %s" % [" OMIT".ansi(:cyan), unit.to_s.ansi(:bold), unit.aspect]
45
+ end
46
+
47
+ #
48
+ def pass(unit)
49
+ puts " %s %s %s" % [" PASS".ansi(:green), unit.to_s.ansi(:bold), unit.aspect]
50
+ end
51
+
52
+ #
53
+ def fail(unit, exception)
54
+ puts " %s %s %s" % [" FAIL".ansi(:red), unit.to_s.ansi(:bold), unit.aspect]
55
+ #puts
56
+ #puts " FAIL #{exception.backtrace[0]}"
57
+ #puts " #{exception}"
58
+ #puts
59
+ end
60
+
61
+ #
62
+ def error(unit, exception)
63
+ puts " %s %s %s" % [" ERROR".ansi(:red), unit.to_s.ansi(:bold), unit.aspect]
64
+ #puts
65
+ #puts " ERROR #{exception.class}"
66
+ #puts " #{exception}"
67
+ #puts " " + exception.backtrace.join("\n ")
68
+ #puts
69
+ end
70
+
71
+ #
72
+ def pending(unit, exception)
73
+ puts " %s %s %s" % ["PENDING".ansi(:yellow), unit.to_s.ansi(:bold), unit.aspect]
74
+ end
75
+
76
+ #
77
+ def finish_suite(suite)
78
+ puts
79
+
80
+ unless record[:pending].empty?
81
+ puts "PENDING:\n\n"
82
+ record[:pending].each do |unit, exception|
83
+ puts " #{unit}"
84
+ puts " #{file_and_line(exception)}"
85
+ puts
86
+ end
87
+ end
88
+
89
+ unless record[:fail].empty?
90
+ puts "FAILURES:\n\n"
91
+ record[:fail].each do |unit, exception|
92
+ puts " #{unit}"
93
+ puts " #{file_and_line(exception)}"
94
+ puts " #{exception}"
95
+ puts code_snippet(exception)
96
+ #puts " #{exception.backtrace[0]}"
97
+ puts
98
+ end
99
+ end
100
+
101
+ unless record[:error].empty?
102
+ puts "ERRORS:\n\n"
103
+ record[:error].each do |unit, exception|
104
+ puts " #{unit}"
105
+ puts " #{file_and_line(exception)}"
106
+ puts " #{exception}"
107
+ puts code_snippet(exception)
108
+ #puts " #{exception.backtrace[0]}"
109
+ puts
110
+ end
111
+ end
112
+
113
+ puts tally
114
+ end
115
+
116
+ #
117
+ def timer
118
+ secs = Time.now - @time
119
+ @time = Time.now
120
+ return "%0.5fs" % [secs.to_s]
121
+ end
122
+
123
+ #
124
+ def timer_reset
125
+ @time = Time.now
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+
@@ -0,0 +1,49 @@
1
+ require 'lemon/view/test_reports/abstract'
2
+
3
+ module Lemon::TestReports
4
+
5
+ # Timed Reporter
6
+ class Tap < Abstract
7
+
8
+ #
9
+ def start_suite(suite)
10
+ @start = Time.now
11
+ @i = 0
12
+ n = suite.testcases.inject(0){ |c, tc| c = c + tc.size; c }
13
+ puts "1..#{n}"
14
+ end
15
+
16
+ def start_unit(unit)
17
+ @i += 1
18
+ end
19
+
20
+ #
21
+ def pass(unit)
22
+ puts "ok #{@i} - #{unit.description}"
23
+ end
24
+
25
+ #
26
+ def fail(unit, exception)
27
+ puts "not ok #{@i} - #{unit.description}"
28
+ puts " FAIL #{exception.backtrace[0]}"
29
+ puts " #{exception}"
30
+ end
31
+
32
+ #
33
+ def error(unit, exception)
34
+ puts "not ok #{@i} - #{unit.description}"
35
+ puts " ERROR #{exception.class}"
36
+ puts " #{exception}"
37
+ puts " " + exception.backtrace.join("\n ")
38
+ end
39
+
40
+ #
41
+ def pending(unit, exception)
42
+ puts "not ok #{@i} - #{unit.description}"
43
+ puts " PENDING"
44
+ puts " #{exception.backtrace[1]}"
45
+ end
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,197 @@
1
+ require 'lemon/view/test_reports/abstract'
2
+
3
+ module Lemon::TestReports
4
+
5
+ # Timed Reporter
6
+ class Verbose < Abstract
7
+
8
+ LAYOUT = " %-12s %11s %11s %s %s"
9
+
10
+ #
11
+ def start_suite(suite)
12
+ @start = Time.now
13
+ timer_reset
14
+ end
15
+
16
+ #
17
+ def start_case(tc)
18
+ if @_last == :unit
19
+ puts
20
+ @_last = :case
21
+ end
22
+ puts tc.to_s.ansi(:bold)
23
+ puts
24
+ end
25
+
26
+ #
27
+ def context(context)
28
+ unless context.to_s.empty?
29
+ if @_last == :unit
30
+ puts
31
+ @_last = :context
32
+ end
33
+ puts " #{context}"
34
+ puts
35
+ end
36
+ end
37
+
38
+ #
39
+ def start_unit(unit)
40
+ if @context != unit.context
41
+ @context = unit.context
42
+ context(@context)
43
+ end
44
+ timer_reset
45
+ end
46
+
47
+ #
48
+ def omit(unit)
49
+ data = ["OMIT".ansi(:cyan), timer, clock, unit.name.ansi(:bold), unit.aspect]
50
+ puts LAYOUT % data
51
+ #puts " %s %s %s" % [" OMIT".ansi(:cyan), unit.to_s, unit.aspect]
52
+ @_last = :unit
53
+ end
54
+
55
+ #
56
+ def pass(unit)
57
+ data = ["PASS".ansi(:green), timer, clock, unit.name.ansi(:bold), unit.aspect]
58
+ puts LAYOUT % data
59
+ end
60
+
61
+ #
62
+ def fail(unit, exception)
63
+ data = ["FAIL".ansi(:red), timer, clock, unit.name.ansi(:bold), unit.aspect]
64
+ puts LAYOUT % data
65
+ #puts
66
+ #puts " FAIL #{exception.backtrace[0]}"
67
+ #puts " #{exception}"
68
+ #puts
69
+ end
70
+
71
+ #
72
+ def error(unit, exception)
73
+ data = ["ERRS".ansi(:red, :bold), timer, clock, unit.name.ansi(:bold), unit.aspect]
74
+ puts LAYOUT % data
75
+ #puts
76
+ #puts " ERROR #{exception.class}"
77
+ #puts " #{exception}"
78
+ #puts " " + exception.backtrace.join("\n ")
79
+ #puts
80
+ end
81
+
82
+ #
83
+ def pending(unit, exception)
84
+ data = ["PEND".ansi(:yellow), timer, clock, unit.name.ansi(:bold), unit.aspect]
85
+ puts LAYOUT % data
86
+ end
87
+
88
+ #
89
+ def finish_unit(unit)
90
+ @_last = :unit
91
+ end
92
+
93
+ #
94
+ def finish_suite(suite)
95
+ puts
96
+
97
+ unless record[:omit].empty?
98
+ puts "OMITTED:\n\n"
99
+ puts record[:omit].map{ |u| u.to_s }.sort.join(' ')
100
+ puts
101
+ end
102
+
103
+ unless record[:pending].empty?
104
+ puts "PENDING:\n\n"
105
+ record[:pending].each do |unit, exception|
106
+ puts " #{unit}"
107
+ puts " #{file_and_line(exception)}"
108
+ puts
109
+ end
110
+ end
111
+
112
+ unless record[:fail].empty?
113
+ puts "FAILURES:\n\n"
114
+ record[:fail].each do |unit, exception|
115
+ puts " #{unit}"
116
+ puts " #{file_and_line(exception)}"
117
+ puts " #{exception}"
118
+ puts code_snippet(exception)
119
+ #puts " #{exception.backtrace[0]}"
120
+ puts
121
+ end
122
+ end
123
+
124
+ unless record[:error].empty?
125
+ puts "ERRORS:\n\n"
126
+ record[:error].each do |unit, exception|
127
+ puts " #{unit}".ansi(:bold)
128
+ puts " #{exception.class} @ #{file_and_line(exception)}"
129
+ puts " #{exception}"
130
+ puts code_snippet(exception)
131
+ #puts " #{exception.backtrace[0]}"
132
+ puts
133
+ end
134
+ end
135
+
136
+ puts tally
137
+ end
138
+
139
+ #
140
+ def clock
141
+ secs = Time.now - @start
142
+ return "%0.5fs" % [secs.to_s]
143
+ end
144
+
145
+ #
146
+ def timer
147
+ secs = Time.now - @time
148
+ @time = Time.now
149
+ return "%0.5fs" % [secs.to_s]
150
+ end
151
+
152
+ #
153
+ def timer_reset
154
+ @time = Time.now
155
+ end
156
+
157
+ end
158
+
159
+ end
160
+
161
+
162
+
163
+
164
+ =begin
165
+ if cover?
166
+
167
+ unless uncovered_cases.empty?
168
+ unc = uncovered_cases.map do |mod|
169
+ yellow(mod.name)
170
+ end.join(", ")
171
+ puts "\nUncovered Cases: " + unc
172
+ end
173
+
174
+ unless uncovered_units.empty?
175
+ unc = uncovered_units.map do |unit|
176
+ yellow(unit)
177
+ end.join(", ")
178
+ puts "\nUncovered Units: " + unc
179
+ end
180
+
181
+ #unless uncovered.empty?
182
+ # unc = uncovered.map do |unit|
183
+ # yellow(unit)
184
+ # end.join(", ")
185
+ # puts "\nUncovered: " + unc
186
+ #end
187
+
188
+ unless undefined_units.empty?
189
+ unc = undefined_units.map do |unit|
190
+ yellow(unit)
191
+ end.join(", ")
192
+ puts "\nUndefined Units: " + unc
193
+ end
194
+
195
+ end
196
+ =end
197
+