lemon 0.5

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.
data/COPYING.LESSER ADDED
@@ -0,0 +1,166 @@
1
+ = GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ == 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the
17
+ GNU General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ == 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ == 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ == 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ == 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this
92
+ license document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ d.0) Convey the Minimal Corresponding Source under the terms of
102
+ this License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ d.1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ == 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ == 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
166
+
data/HISTORY ADDED
@@ -0,0 +1,13 @@
1
+ = RELEASE HISTORY
2
+
3
+ == 0.5 / 2009-12-31
4
+
5
+ This is the initial public release of Lemon. Lemon is
6
+ still under development and should be considered betaware,
7
+ but it's API is stable and the system usable enough to
8
+ warrant a release.
9
+
10
+ Changes:
11
+
12
+ * Happy First Release Day!
13
+
data/MANIFEST ADDED
@@ -0,0 +1,37 @@
1
+ COPYING
2
+ COPYING.LESSER
3
+ HISTORY
4
+ README.rdoc
5
+ bin/lemon
6
+ lib/lemon
7
+ lib/lemon.rb
8
+ lib/lemon/command.rb
9
+ lib/lemon/coverage.rb
10
+ lib/lemon/kernel.rb
11
+ lib/lemon/reporter.rb
12
+ lib/lemon/reporters
13
+ lib/lemon/reporters.rb
14
+ lib/lemon/reporters/dotprogress.rb
15
+ lib/lemon/reporters/verbose.rb
16
+ lib/lemon/runner.rb
17
+ lib/lemon/test
18
+ lib/lemon/test/case.rb
19
+ lib/lemon/test/concern.rb
20
+ lib/lemon/test/suite.rb
21
+ lib/lemon/test/unit.rb
22
+ meta/author
23
+ meta/contact
24
+ meta/copyright
25
+ meta/description
26
+ meta/homepage
27
+ meta/license
28
+ meta/name
29
+ meta/repository
30
+ meta/suite
31
+ meta/summary
32
+ meta/title
33
+ meta/version
34
+ test/cases
35
+ test/cases/coverage_case.rb
36
+ test/cases/testcase_case.rb
37
+ test/demos
data/README.rdoc ADDED
@@ -0,0 +1,108 @@
1
+ = Lemon
2
+
3
+ * http://proutils.github.com/lemon
4
+ * http://github.com/proutils/lemon
5
+
6
+
7
+ == DESCRIPTION
8
+
9
+ Lemon is a Unit Testing Framework that enforces a testcase
10
+ construction mirroring the class or module and method design
11
+ of the target system. Arguably this promotes the proper
12
+ technique for unit testing, since it helps ensure good test
13
+ coverage.
14
+
15
+ The difference between unit testing and functional testing, and
16
+ all other forms of testing for that matter, lies in where the
17
+ *concern* lies. The concern of unit testing are the concerns
18
+ of unit tests.
19
+
20
+
21
+ == HOW TO USE
22
+
23
+ Say our library consists of the class X:
24
+
25
+ class X
26
+ def a; "a"; end
27
+ end
28
+
29
+ The simplist test case would be written as follows:
30
+
31
+ TestCase X do
32
+ Unit :a => "method #a does something expected" do
33
+ x = X.new
34
+ x.a.assert.is_a? String
35
+ end
36
+ end
37
+
38
+ As tests grow, we need to organize them into concerns. For this
39
+ Lemon provides the #Concern method.
40
+
41
+ TestCase X do
42
+ Concern "Description of a concern that the following unit",
43
+ "tests address."
44
+
45
+ Unit :a => "method #a does something expected" do
46
+ x = X.new
47
+ x.a.assert.is_a? String
48
+ end
49
+ end
50
+
51
+ To run tests use the +lemon+ command-line utility.
52
+
53
+ $ lemon test/cases/name_case.rb
54
+
55
+ Normal output is typical <i>dot-progress</i>. For verbose output, use the <tt>--verbose</tt>
56
+ or <tt>-v</tt> option.
57
+
58
+ $ lemon -v test/cases/name_case.rb
59
+
60
+
61
+ == Checking Test Coverage
62
+
63
+ Lemon can check test coverage by loading your target system and
64
+ comparing it to your tests.
65
+
66
+ $ lemon --coverage -Ilib -rmyapp test/cases/
67
+
68
+
69
+ == Generating Test Skeletons
70
+
71
+ NOTE: This feature is not yet fully implemented!
72
+
73
+ Because of the one to one correspondance of case-unit to class-method, Lemon can
74
+ also generate test scaffolding for previously written code. To do this, use the
75
+ <tt>--generate</tt> option and provide the lib location, or files, of the
76
+ scripts for which to generate test scaffolding, and the output location for
77
+ the test scripts.
78
+
79
+ $ lemon --generate -rlib/ test/cases/
80
+
81
+ Generating test case scaffodling from code will undoubtedly strike test-driven developers
82
+ as a case of putting the cart before the horse. However, it is not unreasonable to argue
83
+ that high-level, behavior-driven, functional testing frameworks, such as Q.E.D. and
84
+ Cucumber are better suited to test-first methodologies. While test-driven development
85
+ can obviously be done with Lemon, unit-testing is more appropriate for testing specific,
86
+ critical protions of code, or for achieving full test coverage for mission critical
87
+ applications.
88
+
89
+
90
+ == COPYRIGHT
91
+
92
+ (LGPL License)
93
+
94
+ Copyright (c) 2009 Thomas Sawyer
95
+
96
+ This program is free software: you can redistribute it and/or modify
97
+ it under the terms of the Lesser General Public License as published by
98
+ the Free Software Foundation, either version 3 of the License, or
99
+ (at your option) any later version.
100
+
101
+ This program is distributed in the hope that it will be useful,
102
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
103
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104
+ Lesser General Public License for more details.
105
+
106
+ You should have received a copy of the Lesser General Public License
107
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
108
+
data/Syckfile ADDED
@@ -0,0 +1,68 @@
1
+ ---
2
+ box:
3
+ service: Box
4
+ active : true
5
+ types : [gem, gz]
6
+ include: [bin, lib, meta, test, "[A-Z]*"]
7
+ exclude: [Syckfile]
8
+ master : true
9
+
10
+ email:
11
+ service : Email
12
+ file : ~
13
+ subject : ~
14
+ mailto : ruby-talk@ruby-lang.org
15
+ from : <%= ENV['EMAIL_ACCOUNT'] %>
16
+ server : <%= ENV['EMAIL_SERVER'] %>
17
+ port : <%= ENV['EMAIL_PORT'] %>
18
+ account : <%= ENV['EMAIL_ACCOUNT'] %>
19
+ domain : <%= ENV['EMAIL_DOMAIN'] %>
20
+ login : <%= ENV['EMAIL_LOGIN'] %>
21
+ secure : <%= ENV['EMAIL_SECURE'] %>
22
+ active : true
23
+
24
+ dnote:
25
+ service : DNote
26
+ loadpath : ~
27
+ labels : ~
28
+ output : ~
29
+ active : true
30
+
31
+ ridoc:
32
+ service: RIDoc
33
+ include: ~
34
+ exclude: [Syckfile]
35
+ ignore : ~
36
+ active : true
37
+
38
+ stats:
39
+ service : Stats
40
+ title : ~
41
+ loadpath : ~
42
+ exclude : ~
43
+ output : ~
44
+ active : true
45
+
46
+ testrb:
47
+ service : Testrb
48
+ tests : ~
49
+ exclude : ~
50
+ loadpath : ~
51
+ requires : ~
52
+ live : false
53
+ active : false
54
+
55
+ vclog:
56
+ service : VClog
57
+ format : html # xml, txt
58
+ layout : rel # gnu
59
+ typed : false
60
+ output : ~
61
+ active : false
62
+
63
+ syntax:
64
+ service : Syntax
65
+ loadpath : ~
66
+ exclude : ~
67
+ active : false
68
+
data/bin/lemon ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'lemon/command'
3
+ Lemon::Command.run
data/lib/lemon.rb ADDED
@@ -0,0 +1 @@
1
+ require 'lemon/runner'
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lemon'
4
+ require 'lemon/coverage'
5
+ require 'optparse'
6
+ require 'yaml'
7
+
8
+ module Lemon
9
+
10
+ # Lemon Command-line tool.
11
+ class Command
12
+
13
+ # Initialize and run.
14
+ def self.run
15
+ new.run
16
+ end
17
+
18
+ attr_accessor :command
19
+ attr_accessor :format
20
+ attr_accessor :requires
21
+ attr_accessor :includes
22
+ attr_accessor :public_only
23
+
24
+ # New Command instance.
25
+ def initialize
26
+ @format = nil
27
+ @requires = []
28
+ @includes = []
29
+ @public_only = false
30
+ end
31
+
32
+ # Instance of OptionParser.
33
+ def parser
34
+ @parser ||= OptionParser.new do |opt|
35
+ opt.on('--verbose', '-v', "select verbose report format") do |type|
36
+ self.format = :verbose
37
+ end
38
+ #opt.on('--format', '-f [TYPE]', "select alternate report format") do |type|
39
+ # self.format = type
40
+ #end
41
+ opt.on('--coverage', '-c', 'produce a coverage report') do
42
+ self.command = :coverage
43
+ end
44
+ opt.on('--generate', '-g', 'generate test skeletons') do
45
+ self.command = :generate
46
+ end
47
+ opt.on('--public', '-p', "only include public methods (for -c and -g)") do
48
+ self.public_only = true
49
+ end
50
+ opt.on("-I [PATH]" , 'include in $LOAD_PATH') do |path|
51
+ self.includes = path
52
+ end
53
+ opt.on("-r [FILES]" , 'library files to require') do |files|
54
+ self.requires = files
55
+ end
56
+ opt.on("--debug" , 'turn on debugging mode') do
57
+ $DEBUG = true
58
+ end
59
+ opt.on_tail('--help', '-h', 'show this help message') do
60
+ puts opt
61
+ exit
62
+ end
63
+ end
64
+ end
65
+
66
+ #
67
+ def public_only?
68
+ @public_only
69
+ end
70
+
71
+ #
72
+ def requires=(paths)
73
+ @requires = paths.split(/[:;]/)
74
+ end
75
+
76
+ #
77
+ def includes=(paths)
78
+ @includes = paths.split(/[:;]/)
79
+ end
80
+
81
+ #
82
+ def run
83
+ parser.parse!
84
+
85
+ includes.each do |path|
86
+ $LOAD_PATHS.unshift(path)
87
+ end
88
+
89
+ tests = ARGV
90
+
91
+ case command
92
+ when :coverage
93
+ coverage(tests)
94
+ when :generate
95
+ generate(tests)
96
+ else
97
+ test(tests)
98
+ end
99
+ end
100
+
101
+ # Check test coverage.
102
+ def coverage(tests)
103
+ cover = Lemon::Coverage.new(requires, :public => public_only?)
104
+ suite = Lemon::Test::Suite.new(tests)
105
+ puts cover.coverage(suite).to_yaml
106
+ end
107
+
108
+ # Generate test skeletons.
109
+ def generate(tests)
110
+ cover = Lemon::Coverage.new(requires, :public => public_only?)
111
+ #suite = Lemon::Test::Suite.new(tests)
112
+ puts cover.generate #(suite).to_yaml
113
+ end
114
+
115
+ # Run unit tests.
116
+ def test(tests)
117
+ requires.each{ |path| require(path) }
118
+ suite = Lemon::Test::Suite.new(tests)
119
+ runner = Lemon::Runner.new(suite, format)
120
+ runner.run
121
+ end
122
+
123
+ end
124
+
125
+ end