lemon 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.ruby +55 -0
  2. data/APACHE2.txt +206 -0
  3. data/HISTORY.rdoc +12 -0
  4. data/NOTICE.rdoc +16 -0
  5. data/bin/lemon +1 -1
  6. data/demo/case_example_error.rb +10 -0
  7. data/{test/cli → features}/coverage.feature +0 -0
  8. data/{test/cli → features}/generate.feature +0 -0
  9. data/{test/cli → features}/step_definitions/coverage_steps.rb +0 -0
  10. data/{test/cli → features}/support/ae.rb +0 -0
  11. data/{test/cli → features}/support/aruba.rb +0 -0
  12. data/{test/cli → features}/test.feature +0 -0
  13. data/lib/lemon.rb +19 -1
  14. data/lib/lemon.yml +55 -0
  15. data/lib/lemon/cli.rb +0 -1
  16. data/lib/lemon/controller/test_runner.rb +12 -3
  17. data/lib/lemon/model/test_case.rb +4 -2
  18. data/lib/lemon/model/test_unit.rb +45 -2
  19. data/lib/lemon/view/test_reports/abstract.rb +107 -0
  20. data/lib/lemon/view/test_reports/tapj.rb +130 -0
  21. data/lib/lemon/view/test_reports/tapy.rb +141 -0
  22. data/qed/applique/fs.rb +21 -0
  23. data/{test/api/coverage/complete.rdoc → qed/coverage/01_complete.rdoc} +9 -9
  24. data/qed/coverage/02_incomplete.rdoc +97 -0
  25. data/{test/api/coverage/extensions.rdoc → qed/coverage/03_extensions.rdoc} +5 -5
  26. data/test/{unit/case_coverage_analyzer.rb → case_coverage_analyzer.rb} +0 -0
  27. data/test/{unit/case_test_case_dsl.rb → case_test_case_dsl.rb} +0 -0
  28. data/test/fixtures/case_complete.rb +5 -1
  29. data/test/runner +1 -2
  30. metadata +31 -39
  31. data/LICENSE +0 -22
  32. data/lib/lemon/meta/data.rb +0 -29
  33. data/lib/lemon/meta/gemfile +0 -24
  34. data/lib/lemon/meta/profile +0 -17
  35. data/meta/data.rb +0 -29
  36. data/meta/gemfile +0 -24
  37. data/meta/profile +0 -17
  38. data/test/api/applique/fs.rb +0 -18
  39. data/test/api/coverage/incomplete.rdoc +0 -97
@@ -0,0 +1,21 @@
1
+ require 'fileutils'
2
+
3
+ #Before :demo do
4
+ # FileUtils.rm_r('lib')
5
+ # FileUtils.rm_r('test')
6
+ #end
7
+
8
+ When "Given an example script in '(((.*?)))' as follows" do |name, text|
9
+ #name = File.join('tmp', name) if /^tmp/ !~ name
10
+ dir = File.dirname(name)
11
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
12
+ File.open(name, 'w'){ |w| w << text }
13
+ end
14
+
15
+ When "given a test case in '(((.*?)))' as follows" do |name, text|
16
+ #name = File.join('tmp', name) if /^tmp/ !~ name
17
+ dir = File.dirname(name)
18
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
19
+ File.open(name, 'w'){ |w| w << text }
20
+ end
21
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  === Complete Coverage of Public Interface
4
4
 
5
- Given an example script in 'tmp/lib/example.rb' as follows:
5
+ Given an example script in 'lib/complete_example.rb' as follows:
6
6
 
7
7
  class C1
8
8
  def f1; "f1"; end
@@ -18,9 +18,9 @@ Given an example script in 'tmp/lib/example.rb' as follows:
18
18
  def g3; "g3"; end
19
19
  end
20
20
 
21
- And given a test case in 'tmp/test/example_case.rb' as follows:
21
+ And given a test case in 'test/complete_example_case.rb' as follows:
22
22
 
23
- covers 'example.rb'
23
+ covers 'complete_example.rb'
24
24
 
25
25
  testcase C1 do
26
26
  unit :f1 => "Returns a String" do
@@ -40,9 +40,9 @@ And we get the coverage information via CoverageAnalyer.
40
40
 
41
41
  require 'lemon'
42
42
 
43
- tests = ['tmp/test/example_case.rb']
43
+ tests = ['test/complete_example_case.rb']
44
44
 
45
- coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'tmp/lib')
45
+ coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'lib')
46
46
 
47
47
  Then we should see that there are no uncovered units.
48
48
 
@@ -76,9 +76,9 @@ In addition there should be no uncovered_cases or undefined_units.
76
76
 
77
77
  We will use the same example classes as above, but in this case we will
78
78
  add coverage for private and protected methods as well, given a test case
79
- in 'tmp/test/example_case.rb' as follows:
79
+ in 'test/complete_example_case.rb' as follows:
80
80
 
81
- covers 'example.rb'
81
+ covers 'complete_example.rb'
82
82
 
83
83
  testcase C1 do
84
84
  unit :f1 => "Returns a String" do
@@ -102,9 +102,9 @@ And we get the coverage information via CoverageAnalyer.
102
102
 
103
103
  require 'lemon'
104
104
 
105
- tests = ['tmp/test/example_case.rb']
105
+ tests = ['test/complete_example_case.rb']
106
106
 
107
- coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'tmp/lib', :private=>true)
107
+ coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'lib', :private=>true)
108
108
 
109
109
  Notice the use of the +private+ option. This will add private and protected
110
110
  methods to the coverage analysis.
@@ -0,0 +1,97 @@
1
+ == Incomplete Coverage
2
+
3
+ === Incomplete Coverage of Public Interface
4
+
5
+ Given an example script in 'lib/incomplete_example.rb' as follows:
6
+
7
+ class I1
8
+ def f1; "f1"; end
9
+ def f2; "f2"; end
10
+ def f3; "f3"; end
11
+ end
12
+
13
+ class I2
14
+ def g1; "g1"; end
15
+ protected
16
+ def g2; "g2"; end
17
+ private
18
+ def g3; "g3"; end
19
+ end
20
+
21
+ class I3
22
+ def h1; "h1"; end
23
+ end
24
+
25
+ And given a test case in 'test/incomplete_example_case.rb' as follows:
26
+
27
+ covers 'incomplete_example.rb'
28
+
29
+ testcase I1 do
30
+ unit :f1 => "Returns a String" do
31
+ end
32
+ unit :f2 => "Returns a String" do
33
+ end
34
+ end
35
+
36
+ testcase I2 do
37
+ unit :x1 => "Does not exist" do
38
+ end
39
+ end
40
+
41
+ And we get the coverage information via CoverageAnalyer.
42
+
43
+ require 'lemon'
44
+
45
+ tests = ['test/incomplete_example_case.rb']
46
+
47
+ coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'lib')
48
+
49
+ Then we should see that there are 2 unconvered units, I1#f3 and I2#g1
50
+ because no testcase unit was defined for them and they are both public methods.
51
+
52
+ units = coverage.uncovered_units.map{ |u| u.to_s }
53
+
54
+ units.assert.include?('I1#f3')
55
+ units.assert.include?('I2#g1')
56
+
57
+ units.size.assert == 2
58
+
59
+ You might expect that 'I3#h1' would be in the uncovered units list as well,
60
+ since it is a public method and no test unit covers it. However, there is
61
+ no test case for I3 at all, so Lemon takes that to mean that I3 is of
62
+ no interest.
63
+
64
+ units.refute.include?('I3#h1')
65
+
66
+ But I3 will be listed in the uncovered cases list.
67
+
68
+ coverage.uncovered_cases == [I3]
69
+
70
+ Note that uncovered case methods can be included in the uncovered units list
71
+ by setting the +zealous+ option, which we will demonstrate later.
72
+
73
+ There should still be 3 covered units, I1#f1, I1#f2 and I2#x1.
74
+
75
+ coverage.covered_units.size.assert == 3
76
+
77
+ units = coverage.covered_units.map{ |u| u.to_s }
78
+
79
+ units.assert.include?('I1#f1')
80
+ units.assert.include?('I1#f2')
81
+ units.assert.include?('I2#x1')
82
+
83
+ But we will not find any covered units for class I2.
84
+
85
+ units.refute.include?('I2#g1')
86
+ units.refute.include?('I2#g2')
87
+ units.refute.include?('I2#g3')
88
+
89
+ Notice also that we defined a unit for I2#x1, a method that does not exist.
90
+ So it should be listed in the undefined units list.
91
+
92
+ coverage.undefined_units.size.assert == 1
93
+
94
+ units = coverage.undefined_units.map{ |u| u.to_s }
95
+
96
+ units.assert.include?('I2#x1')
97
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  === Kernel Extensions
4
4
 
5
- Given an example script in 'tmp/lib/example.rb' as follows:
5
+ Given an example script in 'lib/extensions_example.rb' as follows:
6
6
 
7
7
  module Kernel
8
8
  def f1; "f1"; end
@@ -10,9 +10,9 @@ Given an example script in 'tmp/lib/example.rb' as follows:
10
10
  def f3; "f3"; end
11
11
  end
12
12
 
13
- And given a test case in 'tmp/test/example_case.rb' as follows:
13
+ And given a test case in 'test/extensions_example_case.rb' as follows:
14
14
 
15
- covers 'example.rb'
15
+ covers 'extensions_example.rb'
16
16
 
17
17
  tests Kernel do
18
18
  unit :f1 do
@@ -27,9 +27,9 @@ And we get the coverage information via CoverageAnalyer.
27
27
 
28
28
  require 'lemon'
29
29
 
30
- tests = ['tmp/test/example_case.rb']
30
+ tests = ['test/extensions_example_case.rb']
31
31
 
32
- coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'tmp/lib')
32
+ coverage = Lemon::CoverageAnalyzer.new(tests, :loadpath=>'lib')
33
33
 
34
34
  Then we should see that there are two covered units, #f1 and #f2.
35
35
 
@@ -3,19 +3,23 @@ covers File.dirname(__FILE__) + '/example.rb'
3
3
  testcase X do
4
4
 
5
5
  unit :a => "Returns a String" do
6
+ X.new.a
6
7
  end
7
8
 
8
9
  unit :b => "Returns a String" do
10
+ X.new.b
9
11
  end
10
12
 
11
13
  unit :c => "Returns a String" do
14
+ X.new.c
12
15
  end
13
16
 
14
17
  end
15
18
 
16
- testrcase Y do
19
+ testcase Y do
17
20
 
18
21
  unit :q => "Returns a String" do
22
+ Y.new.q
19
23
  end
20
24
 
21
25
  end
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env ruby
2
- system 'lemon -v test/unit/*.rb'
3
- system 'cucumber'
2
+ system 'lemon -Ilib -v test/*.rb'
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: 59
5
- prerelease: false
4
+ hash: 57
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-05 00:00:00 -04:00
19
- default_executable:
18
+ date: 2011-05-19 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: ae
@@ -33,7 +32,7 @@ dependencies:
33
32
  type: :runtime
34
33
  version_requirements: *id001
35
34
  - !ruby/object:Gem::Dependency
36
- name: syckle
35
+ name: redline
37
36
  prerelease: false
38
37
  requirement: &id002 !ruby/object:Gem::Requirement
39
38
  none: false
@@ -47,7 +46,7 @@ dependencies:
47
46
  type: :development
48
47
  version_requirements: *id002
49
48
  - !ruby/object:Gem::Dependency
50
- name: box
49
+ name: reap
51
50
  prerelease: false
52
51
  requirement: &id003 !ruby/object:Gem::Requirement
53
52
  none: false
@@ -61,7 +60,7 @@ dependencies:
61
60
  type: :development
62
61
  version_requirements: *id003
63
62
  - !ruby/object:Gem::Dependency
64
- name: cucumber
63
+ name: qed
65
64
  prerelease: false
66
65
  requirement: &id004 !ruby/object:Gem::Requirement
67
66
  none: false
@@ -75,7 +74,7 @@ dependencies:
75
74
  type: :development
76
75
  version_requirements: *id004
77
76
  - !ruby/object:Gem::Dependency
78
- name: ae
77
+ name: cucumber
79
78
  prerelease: false
80
79
  requirement: &id005 !ruby/object:Gem::Requirement
81
80
  none: false
@@ -111,20 +110,25 @@ extensions: []
111
110
  extra_rdoc_files:
112
111
  - README.rdoc
113
112
  files:
113
+ - .ruby
114
114
  - bin/lemon
115
+ - demo/case_example_error.rb
115
116
  - demo/case_example_fail.rb
116
117
  - demo/case_example_pass.rb
117
118
  - demo/case_example_pending.rb
118
119
  - demo/case_example_untested.rb
119
120
  - demo/fixture/example-use.rb
120
121
  - demo/fixture/example.rb
122
+ - features/coverage.feature
123
+ - features/generate.feature
124
+ - features/step_definitions/coverage_steps.rb
125
+ - features/support/ae.rb
126
+ - features/support/aruba.rb
127
+ - features/test.feature
121
128
  - lib/lemon/cli.rb
122
129
  - lib/lemon/controller/coverage_analyzer.rb
123
130
  - lib/lemon/controller/scaffold_generator.rb
124
131
  - lib/lemon/controller/test_runner.rb
125
- - lib/lemon/meta/data.rb
126
- - lib/lemon/meta/gemfile
127
- - lib/lemon/meta/profile
128
132
  - lib/lemon/model/ae.rb
129
133
  - lib/lemon/model/cover_unit.rb
130
134
  - lib/lemon/model/main.rb
@@ -146,33 +150,27 @@ files:
146
150
  - lib/lemon/view/test_reports/outline.rb
147
151
  - lib/lemon/view/test_reports/summary.rb
148
152
  - lib/lemon/view/test_reports/tap.rb
153
+ - lib/lemon/view/test_reports/tapj.rb
154
+ - lib/lemon/view/test_reports/tapy.rb
149
155
  - lib/lemon/view/test_reports/verbose.rb
150
156
  - lib/lemon.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
157
+ - lib/lemon.yml
158
+ - qed/applique/fs.rb
159
+ - qed/coverage/01_complete.rdoc
160
+ - qed/coverage/02_incomplete.rdoc
161
+ - qed/coverage/03_extensions.rdoc
162
+ - test/case_coverage_analyzer.rb
163
+ - test/case_test_case_dsl.rb
164
164
  - test/fixtures/case_complete.rb
165
165
  - test/fixtures/case_inclusion.rb
166
166
  - test/fixtures/case_incomplete.rb
167
167
  - test/fixtures/example.rb
168
168
  - test/fixtures/helper.rb
169
169
  - test/runner
170
- - test/unit/case_coverage_analyzer.rb
171
- - test/unit/case_test_case_dsl.rb
172
170
  - HISTORY.rdoc
173
- - LICENSE
171
+ - APACHE2.txt
174
172
  - README.rdoc
175
- has_rdoc: true
173
+ - NOTICE.rdoc
176
174
  homepage: http://proutils.github.com/lemon
177
175
  licenses:
178
176
  - Apache 2.0
@@ -205,15 +203,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
203
  requirements: []
206
204
 
207
205
  rubyforge_project: lemon
208
- rubygems_version: 1.3.7
206
+ rubygems_version: 1.8.2
209
207
  signing_key:
210
208
  specification_version: 3
211
209
  summary: Pucker-tight Unit Testing
212
- test_files:
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
210
+ test_files: []
211
+
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) 2009 Thomas Sawyer
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,29 +0,0 @@
1
- Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION) # becuase Ruby 1.8~ gets in the way
2
-
3
- module Lemon
4
-
5
- def self.__DIR__
6
- File.dirname(__FILE__)
7
- end
8
-
9
- def self.gemfile
10
- @gemfile ||= (
11
- require 'yaml'
12
- YAML.load(File.new(__DIR__ + '/gemfile'))
13
- )
14
- end
15
-
16
- def self.profile
17
- @profile ||= (
18
- require 'yaml'
19
- YAML.load(File.new(__DIR__ + '/profile'))
20
- )
21
- end
22
-
23
- def self.const_missing(name)
24
- key = name.to_s.downcase
25
- gemfile[key] || profile[key] || super(name)
26
- end
27
-
28
- end
29
-