lemon 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
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,18 @@
1
+ covers File.dirname(__FILE__) + '/example.rb'
2
+
3
+ require File.dirname(__FILE__) + '/helper.rb'
4
+
5
+ testcase X do
6
+
7
+ include HelperMixin
8
+
9
+ unit :a => "Returns a String" do
10
+ X.new.a
11
+ end
12
+
13
+ unit :b => "Returns a String" do
14
+ X.new.b
15
+ end
16
+
17
+ end
18
+
@@ -1,11 +1,11 @@
1
- Covers File.dirname(__FILE__) + '/example.rbx'
1
+ covers File.dirname(__FILE__) + '/example.rb'
2
2
 
3
- TestCase X do
3
+ testcase X do
4
4
 
5
- Unit :a => "Returns a String" do
5
+ unit :a => "Returns a String" do
6
6
  end
7
7
 
8
- Unit :b => "Returns a String" do
8
+ unit :b => "Returns a String" do
9
9
  end
10
10
 
11
11
  end
@@ -5,4 +5,9 @@ class X
5
5
  end
6
6
  class Y
7
7
  def q; "q"; end
8
+ protected
9
+ def r; "r"; end
10
+ private
11
+ def s; "s"; end
8
12
  end
13
+
@@ -0,0 +1,13 @@
1
+ # Some fixture code for testing #include.
2
+ module HelperMixin
3
+
4
+ def help; "help"; end
5
+
6
+ module SubModule
7
+
8
+ def self.help; "sub-help"; end
9
+
10
+ end
11
+
12
+ end
13
+
data/test/runner ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ system 'lemon -v test/unit/*.rb'
3
+ system 'cucumber'
@@ -0,0 +1,25 @@
1
+ covers 'lemon/controller/coverage_analyzer'
2
+
3
+ testcase Lemon::CoverageAnalyzer do
4
+
5
+ setup "Coverage of public units of an incomplete test" do
6
+ @memo_instance ||= (
7
+ files = ['test/fixtures/case_incomplete.rb']
8
+ Lemon::CoverageAnalyzer.new(files)
9
+ )
10
+ end
11
+
12
+ unit :covered => 'returns a list of covered units' do |ca|
13
+ ca.covered.assert.is_a?(Array)
14
+ end
15
+
16
+ unit :uncovered => 'returns a list of uncovered units' do |ca|
17
+ ca.uncovered.assert.is_a?(Array)
18
+ end
19
+
20
+ unit :current => 'returns a current Snapshot of all units in the system' do |ca|
21
+ ca.current.assert.is_a?(Lemon::Snapshot)
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,46 @@
1
+ testcase Lemon::TestCase::DSL do
2
+
3
+ before do
4
+ @files = ['test/fixtures/case_inclusion.rb']
5
+ end
6
+
7
+ setup "Modules included in a test case are accessible by the unit tests" do
8
+ ts = Lemon::TestSuite.new(@files)
9
+ tc = ts.testcases.first # the only one
10
+ tc.dsl
11
+ end
12
+
13
+ unit :include, "allows access to module methods" do |dsl|
14
+ mod = Module.new{ def x; "x"; end }
15
+ dsl.include(mod)
16
+ # how to test?
17
+ end
18
+
19
+ # I do not think it is possible to make this work using dyanmic module
20
+ # construction. Please correct me if you know otherwise. To fix
21
+ # would mean turning test cases into classes instead of objects. Maybe
22
+ # we will do this in the future.
23
+ omit unit :include, "allows access to nested modules" do |dsl|
24
+ mod = Module.new{ N = 1 }
25
+ dsl.include(mod)
26
+ dsl::N == 1
27
+ end
28
+
29
+ setup "Test cases are augmented by before and afters procedures" do
30
+ ts = Lemon::TestSuite.new(@files)
31
+ tc = ts.testcases.first # the only one
32
+ tc.dsl
33
+ end
34
+
35
+ unit :before => "setup a pre-testcase procedure" do |dsl|
36
+ dsl.before{ }
37
+ # how to test?
38
+ end
39
+
40
+ unit :after => "setup a post-testcase procedure" do |dsl|
41
+ dsl.after{ }
42
+ # how to test?
43
+ end
44
+
45
+ end
46
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lemon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 0.8.1
9
+ - 2
10
+ version: 0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-11 00:00:00 -04:00
18
+ date: 2010-09-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: syckle
22
+ name: ae
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -30,10 +30,10 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  version: "0"
33
- type: :development
33
+ type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: box
36
+ name: syckle
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :development
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: cucumber
50
+ name: box
51
51
  prerelease: false
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -61,7 +61,7 @@ dependencies:
61
61
  type: :development
62
62
  version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- name: ae
64
+ name: cucumber
65
65
  prerelease: false
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
@@ -75,7 +75,7 @@ dependencies:
75
75
  type: :development
76
76
  version_requirements: *id004
77
77
  - !ruby/object:Gem::Dependency
78
- name: aruba
78
+ name: ae
79
79
  prerelease: false
80
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
81
  none: false
@@ -88,8 +88,22 @@ dependencies:
88
88
  version: "0"
89
89
  type: :development
90
90
  version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: aruba
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :development
104
+ version_requirements: *id006
91
105
  description: Lemon is a unit testing framework that tightly correlates class to test case and method to test unit.
92
- email: proutils@googlegroups.com
106
+ email: transfire@gmail.com
93
107
  executables:
94
108
  - lemon
95
109
  extensions: []
@@ -98,45 +112,70 @@ extra_rdoc_files:
98
112
  - README.rdoc
99
113
  files:
100
114
  - bin/lemon
101
- - features/coverage.feature
102
- - features/generate.feature
103
- - features/step_definitions/coverage_steps.rb
104
- - features/support/ae.rb
105
- - features/support/aruba.rb
106
- - features/test.feature
107
- - lib/lemon/command.rb
108
- - lib/lemon/coverage.rb
109
- - lib/lemon/coversheet/abstract.rb
110
- - lib/lemon/coversheet/outline.rb
111
- - lib/lemon/dsl.rb
112
- - lib/lemon/kernel.rb
113
- - lib/lemon/reporter/abstract.rb
114
- - lib/lemon/reporter/dotprogress.rb
115
- - lib/lemon/reporter/outline.rb
116
- - lib/lemon/reporter/verbose.rb
117
- - lib/lemon/reporter.rb
118
- - lib/lemon/runner.rb
119
- - lib/lemon/snapshot.rb
120
- - lib/lemon/test/case.rb
121
- - lib/lemon/test/concern.rb
122
- - lib/lemon/test/suite.rb
123
- - lib/lemon/test/unit.rb
115
+ - demo/case_example_fail.rb
116
+ - demo/case_example_pass.rb
117
+ - demo/case_example_pending.rb
118
+ - demo/case_example_untested.rb
119
+ - demo/fixture/example-use.rb
120
+ - demo/fixture/example.rb
121
+ - lib/lemon/cli.rb
122
+ - lib/lemon/controller/coverage_analyzer.rb
123
+ - lib/lemon/controller/scaffold_generator.rb
124
+ - lib/lemon/controller/test_runner.rb
125
+ - lib/lemon/meta/data.rb
126
+ - lib/lemon/meta/gemfile
127
+ - lib/lemon/meta/profile
128
+ - lib/lemon/model/ae.rb
129
+ - lib/lemon/model/cover_unit.rb
130
+ - lib/lemon/model/main.rb
131
+ - lib/lemon/model/pending.rb
132
+ - lib/lemon/model/snapshot.rb
133
+ - lib/lemon/model/source_parser.rb
134
+ - lib/lemon/model/test_case.rb
135
+ - lib/lemon/model/test_context.rb
136
+ - lib/lemon/model/test_suite.rb
137
+ - lib/lemon/model/test_unit.rb
138
+ - lib/lemon/view/cover_reports/abstract.rb
139
+ - lib/lemon/view/cover_reports/compact.rb
140
+ - lib/lemon/view/cover_reports/outline.rb
141
+ - lib/lemon/view/cover_reports/verbose.rb
142
+ - lib/lemon/view/cover_reports/yaml.rb
143
+ - lib/lemon/view/test_reports/abstract.rb
144
+ - lib/lemon/view/test_reports/dotprogress.rb
145
+ - lib/lemon/view/test_reports/html.rb
146
+ - lib/lemon/view/test_reports/outline.rb
147
+ - lib/lemon/view/test_reports/summary.rb
148
+ - lib/lemon/view/test_reports/tap.rb
149
+ - lib/lemon/view/test_reports/verbose.rb
124
150
  - lib/lemon.rb
125
- - test/case_coverage.rb
126
- - test/case_testcase.rb
151
+ - meta/data.rb
152
+ - meta/gemfile
153
+ - meta/profile
154
+ - test/api/applique/fs.rb
155
+ - test/api/coverage/complete.rdoc
156
+ - test/api/coverage/extensions.rdoc
157
+ - test/api/coverage/incomplete.rdoc
158
+ - test/cli/coverage.feature
159
+ - test/cli/generate.feature
160
+ - test/cli/step_definitions/coverage_steps.rb
161
+ - test/cli/support/ae.rb
162
+ - test/cli/support/aruba.rb
163
+ - test/cli/test.feature
127
164
  - test/fixtures/case_complete.rb
165
+ - test/fixtures/case_inclusion.rb
128
166
  - test/fixtures/case_incomplete.rb
129
167
  - test/fixtures/example.rb
168
+ - test/fixtures/helper.rb
169
+ - test/runner
170
+ - test/unit/case_coverage_analyzer.rb
171
+ - test/unit/case_test_case_dsl.rb
130
172
  - HISTORY.rdoc
131
- - PROFILE
132
173
  - LICENSE
133
174
  - README.rdoc
134
- - REQUIRE
135
- - VERSION
136
175
  has_rdoc: true
137
176
  homepage: http://proutils.github.com/lemon
138
- licenses: []
139
-
177
+ licenses:
178
+ - Apache 2.0
140
179
  post_install_message:
141
180
  rdoc_options:
142
181
  - --title
@@ -171,4 +210,10 @@ signing_key:
171
210
  specification_version: 3
172
211
  summary: Pucker-tight Unit Testing
173
212
  test_files:
174
- - test/case_testcase.rb
213
+ - demo/case_example_untested.rb
214
+ - lib/lemon/controller/test_runner.rb
215
+ - lib/lemon/model/test_case.rb
216
+ - lib/lemon/model/test_context.rb
217
+ - lib/lemon/model/test_suite.rb
218
+ - lib/lemon/model/test_unit.rb
219
+ - test/unit/case_test_case_dsl.rb
data/REQUIRE DELETED
@@ -1,9 +0,0 @@
1
- development:
2
- - syckle
3
- - box
4
-
5
- development/test:
6
- - cucumber
7
- - ae
8
- - aruba
9
-
data/VERSION DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- name : lemon
3
- major: 0
4
- minor: 8
5
- patch: 1
6
- date : 2010-07-10
data/lib/lemon/command.rb DELETED
@@ -1,184 +0,0 @@
1
- module Lemon
2
- require 'lemon'
3
- require 'optparse'
4
-
5
- # Lemon Command-line tool.
6
- class Command
7
-
8
- # Initialize and run.
9
- def self.run
10
- new.run
11
- end
12
-
13
- # New Command instance.
14
- def initialize
15
- @command = :test
16
- @format = nil
17
- @requires = []
18
- @includes = []
19
- @namespaces = []
20
- @uncovered = false
21
- @public_only = true
22
- end
23
-
24
- #
25
- attr_accessor :command
26
-
27
- #
28
- attr_accessor :format
29
-
30
- #
31
- attr_accessor :requires
32
-
33
- #
34
- attr_accessor :includes
35
-
36
- #
37
- attr_accessor :namespaces
38
-
39
- #
40
- attr_accessor :uncovered
41
-
42
- #
43
- attr_accessor :public_only
44
-
45
-
46
- # Get or set librarires to pre-require.
47
- def requires(*paths)
48
- @requires.concat(paths) unless paths.empty?
49
- @requires
50
- end
51
-
52
- # Get or set paths to include in $LOAD_PATH.
53
- def includes(*paths)
54
- @includes.concat(paths) unless paths.empty?
55
- @includes
56
- end
57
-
58
- #
59
- def namespaces(*names)
60
- @namespaces.concat(names) unless names.empty?
61
- @namespaces
62
- end
63
-
64
- # Instance of OptionParser.
65
- def parser
66
- @parser ||= OptionParser.new do |opt|
67
- opt.banner = "lemon [options] [files ...]"
68
- opt.separator("Run unit tests, check coverage and generate test scaffolding.")
69
- opt.separator " "
70
- opt.separator("COMMAND OPTIONS (choose one):")
71
- opt.on('--test', '-t', "run unit tests [default]") do
72
- self.command = :test
73
- end
74
- opt.on('--coverage', '-c', "provide test coverage analysis") do
75
- self.command = :cover
76
- end
77
- opt.on('--generate', '-g', "generate unit test scaffolding") do
78
- self.command = :generate
79
- end
80
- opt.separator " "
81
- opt.separator("COMMON OPTIONS:")
82
- opt.on("--namespace", "-n NAME", "limit testing/coverage to namespace") do |name|
83
- namespaces(name)
84
- end
85
- opt.on('--format', '-f TYPE', "select output format") do |type|
86
- self.format = type
87
- end
88
- opt.on('--verbose', '-v', "select verbose report format") do |type|
89
- self.format = :verbose
90
- end
91
- opt.on('--outline', '-o', "select outline report format") do |type|
92
- self.format = :outline
93
- end
94
- opt.separator " "
95
- opt.separator("COVERAGE OPTIONS:")
96
- opt.on('--private', '-p', "include private and protected methods") do
97
- self.public_only = false
98
- end
99
- opt.separator " "
100
- opt.separator("GENERATOR OPTIONS:")
101
- opt.on("--uncovered", "-u", "only include missing units of uncovered methods") do
102
- self.uncovered = true
103
- end
104
- opt.separator " "
105
- opt.separator("SYSTEM OPTIONS:")
106
- opt.on("-r [FILES]" , 'files to require (before doing anything else)') do |files|
107
- files = files.split(/[:;]/)
108
- requires(*files)
109
- end
110
- opt.on("-I [PATH]" , 'locations to add to $LOAD_PATH') do |path|
111
- paths = path.split(/[:;]/)
112
- includes(*paths)
113
- end
114
- opt.on("--debug" , 'turn on debugging mode') do
115
- $DEBUG = true
116
- end
117
- opt.on_tail('--help', '-h', 'show this help message') do
118
- puts opt
119
- exit
120
- end
121
- end
122
- end
123
-
124
- # Run command.
125
- def run
126
- parser.parse!
127
- __send__(@command)
128
- end
129
-
130
- # Run unit tests.
131
- def test
132
- require 'lemon/runner'
133
-
134
- files = ARGV.dup
135
-
136
- includes.each{ |path| $LOAD_PATH.unshift(path) }
137
- requires.each{ |path| require(path) }
138
-
139
- #suite = Lemon::Test::Suite.new(files, :cover=>cover)
140
- #runner = Lemon::Runner.new(suite, :format=>format, :cover=>cover, :namespaces=>namespaces)
141
-
142
- suite = Lemon::Test::Suite.new(files)
143
- runner = Lemon::Runner.new(suite, :format=>format, :namespaces=>namespaces)
144
-
145
- runner.run
146
- end
147
-
148
- # Ouput coverage report.
149
- def cover
150
- test_files = ARGV.dup
151
- load_files = []
152
-
153
- includes.each{ |path| $LOAD_PATH.unshift(path) }
154
- requires.each{ |path| require(path) }
155
-
156
- suite = Lemon::Test::Suite.new(test_files, :cover=>true)
157
- coverage = Lemon::Coverage.new(suite, namespaces, :public=>public_only)
158
-
159
- coverage.format(format)
160
- end
161
-
162
- # Generate test templates.
163
- def generate
164
- test_files = ARGV.dup
165
-
166
- includes.each{ |path| $LOAD_PATH.unshift(path) }
167
- requires.each{ |path| require(path) }
168
-
169
- suite = Lemon::Test::Suite.new(test_files, :cover=>true, :cover_all=>true)
170
- cover = Lemon::Coverage.new(suite, namespaces, :public=>public_only)
171
- #cover = Lemon::Coverage.new([], namespaces, :public=>public_only?, :uncovered=>uncovered)
172
-
173
- if uncovered
174
- puts cover.generate_uncovered #(output)
175
- else
176
- puts cover.generate #(output)
177
- end
178
-
179
- end
180
-
181
- end
182
-
183
- end
184
-