lemon 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/{lemon.gemspec → .gemspec} +0 -0
  2. data/.ruby +4 -11
  3. data/Assembly +5 -11
  4. data/HISTORY.rdoc +31 -0
  5. data/MANIFEST +45 -55
  6. data/PROFILE +6 -6
  7. data/README.md +113 -0
  8. data/Rakefile +12 -3
  9. data/VERSION +1 -1
  10. data/bin/lemonade +8 -0
  11. data/lib/lemon.rb +52 -2
  12. data/lib/lemon.yml +4 -11
  13. data/lib/lemon/{model/ae.rb → ae.rb} +0 -0
  14. data/lib/lemon/cli.rb +28 -279
  15. data/lib/lemon/cli/base.rb +139 -0
  16. data/lib/lemon/cli/coverage.rb +52 -0
  17. data/lib/lemon/cli/generate.rb +51 -0
  18. data/lib/lemon/cli/test.rb +50 -0
  19. data/lib/lemon/core_ext.rb +7 -0
  20. data/lib/lemon/core_ext/kernel.rb +20 -0
  21. data/lib/lemon/core_ext/omission.rb +18 -0
  22. data/lib/lemon/{controller/coverage_analyzer.rb → coverage/analyzer.rb} +41 -19
  23. data/lib/lemon/{model → coverage}/cover_unit.rb +0 -0
  24. data/lib/lemon/{view/cover_reports → coverage/formats}/abstract.rb +0 -0
  25. data/lib/lemon/{view/cover_reports → coverage/formats}/compact.rb +1 -1
  26. data/lib/lemon/{view/cover_reports → coverage/formats}/outline.rb +1 -1
  27. data/lib/lemon/{view/cover_reports → coverage/formats}/verbose.rb +1 -1
  28. data/lib/lemon/{view/cover_reports → coverage/formats}/yaml.rb +1 -1
  29. data/lib/lemon/{model → coverage}/snapshot.rb +0 -0
  30. data/lib/lemon/{model → coverage}/source_parser.rb +0 -0
  31. data/lib/lemon/{controller/scaffold_generator.rb → generator.rb} +53 -14
  32. data/lib/lemon/test_advice.rb +63 -0
  33. data/lib/lemon/test_case.rb +270 -0
  34. data/lib/lemon/test_class.rb +28 -0
  35. data/lib/lemon/test_method.rb +207 -0
  36. data/lib/lemon/test_module.rb +114 -0
  37. data/lib/lemon/test_proc.rb +140 -0
  38. data/lib/lemon/test_setup.rb +54 -0
  39. data/lib/lemon/test_world.rb +9 -0
  40. data/notes/{2010-05-06-files_not_classes.rdoc → 2010-05-06-files-not-classes.rdoc} +0 -0
  41. data/notes/{2010-07-11-acid_testing.rdoc → 2010-07-11-acid-testing.rdoc} +0 -0
  42. data/notes/2011-07-07-nailing-down-the-nomenclature.md +6 -0
  43. data/site/index.html +7 -6
  44. data/{qed → spec}/applique/fs.rb +0 -0
  45. data/{qed → spec}/coverage/01_complete.rdoc +26 -16
  46. data/{qed → spec}/coverage/02_incomplete.rdoc +10 -7
  47. data/{qed → spec}/coverage/03_extensions.rdoc +10 -6
  48. data/spec/coverage/applique/lemon.rb +1 -0
  49. data/try/.test +8 -0
  50. data/try/case_error.rb +18 -0
  51. data/try/case_fail.rb +19 -0
  52. data/try/case_pass.rb +42 -0
  53. data/try/case_pending.rb +18 -0
  54. data/try/case_singleton.rb +18 -0
  55. data/try/case_untested.rb +14 -0
  56. data/try/fixtures/calculator.rb +15 -0
  57. data/{demo/fixture → try/fixtures}/example-use.rb +0 -0
  58. data/{demo/fixture → try/fixtures}/example.rb +0 -0
  59. data/try/helpers/loadpath.rb +1 -0
  60. data/{.config → work/deprecated}/cucumber.yml +0 -0
  61. data/{features → work/deprecated/features}/coverage.feature +0 -0
  62. data/{features → work/deprecated/features}/generate.feature +0 -0
  63. data/{features → work/deprecated/features}/step_definitions/coverage_steps.rb +0 -0
  64. data/{features → work/deprecated/features}/support/ae.rb +0 -0
  65. data/{features → work/deprecated/features}/support/aruba.rb +0 -0
  66. data/{features → work/deprecated/features}/test.feature +0 -0
  67. data/work/deprecated/model/dsl/advice.rb +78 -0
  68. data/work/deprecated/model/dsl/subject.rb +40 -0
  69. data/{lib/lemon → work/deprecated}/model/main.rb +40 -29
  70. data/work/deprecated/model/test.rb +54 -0
  71. data/work/deprecated/model/test_base_dsl.rb +88 -0
  72. data/work/deprecated/model/test_clause.rb +112 -0
  73. data/{lib/lemon → work/deprecated}/model/test_context.rb +24 -24
  74. data/work/deprecated/model/test_feature.rb +128 -0
  75. data/work/deprecated/model/test_scenario.rb +137 -0
  76. data/{lib/lemon → work/deprecated}/model/test_suite.rb +113 -32
  77. data/work/deprecated/rake.rb +103 -0
  78. data/{test → work/deprecated/test}/case_coverage_analyzer.rb +0 -0
  79. data/{test → work/deprecated/test}/case_test_case_dsl.rb +2 -2
  80. data/{test → work/deprecated/test}/fixtures/case_complete.rb +0 -0
  81. data/{test → work/deprecated/test}/fixtures/case_inclusion.rb +0 -0
  82. data/{test → work/deprecated/test}/fixtures/case_incomplete.rb +0 -0
  83. data/{test → work/deprecated/test}/fixtures/example.rb +0 -0
  84. data/{test → work/deprecated/test}/fixtures/helper.rb +0 -0
  85. data/{test → work/deprecated/test}/runner +0 -0
  86. data/work/old-tests/case_example.rb +15 -0
  87. data/work/old-tests/feature_example.rb +40 -0
  88. data/work/reference/dsl2.rb +4 -0
  89. metadata +101 -98
  90. data/README.rdoc +0 -103
  91. data/bin/lemon +0 -4
  92. data/demo/case_example_error.rb +0 -10
  93. data/demo/case_example_fail.rb +0 -15
  94. data/demo/case_example_pass.rb +0 -32
  95. data/demo/case_example_pending.rb +0 -14
  96. data/demo/case_example_untested.rb +0 -10
  97. data/lib/lemon/controller/test_runner.rb +0 -299
  98. data/lib/lemon/model/pending.rb +0 -10
  99. data/lib/lemon/model/test_case.rb +0 -305
  100. data/lib/lemon/model/test_unit.rb +0 -147
  101. data/lib/lemon/view/test_reports/abstract.rb +0 -256
  102. data/lib/lemon/view/test_reports/dotprogress.rb +0 -73
  103. data/lib/lemon/view/test_reports/html.rb +0 -146
  104. data/lib/lemon/view/test_reports/outline.rb +0 -118
  105. data/lib/lemon/view/test_reports/summary.rb +0 -131
  106. data/lib/lemon/view/test_reports/tap.rb +0 -49
  107. data/lib/lemon/view/test_reports/tapj.rb +0 -130
  108. data/lib/lemon/view/test_reports/tapy.rb +0 -141
  109. data/lib/lemon/view/test_reports/verbose.rb +0 -197
  110. data/work/sandbox/lib/sample.rb +0 -13
  111. data/work/sandbox/test/sample_case.rb +0 -12
  112. data/work/trash/example-cover.rb +0 -5
  113. data/work/trash/example.rb +0 -16
@@ -9,6 +9,7 @@ copyrights:
9
9
  replacements: []
10
10
  conflicts: []
11
11
  requirements:
12
+ - name: test
12
13
  - name: ae
13
14
  - name: ansi
14
15
  version: 1.3+
@@ -24,14 +25,6 @@ requirements:
24
25
  groups:
25
26
  - test
26
27
  development: true
27
- - name: cucumber
28
- groups:
29
- - test
30
- development: true
31
- - name: aruba
32
- groups:
33
- - test
34
- development: true
35
28
  dependencies: []
36
29
  repositories:
37
30
  - uri: git://github.com/proutils/lemon.git
@@ -47,10 +40,10 @@ extra:
47
40
  alternatives: []
48
41
  revision: 0
49
42
  title: Lemon
50
- suite: proutils
51
43
  summary: Pucker-tight Unit Testing
52
44
  description: Lemon is a unit testing framework that tightly correlates class to test
53
45
  case and method to test unit.
54
- version: 0.8.5
46
+ organization: RubyWorks
47
+ version: 0.9.0
55
48
  name: lemon
56
- date: '2011-07-16'
49
+ date: '2011-08-11'
File without changes
@@ -1,285 +1,34 @@
1
- module Lemon
2
-
3
- require 'optparse'
4
-
5
- # TODO: What about a config file?
6
-
7
- # CLI Interface handle all lemon sub-commands.
8
- class CLI
9
-
10
- COMMANDS = {
11
- '-t' => 'test' , '--test' => 'test',
12
- '-c' => 'coverage', '--cov' => 'coverage', '--coverage' => 'coverage',
13
- '-g' => 'generate', '--gen' => 'generate', '--generate' => 'generate'
14
- }
15
-
16
- #
17
- def self.run(argv=ARGV)
18
- new.run(argv)
19
- end
20
-
21
- #
22
- def initialize(argv=ARGV)
23
- @options = {}
24
- end
25
-
26
- #
27
- def options
28
- @options
29
- end
30
-
31
- #
32
- def run(argv)
33
- cmdopt = COMMANDS.keys.find{ |k| argv.delete(k) }
34
- command = COMMANDS[cmdopt]
35
-
36
- if command.nil? && argv.include?('--help')
37
- option_commands
38
- option_parser.parse!(argv)
39
- end
40
-
41
- command ||= 'test'
42
-
43
- #option_commands
44
-
45
- #cmd = argv.shift
46
- #cmd = COMMANDS.find{ |c| /^#{cmd}/ =~ c }
47
- #option_parser.order!(argv)
48
-
49
- begin
50
- __send__("#{command}_parse", argv)
51
- __send__("#{command}", argv)
52
- rescue => err
53
- raise err if $DEBUG
54
- $stderr.puts('ERROR: ' + err.to_s)
55
- end
56
- end
57
-
58
- # T E S T
59
-
60
- # Run unit tests.
61
- def test(scripts)
62
- require 'lemon/controller/test_runner'
63
-
64
- loadpath = options[:loadpath] || ['lib'] # + ['lib'] ?
65
- requires = options[:requires] || []
66
-
67
- loadpath.each{ |path| $LOAD_PATH.unshift(path) }
68
- requires.each{ |path| require(path) }
69
-
70
- #suite = Lemon::Test::Suite.new(files, :cover=>cover)
71
- #runner = Lemon::Runner.new(suite, :format=>format, :cover=>cover, :namespaces=>namespaces)
72
-
73
- runner = Lemon::TestRunner.new(
74
- scripts, :format=>options[:format], :namespaces=>options[:namespaces]
75
- )
76
-
77
- success = runner.run
78
-
79
- exit -1 unless success
80
- end
81
-
82
- #
83
- def test_parse(argv)
84
- option_parser.banner = "Usage: lemon [-t] [options] [files ...]"
85
- #option_parser.separator("Run unit tests.")
86
-
87
- option_format
88
- option_verbose
89
- option_namespaces
90
- option_loadpath
91
- option_requires
92
-
93
- option_parser.parse!(argv)
94
- end
95
-
96
- # C O V E R A G E
97
-
98
- # Ouput coverage report.
99
- def coverage(test_files)
100
- require 'lemon/controller/coverage_analyzer'
101
-
102
- #loadpath = options[:loadpath] || []
103
- #requires = options[:requires] || []
104
-
105
- #loadpath.each{ |path| $LOAD_PATH.unshift(path) }
106
- #requires.each{ |path| require(path) }
107
-
108
- $stderr.print "Calculating... "
109
- $stderr.flush
110
-
111
- cover = Lemon::CoverageAnalyzer.new(test_files, options)
112
-
113
- cover.calculate # this just helps calcs get done up front
114
-
115
- $stderr.puts
116
-
117
- cover.render
118
- end
1
+ #require 'lemon/cli/test'
2
+ require 'lemon/cli/generate'
3
+ require 'lemon/cli/coverage'
119
4
 
120
- #
121
- def coverage_parse(argv)
122
- option_parser.banner = "Usage: lemon -c [options] [files ...]"
123
- #option_parser.separator("Check test coverage.")
124
-
125
- option_namespaces
126
- option_private
127
- option_zealous
128
- option_output
129
- option_format
130
- option_loadpath
131
- option_requires
132
-
133
- option_parser.parse!(argv)
134
- end
135
-
136
- # G E N E R A T E
137
-
138
- # Generate test templates.
139
- def generate(test_files)
140
- require 'lemon/controller/scaffold_generator'
141
-
142
- loadpath = options[:loadpath] || []
143
- requires = options[:requires] || []
144
-
145
- loadpath.each{ |path| $LOAD_PATH.unshift(path) }
146
- requires.each{ |path| require(path) }
147
-
148
- #cover = options[:uncovered]
149
- #suite = Lemon::TestSuite.new(test_files, :cover=>cover) #, :cover_all=>true)
150
- generator = Lemon::ScaffoldGenerator.new(test_files, options)
151
-
152
- #if uncovered
153
- # puts cover.generate_uncovered #(output)
154
- #else
155
- puts generator.generate #(output)
156
- #end
157
- end
158
-
159
- #
160
- def generate_parse(argv)
161
- option_parser.banner = "Usage: lemon -g [options] [files ...]"
162
- #option_parser.separator("Generate test scaffolding.")
163
-
164
- option_namespaces
165
- option_uncovered
166
- option_all
167
- option_private
168
- option_loadpath
169
- option_requires
170
-
171
- option_parser.parse!(argv)
172
- end
173
-
174
- # P A R S E R O P T I O N S
175
-
176
- def option_commands
177
- option_parser.banner = "Usage: lemon [command] [options] [files ...]"
178
- option_parser.on('-t', '--test', 'run unit tests [default]') do
179
- @command = :test
180
- end
181
- option_parser.on('-c', '--cov', '--coverage', 'provide test coverage analysis') do
182
- @command = :coverage
183
- end
184
- option_parser.on('-g', '--gen', '--generate', 'generate unit test scaffolding') do
185
- @command = :generate
186
- end
187
- end
188
-
189
- def option_namespaces
190
- option_parser.on('-n', '--namespace NAME', 'add a namespace to output') do |name|
191
- options[:namespaces] ||= []
192
- options[:namespaces] << name
193
- end
194
- end
195
-
196
- #def option_framework
197
- # option_parser.on('-f', '--framework NAME', 'framework syntax to output') do |name|
198
- # options[:framework] = name.to_sym
199
- # end
200
- #end
201
-
202
- def option_format
203
- option_parser.on('-f', '--format NAME', 'output format') do |name|
204
- options[:format] = name
205
- end
206
- end
207
-
208
- def option_verbose
209
- option_parser.on('-v', '--verbose', 'shortcut for `-f verbose`') do |name|
210
- options[:format] = 'verbose'
211
- end
212
- end
213
-
214
- def option_uncovered
215
- option_parser.on('-u', '--uncovered', 'include only uncovered units') do
216
- options[:uncovered] = true
217
- end
218
- end
219
-
220
- def option_all
221
- option_parser.on('-a', '--all', 'include all namespaces and units') do
222
- options[:all] = true
223
- end
224
- end
225
-
226
- def option_private
227
- option_parser.on('-p', '--private', 'include private and protected methods') do
228
- options[:private] = true
229
- end
230
- end
231
-
232
- def option_zealous
233
- option_parser.on('-z', '--zealous', 'include undefined case methods') do
234
- options[:zealous] = true
235
- end
236
- end
237
-
238
- def option_output
239
- option_parser.on('-o', '--output DIRECTORY', 'log directory') do |dir|
240
- options[:output] = dir
241
- end
242
- end
243
-
244
- def option_loadpath
245
- option_parser.on("-I PATH" , 'add directory to $LOAD_PATH') do |path|
246
- paths = path.split(/[:;]/)
247
- options[:loadpath] ||= []
248
- options[:loadpath].concat(paths)
249
- end
250
- end
251
-
252
- def option_requires
253
- option_parser.on("-r FILE" , 'require file(s) (before doing anything else)') do |files|
254
- files = files.split(/[:;]/)
255
- options[:requires] ||= []
256
- options[:requires].concat(files)
257
- end
258
- end
5
+ module Lemon
259
6
 
260
- def option_parser
261
- @option_parser ||= (
262
- OptionParser.new do |opt|
263
- opt.on_tail("--[no-]ansi" , 'turn on/off ANIS colors') do |v|
264
- $ansi = v
265
- end
266
- opt.on_tail("--debug" , 'turn on debugging mode') do
267
- $DEBUG = true
268
- end
269
- opt.on_tail("--about" , 'display information about lemon') do
270
- puts "Lemon v#{Lemon::VERSION}"
271
- puts "#{Lemon::COPYRIGHT}"
272
- exit
273
- end
274
- opt.on_tail('-h', '--help', 'display help (also try `<command> --help`)') do
275
- puts opt
276
- exit
277
- end
278
- end
279
- )
7
+ #--
8
+ # TODO: Use Lemon::CLI::Runner and have it delegate to Ruby Test ?
9
+ #++
10
+
11
+ # Command line interface takes the first argument off `argv` to determine
12
+ # the subcommand: `test`, `cov` or `gen`. If `test`, then Lemon delegates
13
+ # control to Ruby Test.
14
+ #
15
+ def self.cli(*argv)
16
+ cmd = argv.shift
17
+ case cmd
18
+ when 'test'
19
+ require 'lemon'
20
+ require 'test/cli'
21
+ Test::Runner.cli(*ARGV)
22
+ #Lemon::CLI::Test.new.run(argv)
23
+ when /^gen/, /^scaf/
24
+ Lemon::CLI::Generate.new.run(argv)
25
+ when /^cov/
26
+ Lemon::CLI::Coverage.new.run(argv)
27
+ else
28
+ # run tests instead?
29
+ puts "invalid lemon command -- #{cmd}"
30
+ exit -1
280
31
  end
281
-
282
32
  end
283
33
 
284
34
  end
285
-
@@ -0,0 +1,139 @@
1
+ module Lemon
2
+
3
+ require 'optparse'
4
+
5
+ # TODO: What about a config file?
6
+
7
+ # CLI Interfaces handle all lemon sub-commands.
8
+ module CLI
9
+
10
+ # Base class for all commands.
11
+ class Base
12
+
13
+ #
14
+ def initialize(argv=ARGV)
15
+ @options = {}
16
+ end
17
+
18
+ #
19
+ def options
20
+ @options
21
+ end
22
+
23
+ #
24
+ def run(argv)
25
+ begin
26
+ command_parse(argv)
27
+ command_run(argv)
28
+ rescue => err
29
+ raise err if $DEBUG
30
+ $stderr.puts('ERROR: ' + err.to_s)
31
+ end
32
+ end
33
+
34
+ #
35
+ def option_parser
36
+ @option_parser ||= (
37
+ OptionParser.new do |opt|
38
+ opt.on_tail("--[no-]ansi" , 'turn on/off ANIS colors') do |v|
39
+ $ansi = v
40
+ end
41
+ opt.on_tail("--debug" , 'turn on debugging mode') do
42
+ $DEBUG = true
43
+ end
44
+ opt.on_tail("--about" , 'display information about lemon') do
45
+ puts "Lemon v#{Lemon::VERSION}"
46
+ puts "#{Lemon::COPYRIGHT}"
47
+ exit
48
+ end
49
+ opt.on_tail('-h', '--help', 'display help (also try `<command> --help`)') do
50
+ puts opt
51
+ exit
52
+ end
53
+ end
54
+ )
55
+ end
56
+
57
+ #
58
+ def option_namespaces
59
+ option_parser.on('-n', '--namespace NAME', 'add a namespace to output') do |name|
60
+ options[:namespaces] ||= []
61
+ options[:namespaces] << name
62
+ end
63
+ end
64
+
65
+ #def option_framework
66
+ # option_parser.on('-f', '--framework NAME', 'framework syntax to output') do |name|
67
+ # options[:framework] = name.to_sym
68
+ # end
69
+ #end
70
+
71
+ def option_format
72
+ option_parser.on('-f', '--format NAME', 'output format') do |name|
73
+ options[:format] = name
74
+ end
75
+ end
76
+
77
+ def option_verbose
78
+ option_parser.on('-v', '--verbose', 'shortcut for `-f verbose`') do |name|
79
+ options[:format] = 'verbose'
80
+ end
81
+ end
82
+
83
+ def option_covered
84
+ option_parser.on('-c', '--covered', 'include covered units') do
85
+ options[:covered] = true
86
+ end
87
+ end
88
+
89
+ def option_uncovered
90
+ option_parser.on('-u', '--uncovered', 'include only uncovered units') do
91
+ options[:uncovered] = true
92
+ end
93
+ end
94
+
95
+ def option_all
96
+ option_parser.on('-a', '--all', 'include all namespaces and units') do
97
+ options[:all] = true
98
+ end
99
+ end
100
+
101
+ def option_private
102
+ option_parser.on('-p', '--private', 'include private and protected methods') do
103
+ options[:private] = true
104
+ end
105
+ end
106
+
107
+ def option_zealous
108
+ option_parser.on('-z', '--zealous', 'include undefined case methods') do
109
+ options[:zealous] = true
110
+ end
111
+ end
112
+
113
+ def option_output
114
+ option_parser.on('-o', '--output DIRECTORY', 'log directory') do |dir|
115
+ options[:output] = dir
116
+ end
117
+ end
118
+
119
+ def option_loadpath
120
+ option_parser.on("-I PATH" , 'add directory to $LOAD_PATH') do |path|
121
+ paths = path.split(/[:;]/)
122
+ options[:loadpath] ||= []
123
+ options[:loadpath].concat(paths)
124
+ end
125
+ end
126
+
127
+ def option_requires
128
+ option_parser.on("-r FILE" , 'require file(s) (before doing anything else)') do |files|
129
+ files = files.split(/[:;]/)
130
+ options[:requires] ||= []
131
+ options[:requires].concat(files)
132
+ end
133
+ end
134
+
135
+ end
136
+
137
+ end
138
+
139
+ end