lemon 0.9.0 → 0.9.1

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 (107) hide show
  1. data/.ruby +23 -14
  2. data/.yardopts +6 -0
  3. data/Config.rb +14 -0
  4. data/{HISTORY.rdoc → HISTORY.md} +26 -11
  5. data/LICENSE.txt +27 -0
  6. data/README.md +42 -28
  7. data/SPECSHEET.md +314 -0
  8. data/bin/{lemonade → lemons} +0 -0
  9. data/lib/lemon.yml +23 -14
  10. data/lib/lemon/cli.rb +19 -8
  11. data/lib/lemon/cli/base.rb +50 -20
  12. data/lib/lemon/cli/generate.rb +51 -16
  13. data/lib/lemon/cli/lemon.ascii +84 -0
  14. data/lib/lemon/cli/obrother.rb +35 -0
  15. data/lib/lemon/cli/scaffold.rb +116 -0
  16. data/lib/lemon/core_ext.rb +2 -2
  17. data/lib/lemon/core_ext/module.rb +9 -0
  18. data/lib/lemon/coverage/analyzer.rb +76 -5
  19. data/lib/lemon/coverage/cover_unit.rb +38 -14
  20. data/lib/lemon/coverage/formats/verbose.rb +1 -1
  21. data/lib/lemon/coverage/generator.rb +196 -0
  22. data/lib/lemon/coverage/snapshot.rb +16 -16
  23. data/lib/lemon/coverage/source_parser.rb +103 -37
  24. data/lib/lemon/ignore_callers.rb +19 -0
  25. data/lib/lemon/test_case.rb +135 -26
  26. data/lib/lemon/test_class.rb +16 -3
  27. data/lib/lemon/test_class_method.rb +58 -0
  28. data/lib/lemon/test_method.rb +57 -68
  29. data/lib/lemon/test_module.rb +47 -44
  30. data/lib/lemon/test_proc.rb +28 -2
  31. data/lib/lemon/test_scope.rb +14 -0
  32. data/lib/lemon/test_setup.rb +1 -1
  33. data/lib/lemon/test_world.rb +7 -0
  34. data/{work/deprecated/features/support → spec/applique}/ae.rb +0 -0
  35. data/spec/coverage/{01_complete.rdoc → 01_complete.md} +3 -3
  36. data/spec/coverage/{02_incomplete.rdoc → 02_incomplete.md} +2 -2
  37. data/spec/coverage/{03_extensions.rdoc → 03_extensions.md} +2 -2
  38. data/try/case_scope.rb +19 -0
  39. metadata +50 -102
  40. data/.gemspec +0 -152
  41. data/.gitignore +0 -8
  42. data/.reap/digest +0 -678
  43. data/.reap/test.reap +0 -7
  44. data/Assembly +0 -37
  45. data/COPYING.rdoc +0 -33
  46. data/MANIFEST +0 -55
  47. data/PROFILE +0 -30
  48. data/Rakefile +0 -23
  49. data/VERSION +0 -1
  50. data/lib/lemon/core_ext/omission.rb +0 -18
  51. data/lib/lemon/generator.rb +0 -149
  52. data/notes/2010-05-05-coverage.rdoc +0 -47
  53. data/notes/2010-05-06-files-not-classes.rdoc +0 -19
  54. data/notes/2010-07-11-acid-testing.rdoc +0 -52
  55. data/notes/2010-08-02-enforcing-the-unit.md +0 -68
  56. data/notes/2010-08-03-new-api.md +0 -37
  57. data/notes/2011-07-07-nailing-down-the-nomenclature.md +0 -6
  58. data/site/.rsync-filter +0 -8
  59. data/site/assets/images/cut-lemon.png +0 -0
  60. data/site/assets/images/forkme.png +0 -0
  61. data/site/assets/images/github-logo.png +0 -0
  62. data/site/assets/images/lemon.jpg +0 -0
  63. data/site/assets/images/lemon.svg +0 -39
  64. data/site/assets/images/lemons-are-good.png +0 -0
  65. data/site/assets/images/opensource.png +0 -0
  66. data/site/assets/images/ruby-logo.png +0 -0
  67. data/site/assets/images/skin.jpg +0 -0
  68. data/site/assets/images/skin1.jpg +0 -0
  69. data/site/assets/images/tap.png +0 -0
  70. data/site/assets/images/title.png +0 -0
  71. data/site/assets/styles/class.css +0 -6
  72. data/site/assets/styles/reset.css +0 -17
  73. data/site/assets/styles/site.css +0 -33
  74. data/site/index.html +0 -218
  75. data/work/deprecated/command/abstract.rb +0 -29
  76. data/work/deprecated/command/coverage.rb +0 -115
  77. data/work/deprecated/command/generate.rb +0 -124
  78. data/work/deprecated/command/test.rb +0 -112
  79. data/work/deprecated/cucumber.yml +0 -3
  80. data/work/deprecated/features/coverage.feature +0 -65
  81. data/work/deprecated/features/generate.feature +0 -66
  82. data/work/deprecated/features/step_definitions/coverage_steps.rb +0 -1
  83. data/work/deprecated/features/support/aruba.rb +0 -1
  84. data/work/deprecated/features/test.feature +0 -67
  85. data/work/deprecated/model/dsl/advice.rb +0 -78
  86. data/work/deprecated/model/dsl/subject.rb +0 -40
  87. data/work/deprecated/model/main.rb +0 -87
  88. data/work/deprecated/model/test.rb +0 -54
  89. data/work/deprecated/model/test_base_dsl.rb +0 -88
  90. data/work/deprecated/model/test_clause.rb +0 -112
  91. data/work/deprecated/model/test_context.rb +0 -90
  92. data/work/deprecated/model/test_feature.rb +0 -128
  93. data/work/deprecated/model/test_scenario.rb +0 -137
  94. data/work/deprecated/model/test_suite.rb +0 -297
  95. data/work/deprecated/rake.rb +0 -103
  96. data/work/deprecated/test/case_coverage_analyzer.rb +0 -25
  97. data/work/deprecated/test/case_test_case_dsl.rb +0 -46
  98. data/work/deprecated/test/fixtures/case_complete.rb +0 -25
  99. data/work/deprecated/test/fixtures/case_inclusion.rb +0 -18
  100. data/work/deprecated/test/fixtures/case_incomplete.rb +0 -12
  101. data/work/deprecated/test/fixtures/example.rb +0 -13
  102. data/work/deprecated/test/fixtures/helper.rb +0 -13
  103. data/work/deprecated/test/runner +0 -2
  104. data/work/old-tests/case_example.rb +0 -15
  105. data/work/old-tests/feature_example.rb +0 -40
  106. data/work/reference/dsl2.rb +0 -140
  107. data/work/reference/dynamic_constant_lookup.rb +0 -76
@@ -1,7 +0,0 @@
1
-
2
- trip :test do
3
- system "lemon -Ilib test/*.rb"
4
- system "qed -Ilib qed/"
5
- #system "cucumber"
6
- end
7
-
data/Assembly DELETED
@@ -1,37 +0,0 @@
1
- ---
2
- email:
3
- service : Email
4
- file : ~
5
- subject : ~
6
- mailto :
7
- - ruby-talk@ruby-lang.org
8
- - rubyworks-mailinglist@googlegroups.com
9
- #parts : [readme]
10
- active : true
11
-
12
- gem:
13
- active : true
14
-
15
- github: {}
16
-
17
- dnote:
18
- labels : ~
19
- output : log/DNOTE.rdoc
20
-
21
- yard:
22
- yardopts: true
23
- priority: 2
24
-
25
- qed:
26
- files: spec
27
-
28
- qedoc:
29
- title: Lemony Testing
30
- files: spec
31
- output: QED.rdoc
32
-
33
- vclog:
34
- output:
35
- - log/AHISTORY.rdoc
36
- - log/CHANGELOG.rdoc
37
-
@@ -1,33 +0,0 @@
1
- = COPYRIGHT NOTICES
2
-
3
- == Lemon
4
-
5
- Copyright:: (c)2009 Thomas Sawyer
6
- License:: BSD-2-Clause
7
- Website:: http://rubyworks.github.com/lemon
8
-
9
- Copyright 2009 Thomas Sawyer. All rights reserved.
10
-
11
- Redistribution and use in source and binary forms, with or without modification, are
12
- permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions of source code must retain the above copyright notice, this list of
15
- conditions and the following disclaimer.
16
-
17
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
18
- of conditions and the following disclaimer in the documentation and/or other materials
19
- provided with the distribution.
20
-
21
- THIS SOFTWARE IS PROVIDED BY Thomas Sawyer ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Thomas Sawyer OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-
31
- The views and conclusions contained in the software and documentation are those of the
32
- authors and should not be interpreted as representing official policies, either expressed
33
- or implied, of Thomas Sawyer.
data/MANIFEST DELETED
@@ -1,55 +0,0 @@
1
- #!mast .yardopts .ruby bin demo lib man qed spec test try [A-Z][A-Z]*
2
- .yardopts
3
- .ruby
4
- bin/lemonade
5
- lib/lemon/ae.rb
6
- lib/lemon/cli/base.rb
7
- lib/lemon/cli/coverage.rb
8
- lib/lemon/cli/generate.rb
9
- lib/lemon/cli/test.rb
10
- lib/lemon/cli.rb
11
- lib/lemon/core_ext/kernel.rb
12
- lib/lemon/core_ext/omission.rb
13
- lib/lemon/core_ext.rb
14
- lib/lemon/coverage/analyzer.rb
15
- lib/lemon/coverage/cover_unit.rb
16
- lib/lemon/coverage/formats/abstract.rb
17
- lib/lemon/coverage/formats/compact.rb
18
- lib/lemon/coverage/formats/outline.rb
19
- lib/lemon/coverage/formats/verbose.rb
20
- lib/lemon/coverage/formats/yaml.rb
21
- lib/lemon/coverage/snapshot.rb
22
- lib/lemon/coverage/source_parser.rb
23
- lib/lemon/generator.rb
24
- lib/lemon/test_advice.rb
25
- lib/lemon/test_case.rb
26
- lib/lemon/test_class.rb
27
- lib/lemon/test_method.rb
28
- lib/lemon/test_module.rb
29
- lib/lemon/test_proc.rb
30
- lib/lemon/test_setup.rb
31
- lib/lemon/test_world.rb
32
- lib/lemon.rb
33
- lib/lemon.yml
34
- spec/applique/fs.rb
35
- spec/coverage/01_complete.rdoc
36
- spec/coverage/02_incomplete.rdoc
37
- spec/coverage/03_extensions.rdoc
38
- spec/coverage/applique/lemon.rb
39
- try/.test
40
- try/case_error.rb
41
- try/case_fail.rb
42
- try/case_pass.rb
43
- try/case_pending.rb
44
- try/case_singleton.rb
45
- try/case_untested.rb
46
- try/fixtures/calculator.rb
47
- try/fixtures/example-use.rb
48
- try/fixtures/example.rb
49
- try/helpers/loadpath.rb
50
- HISTORY.rdoc
51
- PROFILE
52
- QED.rdoc
53
- README.md
54
- VERSION
55
- COPYING.rdoc
data/PROFILE DELETED
@@ -1,30 +0,0 @@
1
- ---
2
- title : Lemon
3
- summary: Pucker-tight Unit Testing
4
- authors:
5
- - Thomas Sawyer <transfire@gmail.com>
6
-
7
- description:
8
- Lemon is a unit testing framework that tightly correlates
9
- class to test case and method to test unit.
10
-
11
- resources:
12
- home: http://rubyworks.github.com/lemon
13
- code: http://github.com/rubyworks/lemon
14
-
15
- repositories:
16
- origin: git://github.com/proutils/lemon.git
17
-
18
- requirements:
19
- - test
20
- - ae
21
- - ansi 1.3+
22
- - detroit (build)
23
- - reap (build)
24
- - qed (test)
25
-
26
- organization: RubyWorks
27
-
28
- copyright: Copyright 2009 Thomas Sawyer
29
- license: BSD-2-Clause
30
-
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/rake'
4
-
5
- Test::Rake::TestTask.new do |t|
6
- t.libs << 'test/fixtures'
7
- t.tests << 'test/*.rb'
8
- end
9
-
10
- namespace :test do
11
-
12
- desc 'run lemon unit tests (via shell command)'
13
- task :unit do
14
- sh 'lemonade test -Itest/fixtures test/*.rb'
15
- end
16
-
17
- desc 'run qed demonstration tests'
18
- task :qed do
19
- sh 'qed -Ilib spec/'
20
- end
21
-
22
- end
23
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.0
@@ -1,18 +0,0 @@
1
- # The Omission class is a subclass of NotImplementedError with
2
- # it's assertion flag set to true. This will be recognized by
3
- # Ruby Test as a test omission.
4
- #
5
- # @example
6
- # test "some feature" do
7
- # raise Omission, "feature can't be tested"
8
- # end
9
- #
10
- class Omission < NotImplementedError
11
- def assertion?
12
- true
13
- end
14
- def to_proc
15
- error = self
16
- lambda{ raise error }
17
- end
18
- end
@@ -1,149 +0,0 @@
1
- module Lemon
2
-
3
- require 'lemon/coverage/analyzer'
4
-
5
- #--
6
- # TODO: Generator options for selecting all, covered and uncovered still
7
- # need some clarification.
8
- #++
9
-
10
- # Test Scaffold Generator.
11
- #
12
- class Generator
13
-
14
- # New Scaffold Generator.
15
- #
16
- # @option options [Array] :namespaces
17
- # List of class/module names to limit scaffolding.
18
- #
19
- # @option options [Boolean] :private
20
- # Include private methods in scaffolding.
21
- #
22
- # @option options [Boolean] :covered
23
- # Include covered targets in scaffolding.
24
- #
25
- # @option options [Boolean] :uncovered
26
- # Include uncovered targets in scaffolding.
27
- #
28
- # @option options [Boolean] :all
29
- # Include all possible targets in scaffolding.
30
- #
31
- def initialize(files, options={})
32
- @files = files
33
-
34
- @coverage = CoverageAnalyzer.new(files, options)
35
- @suite = @coverage.suite
36
-
37
- @namespaces = options[:namespaces]
38
- @private = options[:private]
39
- @covered = options[:covered]
40
- @uncovered = options[:uncovered]
41
- @all = options[:all]
42
-
43
- if @namespaces
44
- unless @covered or @uncovered
45
- @all = true
46
- end
47
- end
48
-
49
- end
50
-
51
- # Returns CoverageAnalyzer instance.
52
- def coverage
53
- @coverage
54
- end
55
-
56
- # List of class and module namespaces to limit scaffolding.
57
- def namespaces
58
- @namespaces
59
- end
60
-
61
- # Include all targets.
62
- def all?
63
- @all
64
- end
65
-
66
- # Include targets that are already covered.
67
- def covered?
68
- @covered
69
- end
70
-
71
- # Include only uncovered targrts.
72
- def uncovered?
73
- @uncovered
74
- end
75
-
76
- # Include private and protected methods.
77
- def private?
78
- @private
79
- end
80
-
81
- # Generate test template(s).
82
- def generate
83
- if all?
84
- generate_all
85
- elsif uncovered?
86
- generate_uncovered
87
- else
88
- generate_target
89
- end
90
- end
91
-
92
- # Generate code template for covered.
93
- def generate_target
94
- render(filter(coverage.target.units))
95
- end
96
-
97
- # Generate code template for uncovered.
98
- def generate_uncovered
99
- render(filter(coverage.uncovered))
100
- end
101
-
102
- # Generate code template for all.
103
- def generate_all
104
- render(Snapshot.capture(namespaces).units)
105
- end
106
-
107
- # Filter targets to include only specified namespaces.
108
- def filter(units)
109
- return units if namespaces.nil? or namespaces.empty?
110
- units.select do |u|
111
- namespaces.any? do |ns|
112
- /^#{ns}/ =~ u.namespace.to_s
113
- end
114
- end
115
- end
116
-
117
- # Generate code template.
118
- def render(units)
119
- code = []
120
- mods = units.group_by{ |u| u.namespace }
121
- mods.each do |mod, units|
122
- if Class === mod
123
- code << "TestClass #{mod} do"
124
- else
125
- code << "TestModule #{mod} do"
126
- end
127
- units.each do |unit|
128
- next unless private? or unit.public?
129
- if unit.function?
130
- code << "\n ClassMethod :#{unit.method} do"
131
- code << "\n Test '' do"
132
- code << "\n end"
133
- code << "end"
134
- else
135
- code << "\n Method :#{unit.method} do"
136
- code << "\n Test '' do"
137
- code << "\n end"
138
- code << "\n end"
139
- end
140
- end
141
- code << "\nend\n"
142
- end
143
-
144
- code.join("\n")
145
- end
146
-
147
- end
148
-
149
- end
@@ -1,47 +0,0 @@
1
- = 2010-05-05 Getting Good Coverage
2
-
3
- Getting good coverage analysis is not easy. The difficulty comes
4
- is determining what is of interest to the tests and what
5
- is not. That isn't so hard with completely new code, but
6
- core extensions, for instance, are challenging to isolate
7
- from original methods.
8
-
9
- Thee issue can mostly be taken care of by taking a canonical
10
- snapshot of the system before loading the tests. Then taking
11
- a snapshot after loading the tests and comparing the two.
12
- For the most part the difference will be the code in need of
13
- coverage.
14
-
15
- Unfortunately helper code still gets in the way of taking these
16
- snapshots. As a result I have determined there are only four
17
- possible complete solutions.
18
-
19
- 1) Use a Ruby lexer/parser to syntatically deconstruct the
20
- target libraries. This is a complex solution, and not one
21
- I relish trying.
22
-
23
- 2) All helpers must go in special files that are preloaded so
24
- the snapshot can isolate it from the actual target code. This
25
- means any mocks, for instance, would have to be defined in
26
- separate files for the the test(s) that might use them. This
27
- solution it good in that it actually encourges the writing
28
- reusable helper code, but it can be annoying when writting
29
- one-off mocks and such.
30
-
31
- 3) As an alternate to #2, Lemon could provide a method
32
- for specifying that a class/module or method is a helper
33
- and can simply be ignored when analysing coverage.
34
-
35
- 4) Lastly, the library file being covered can be specified
36
- with a special method, e.g. #Covers. The method would act
37
- just like +#require+ except that it takes a snapshot before and
38
- after the loading the library, and in this way builds up
39
- a table of proper coverage targets.
40
-
41
- Options #2 and #3 have proven lack luster. It's simply too
42
- much overhead involved to get good coverage. Option #4 is the most
43
- robust choice. Unfortunately coverage reports can be very slow
44
- if there are lot of files to cover --Snapshots can take a second
45
- or two to create. Hopefully it can be sped up with refinement,
46
- but at the very least the coverage reporting if optional.
47
-
@@ -1,19 +0,0 @@
1
- = 2010-05-06 Files, Not Classes
2
-
3
- Just had a realization about my approch to Lemon tests.
4
- Until now I have equated the test-case to the class/module
5
- and the test-unit to the method. That makes sense, but it means
6
- I have left out a very important factor in the the design
7
- of tests: the file.
8
-
9
- I had defined a test-suite as the entire set of tests to
10
- be run. But I think now I am mistaken. The suite should
11
- correspond to the fiel being tested. Often that will mean
12
- one test-case per test-suite, but that's okay.
13
-
14
- After the next release, 0.7.0, I will implement this
15
- refactorization. I beleive it should ultimately help
16
- improve test coverage as well.
17
-
18
-
19
-
@@ -1,52 +0,0 @@
1
- = 2010-07-11 | Kool-Aid
2
-
3
- Taking Unit Testing to the next level with a dab of DBC.
4
-
5
- Say we have,
6
-
7
- class K
8
-
9
- def f1(a1)
10
- g1(a1)
11
- end
12
-
13
- def g1(a1)
14
- a1 + 1
15
- end
16
-
17
- end
18
-
19
- Now what do we want to say about K#f1?
20
-
21
- unit K, :f1 do |a|
22
- case a
23
- when 1
24
- result do |r|
25
- r.assert == 2
26
- end
27
- end
28
- end
29
-
30
- Now later we induce labor.
31
-
32
- k = K.new
33
- k.f1(1)
34
-
35
- It does't really matter what the result class contains, or how it
36
- even gets called. Thus it can test side-effects as well as simple
37
- functional results.
38
-
39
- Okay, so how do we implement this?
40
-
41
- class K
42
-
43
- alias "f1:lemon", :f1
44
-
45
- def f1(a1)
46
- Lemon.verify_unit(binding) do
47
- send("f1:lemon", a1)
48
- end
49
- end
50
-
51
- end
52
-