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,25 +0,0 @@
1
- covers 'example.rb'
2
-
3
- testcase X do
4
-
5
- unit :a => "Returns a String" do
6
- X.new.a
7
- end
8
-
9
- unit :b => "Returns a String" do
10
- X.new.b
11
- end
12
-
13
- unit :c => "Returns a String" do
14
- X.new.c
15
- end
16
-
17
- end
18
-
19
- testcase Y do
20
-
21
- unit :q => "Returns a String" do
22
- Y.new.q
23
- end
24
-
25
- end
@@ -1,18 +0,0 @@
1
- covers 'example.rb'
2
-
3
- require '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,12 +0,0 @@
1
- covers 'example.rb'
2
-
3
- testcase X do
4
-
5
- unit :a => "Returns a String" do
6
- end
7
-
8
- unit :b => "Returns a String" do
9
- end
10
-
11
- end
12
-
@@ -1,13 +0,0 @@
1
- class X
2
- def a; "a"; end
3
- def b; "b"; end
4
- def c; "c"; end
5
- end
6
- class Y
7
- def q; "q"; end
8
- protected
9
- def r; "r"; end
10
- private
11
- def s; "s"; end
12
- end
13
-
@@ -1,13 +0,0 @@
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
-
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env ruby
2
- system 'lemon -Ilib -v test/*.rb'
@@ -1,15 +0,0 @@
1
- Test.case "Example Case" do
2
-
3
- test "Example Test" do
4
- "example".assert == "example"
5
- end
6
-
7
- context "Example Context" do
8
-
9
- test do
10
- "example".assert == "example"
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,40 +0,0 @@
1
- Test::Feature "Addition" do
2
- To "avoid silly mistakes"
3
- As "a math idiot"
4
- We "need to calculate the sum of numbers"
5
-
6
- Scenario "Add two numbers" do
7
- Given "I have a calculator"
8
- Given "I have entered 50 into the calculator"
9
- Given "I have entered 70 into the calculator"
10
- When "I press add"
11
- Then "the result should be 120 on the screen"
12
- end
13
-
14
- Scenario "Add three numbers" do
15
- Given "I have a calculator"
16
- Given "I have entered 50 into the calculator"
17
- Given "I have entered 70 into the calculator"
18
- Given "I have entered 90 into the calculator"
19
- When "I press add"
20
- Then "the result should be 210 on the screen"
21
- end
22
-
23
- Given 'I have a calculator' do
24
- require 'calculator'
25
- @calculator = Calculator.new
26
- end
27
-
28
- Given 'I have entered (((\d+))) into the calculator' do |n|
29
- @calculator.push n.to_i
30
- end
31
-
32
- When 'I press add' do
33
- @result = @calculator.add
34
- end
35
-
36
- Then 'the result should be (((\d+))) on the screen' do |n|
37
- @result.assert == n.to_i
38
- end
39
- end
40
-
@@ -1,140 +0,0 @@
1
- require 'ae'
2
-
3
- module Lemon
4
-
5
- def self.suite
6
- @suite ||= Suite.new(Runner.new(Reporter.new))
7
- end
8
-
9
- def self.suite=(suite)
10
- @suite = suite
11
- end
12
-
13
- class Context
14
- def initialize(desc=nil)
15
- @desc = desc
16
- @before = {}
17
- @after = {}
18
- end
19
-
20
- def description
21
- @desc
22
- end
23
-
24
- def before(which, &block)
25
- @before[which] = block if block
26
- @before[which]
27
- end
28
-
29
- def after(which, &block)
30
- @after[which] = block if block
31
- @after[which]
32
- end
33
- end
34
-
35
- class Suite
36
- def initialize(runner)
37
- @runner = runner
38
- end
39
-
40
- def before(which, &block)
41
- @runner.before(which, &block)
42
- end
43
-
44
- def after(which, &block)
45
- @runner.after(which, &block)
46
- end
47
-
48
- def unit(mod, meth, desc=nil, &block)
49
- @runner.unit(mod, meth, desc, &block)
50
- end
51
-
52
- def context(desc, &block)
53
- @runner.context(desc, &block)
54
- end
55
- end
56
-
57
- # Runner is a listner.
58
- class Runner
59
- #
60
- def initialize(*reporters)
61
- @reporters = reporters
62
- #@before = {} #Hash.new{|h,k| h[k]=[]}
63
- #@after = {} #Hash.new{|h,k| h[k]=[]}
64
- @context_stack = [Context.new]
65
- end
66
-
67
- def before(which, &block)
68
- @context_stack.last.before(which, &block)
69
- @reporters.each do |reporter|
70
- reporter.before(which, &block)
71
- end
72
- end
73
-
74
- def after(which, &block)
75
- @context_stack.last.after(which, &block)
76
- @reporters.each do |reporter|
77
- reporter.after(which, &block)
78
- end
79
- end
80
-
81
- def instance(desc, &block)
82
- @instance = Context.new(desc, &block)
83
- end
84
-
85
- def unit(mod, meth, desc=nil, &block)
86
- @reporters.each do |reporter|
87
- reporter.unit(mod, meth, desc, &block)
88
- end
89
-
90
- if @instance && block.arity != 0
91
- block.call(@instance.call)
92
- else
93
- block.call
94
- end
95
-
96
- end
97
- end
98
-
99
- class Reporter
100
- #
101
- def initialize
102
- end
103
-
104
- def before(which, &block)
105
- end
106
-
107
- def after(which, &block)
108
- end
109
-
110
- def unit(mod, meth, desc=nil, &block)
111
- puts "%s#%s %s" % [mod.name, meth.to_s, desc]
112
- end
113
- end
114
-
115
- end
116
-
117
-
118
- #
119
- def before(which, &block)
120
- Lemon.suite.before(which, &block)
121
- end
122
-
123
- #
124
- def after(which, &block)
125
- Lemon.suite.after(which, &block)
126
- end
127
-
128
- # @example
129
- # unit Example, :foo, "desciption" do
130
- # ...
131
- # end
132
- #
133
- def unit(mod, meth, desc=nil, &blk)
134
- Lemon.suite.unit(mod, meth, desc, &blk)
135
- end
136
-
137
- def context(desc, &block)
138
- Lemon.suite.context(desc, &block)
139
- end
140
-
@@ -1,76 +0,0 @@
1
- #
2
- module M
3
- def m1; "m1"; end
4
- module N
5
- def self.n1; "n1"; end
6
- end
7
- end
8
-
9
- class X
10
- class << self
11
- alias _new new
12
- def new(&block)
13
- klass = Class.new(self)
14
- klass.module_eval(&block)
15
- klass._new
16
- end
17
- end
18
-
19
- def m ; m1 ; end
20
- def n ; N.n1 ; end
21
- end
22
-
23
- x = X.new do
24
- include M
25
- end
26
-
27
- p x.m
28
- p x.n
29
-
30
-
31
- exit
32
-
33
- class X
34
- attr :set
35
- def initialize(&block)
36
- @set = {}
37
- instance_eval(&block)
38
- end
39
- def defset(name, &block)
40
- @set[name] = block
41
- end
42
- def include(*mods)
43
- (class << self; self; end).class_eval do
44
- include *mods
45
- end
46
- end
47
- end
48
-
49
- #
50
- module M
51
- def m1; "m1"; end
52
- module N
53
- def self.n1; "n1"; end
54
- end
55
- end
56
-
57
- x = X.new do
58
-
59
- include M
60
-
61
- #Before /returns/ do |unit|
62
- # puts "returns something"
63
- #end
64
-
65
- defset :m do
66
- m1 == "m1"
67
- end
68
-
69
- defset :n do
70
- N.n1 == "n1"
71
- end
72
-
73
- end
74
-
75
- x.set[:m].call
76
- x.set[:n].call