lemon 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
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,29 +0,0 @@
1
- module Lemon
2
- module Command
3
- require 'optparse'
4
-
5
- # Lemon Command-line tool base class.
6
- class Abstract
7
-
8
- # Used to map command-line options to command classes.
9
- # This must be overridden in subclasses, and return an
10
- # array of of options, e.g. [ '-g', '--generate'].
11
- def self.options
12
- raise "not implemented"
13
- end
14
-
15
- # Stores a list of command classes.
16
- def self.commands
17
- @commands ||= []
18
- end
19
-
20
- # When this class is inherited, it is registered to the commands list.
21
- def self.inherited(command_class)
22
- commands << command_class
23
- end
24
-
25
- end
26
-
27
- end
28
- end
29
-
@@ -1,115 +0,0 @@
1
- module Lemon
2
- module Command
3
- require 'lemon/command/abstract'
4
-
5
- # Lemon Coverage Command-line tool.
6
- class Coverage < Abstract
7
- require 'yaml'
8
- require 'lemon/coverage'
9
-
10
- def self.subcommand
11
- 'coverage' #['-c', '--coverage']
12
- end
13
-
14
- # Initialize and run.
15
- def self.run
16
- new.run
17
- end
18
-
19
- # New Command instance.
20
- def initialize
21
- @format = nil
22
- @requires = []
23
- @includes = []
24
- @namespaces = []
25
- @public_only = false
26
- end
27
-
28
- #
29
- attr_accessor :format
30
-
31
- #
32
- attr_accessor :public_only
33
-
34
- #
35
- def public_only?
36
- @public_only
37
- end
38
-
39
- # Get or set librarires to pre-require.
40
- def requires(*paths)
41
- @requires.concat(paths) unless paths.empty?
42
- @requires
43
- end
44
-
45
- # Get or set paths to include in $LOAD_PATH.
46
- def includes(*paths)
47
- @includes.concat(paths) unless paths.empty?
48
- @includes
49
- end
50
-
51
- # Get or set paths to include in $LOAD_PATH.
52
- def namespaces(*names)
53
- @namespaces.concat(names) unless names.empty?
54
- @namespaces
55
- end
56
-
57
- # Instance of OptionParser.
58
- def parser
59
- @parser ||= OptionParser.new do |opt|
60
- opt.banner = "lemon coverage [OPTIONS]"
61
- opt.separator("Produce test coverage report.")
62
- opt.on('--verbose', '-v', "select verbose report format") do |type|
63
- self.format = :verbose
64
- end
65
- #opt.on('--outline', '-o', "select outline report format") do |type|
66
- # self.format = :outline
67
- #end
68
- #opt.on('--format', '-f [TYPE]', "select report format") do |type|
69
- # self.format = type
70
- #end
71
- opt.on('--namespace', '-n [NAME]', "limit coverage to this namespace") do |name|
72
- namespaces(name)
73
- end
74
- opt.on('--public', '-p', "only include public methods") do
75
- self.public_only = true
76
- end
77
- opt.on("-r [FILES]" , 'library files to require') do |files|
78
- files = files.split(/[:;]/)
79
- requires(*files)
80
- end
81
- opt.on("-I [PATH]" , 'include in $LOAD_PATH') do |path|
82
- path = path.split(/[:;]/)
83
- includes(*path)
84
- end
85
- opt.on("--debug" , 'turn on debugging mode') do
86
- $DEBUG = true
87
- end
88
- opt.on_tail('--help', '-h', 'show this help message') do
89
- puts opt
90
- exit
91
- end
92
- end
93
- end
94
-
95
- #
96
- def run
97
- parser.parse!
98
-
99
- test_files = ARGV.dup
100
- load_files = []
101
-
102
- includes.each{ |path| $LOAD_PATH.unshift(path) }
103
- requires.each{ |path| require(path) }
104
-
105
- suite = Lemon::Test::Suite.new(test_files, :cover=>true)
106
- coverage = Lemon::Coverage.new(suite, namespaces, :public=>public_only?)
107
-
108
- coverage.format(format)
109
- end
110
-
111
- end
112
-
113
- end
114
- end
115
-
@@ -1,124 +0,0 @@
1
- module Lemon
2
- module Command
3
- require 'lemon/command/abstract'
4
-
5
- # Lemon Generate Command-line tool.
6
- class Generate < Abstract
7
- require 'lemon/coverage'
8
-
9
- #
10
- def self.subcommand
11
- 'generate' #['-g', '--generate']
12
- end
13
-
14
- # Initialize and run.
15
- def self.run
16
- new.run
17
- end
18
-
19
- # New Command instance.
20
- def initialize
21
- @requires = []
22
- @includes = []
23
- @namespaces = []
24
- @public_only = false
25
- @uncovered = false
26
- end
27
-
28
- # TODO: Support output ? perhaps complex scaffolding
29
- #attr_accessor :output
30
-
31
- #
32
- attr_accessor :public_only
33
-
34
- #
35
- attr_accessor :uncovered
36
-
37
- #
38
- def public_only?
39
- @public_only
40
- end
41
-
42
- #
43
- def uncovered_only?
44
- @uncovered
45
- end
46
-
47
- # Get or set librarires to pre-require.
48
- def requires(*paths)
49
- @requires.concat(paths) unless paths.empty?
50
- @requires
51
- end
52
-
53
- # Get or set paths to include in $LOAD_PATH.
54
- def includes(*paths)
55
- @includes.concat(paths) unless paths.empty?
56
- @includes
57
- end
58
-
59
- #
60
- def namespaces(*names)
61
- @namespaces.concat(names) unless names.empty?
62
- @namespaces
63
- end
64
-
65
- # Instance of OptionParser.
66
- def parser
67
- @parser ||= OptionParser.new do |opt|
68
- opt.banner = "lemon generate [OPTIONS]"
69
- opt.separator("Generate unit test scaffolding.")
70
- opt.on("--namespace", "-n [NAME]", "limit tests to this namespace") do |name|
71
- namespaces(name)
72
- end
73
- opt.on("--public", "-p", "only include public methods") do
74
- self.public_only = true
75
- end
76
- opt.on("--uncovered", "-u", "only include uncovered methods") do
77
- self.uncovered = true
78
- end
79
- #opt.on("--output", "-o [PATH]", "output directory") do |path|
80
- # self.output = path
81
- #end
82
- opt.on("-r [FILES]" , "library files to require") do |files|
83
- files = files.split(/[:;]/)
84
- requires(*files)
85
- end
86
- opt.on("-I [PATH]" , "include in $LOAD_PATH") do |path|
87
- path = path.split(/[:;]/)
88
- includes(*path)
89
- end
90
- opt.on("--debug" , "turn on debugging mode") do
91
- $DEBUG = true
92
- end
93
- opt.on_tail("--help", "-h", "show this help message") do
94
- puts opt
95
- exit
96
- end
97
- end
98
- end
99
-
100
- # Generate test skeletons.
101
- def run
102
- parser.parse!
103
-
104
- test_files = ARGV.dup
105
-
106
- includes.each{ |path| $LOAD_PATH.unshift(path) }
107
- requires.each{ |path| require(path) }
108
-
109
- suite = Lemon::Test::Suite.new(test_files, :cover=>true)
110
- cover = Lemon::Coverage.new(suite, namespaces, :public=>public_only?)
111
- #cover = Lemon::Coverage.new([], namespaces, :public=>public_only?, :uncovered=>uncovered_only?)
112
-
113
- if uncovered_only?
114
- puts cover.generate_uncovered #(output)
115
- else
116
- puts cover.generate #(output)
117
- end
118
- end
119
-
120
- end
121
-
122
- end
123
- end
124
-
@@ -1,112 +0,0 @@
1
- module Lemon
2
- module Command
3
- require 'lemon/command/abstract'
4
-
5
- # Lemon Test Command-line tool.
6
- class Test < Abstract
7
- require 'lemon/runner'
8
-
9
- def self.subcommand
10
- 'test'
11
- end
12
-
13
- # Initialize and run.
14
- def self.run
15
- new.run
16
- end
17
-
18
- # New Command instance.
19
- def initialize
20
- @format = nil
21
- @cover = false
22
- @requires = []
23
- @includes = []
24
- @namespaces = []
25
- end
26
-
27
- #
28
- attr_accessor :format
29
-
30
- #
31
- attr_accessor :cover
32
-
33
- # Get or set librarires to pre-require.
34
- def requires(*paths)
35
- @requires.concat(paths) unless paths.empty?
36
- @requires
37
- end
38
-
39
- # Get or set paths to include in $LOAD_PATH.
40
- def includes(*paths)
41
- @includes.concat(paths) unless paths.empty?
42
- @includes
43
- end
44
-
45
- #
46
- def namespaces(*names)
47
- @namespaces.concat(names) unless names.empty?
48
- @namespaces
49
- end
50
-
51
- # Instance of OptionParser.
52
- def parser
53
- @parser ||= OptionParser.new do |opt|
54
- opt.banner = "lemon [options] [test-files ...]"
55
- opt.separator("Run unit tests.")
56
- opt.separator("OPTIONS:")
57
- #opt.on('--coverage', '-c', "include coverage informarton") do
58
- # self.cover = true
59
- #end
60
- opt.on('--verbose', '-v', "select verbose report format") do |type|
61
- self.format = :verbose
62
- end
63
- opt.on('--outline', '-o', "select outline report format") do |type|
64
- self.format = :outline
65
- end
66
- opt.on('--format', '-f [TYPE]', "select report format") do |type|
67
- self.format = type
68
- end
69
- opt.on("--namespace", "-n [NAME]", "limit testing to this namespace") do |name|
70
- namespaces(name)
71
- end
72
- opt.on("-r [FILES]" , 'library files to require') do |files|
73
- files = files.split(/[:;]/)
74
- requires(*files)
75
- end
76
- opt.on("-I [PATH]" , 'include in $LOAD_PATH') do |path|
77
- paths = path.split(/[:;]/)
78
- includes(*paths)
79
- end
80
- opt.on("--debug" , 'turn on debugging mode') do
81
- $DEBUG = true
82
- end
83
- opt.on_tail('--help', '-h', 'show this help message') do
84
- puts opt
85
- exit
86
- end
87
- end
88
- end
89
-
90
- # Run unit tests.
91
- def run
92
- parser.parse!
93
-
94
- files = ARGV.dup
95
-
96
- includes.each{ |path| $LOAD_PATH.unshift(path) }
97
- requires.each{ |path| require(path) }
98
-
99
- #suite = Lemon::Test::Suite.new(files, :cover=>cover)
100
- #runner = Lemon::Runner.new(suite, :format=>format, :cover=>cover, :namespaces=>namespaces)
101
-
102
- suite = Lemon::Test::Suite.new(files)
103
- runner = Lemon::Runner.new(suite, :format=>format, :namespaces=>namespaces)
104
-
105
- runner.run
106
- end
107
-
108
- end
109
-
110
- end
111
- end
112
-
@@ -1,3 +0,0 @@
1
- default: features
2
- profile: --format profile features
3
- log: --format progress --format html --out=log/cucumber/index.html features
@@ -1,65 +0,0 @@
1
- Feature: Coverage
2
- As a developer
3
- In order to improve test coverge
4
- I want to able to write tests with coverage in mind
5
- And receive effective coverage reports
6
-
7
- Scenario: Complete Example Case
8
- Given a directory named "example"
9
- Given a file named "example/lib/example.rb" with:
10
- """
11
- class X
12
- def a; "a"; end
13
- def b; "b"; end
14
- def c; "c"; end
15
- end
16
- class Y
17
- def q; "q"; end
18
- end
19
- """
20
- Given a file named "example/test/case_complete.rb" with:
21
- """
22
- Covers 'example'
23
- TestCase X do
24
- Unit :a => "Returns a String" do ; end
25
- Unit :b => "Returns a String" do ; end
26
- Unit :c => "Returns a String" do ; end
27
- end
28
- TestCase Y do
29
- Unit :q => "Returns a String" do ; end
30
- end
31
- """
32
- When I cd to "example"
33
- And I run "lemon -c -Ilib test/case_complete.rb"
34
- Then the stdout should contain "0 uncovered cases"
35
- And the stdout should contain "0/4 uncovered"
36
- And the stdout should contain "0 undefined units"
37
-
38
- Scenario: Incomplete Example Case
39
- Given a directory named "example"
40
- Given a file named "example/lib/example.rb" with:
41
- """
42
- class X
43
- def a; "a"; end
44
- def b; "b"; end
45
- def c; "c"; end
46
- end
47
- class Y
48
- def q; "q"; end
49
- end
50
- """
51
- Given a file named "example/test/case_incomplete.rb" with:
52
- """
53
- Covers 'example'
54
- TestCase X do
55
- Unit :a => "Returns a String" do ; end
56
- Unit :b => "Returns a String" do ; end
57
- Unit :d => "Returns a String" do ; end
58
- end
59
- """
60
- When I cd to "example"
61
- And I run "lemon -c -Ilib test/case_incomplete.rb"
62
- Then the stdout should contain "1 uncovered cases"
63
- And the stdout should contain "1/4 uncovered"
64
- And the stdout should contain "1 undefined units"
65
-