lemon 0.8.5 → 0.9.0

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 (113) hide show
  1. data/{lemon.gemspec → .gemspec} +0 -0
  2. data/.ruby +4 -11
  3. data/Assembly +5 -11
  4. data/HISTORY.rdoc +31 -0
  5. data/MANIFEST +45 -55
  6. data/PROFILE +6 -6
  7. data/README.md +113 -0
  8. data/Rakefile +12 -3
  9. data/VERSION +1 -1
  10. data/bin/lemonade +8 -0
  11. data/lib/lemon.rb +52 -2
  12. data/lib/lemon.yml +4 -11
  13. data/lib/lemon/{model/ae.rb → ae.rb} +0 -0
  14. data/lib/lemon/cli.rb +28 -279
  15. data/lib/lemon/cli/base.rb +139 -0
  16. data/lib/lemon/cli/coverage.rb +52 -0
  17. data/lib/lemon/cli/generate.rb +51 -0
  18. data/lib/lemon/cli/test.rb +50 -0
  19. data/lib/lemon/core_ext.rb +7 -0
  20. data/lib/lemon/core_ext/kernel.rb +20 -0
  21. data/lib/lemon/core_ext/omission.rb +18 -0
  22. data/lib/lemon/{controller/coverage_analyzer.rb → coverage/analyzer.rb} +41 -19
  23. data/lib/lemon/{model → coverage}/cover_unit.rb +0 -0
  24. data/lib/lemon/{view/cover_reports → coverage/formats}/abstract.rb +0 -0
  25. data/lib/lemon/{view/cover_reports → coverage/formats}/compact.rb +1 -1
  26. data/lib/lemon/{view/cover_reports → coverage/formats}/outline.rb +1 -1
  27. data/lib/lemon/{view/cover_reports → coverage/formats}/verbose.rb +1 -1
  28. data/lib/lemon/{view/cover_reports → coverage/formats}/yaml.rb +1 -1
  29. data/lib/lemon/{model → coverage}/snapshot.rb +0 -0
  30. data/lib/lemon/{model → coverage}/source_parser.rb +0 -0
  31. data/lib/lemon/{controller/scaffold_generator.rb → generator.rb} +53 -14
  32. data/lib/lemon/test_advice.rb +63 -0
  33. data/lib/lemon/test_case.rb +270 -0
  34. data/lib/lemon/test_class.rb +28 -0
  35. data/lib/lemon/test_method.rb +207 -0
  36. data/lib/lemon/test_module.rb +114 -0
  37. data/lib/lemon/test_proc.rb +140 -0
  38. data/lib/lemon/test_setup.rb +54 -0
  39. data/lib/lemon/test_world.rb +9 -0
  40. data/notes/{2010-05-06-files_not_classes.rdoc → 2010-05-06-files-not-classes.rdoc} +0 -0
  41. data/notes/{2010-07-11-acid_testing.rdoc → 2010-07-11-acid-testing.rdoc} +0 -0
  42. data/notes/2011-07-07-nailing-down-the-nomenclature.md +6 -0
  43. data/site/index.html +7 -6
  44. data/{qed → spec}/applique/fs.rb +0 -0
  45. data/{qed → spec}/coverage/01_complete.rdoc +26 -16
  46. data/{qed → spec}/coverage/02_incomplete.rdoc +10 -7
  47. data/{qed → spec}/coverage/03_extensions.rdoc +10 -6
  48. data/spec/coverage/applique/lemon.rb +1 -0
  49. data/try/.test +8 -0
  50. data/try/case_error.rb +18 -0
  51. data/try/case_fail.rb +19 -0
  52. data/try/case_pass.rb +42 -0
  53. data/try/case_pending.rb +18 -0
  54. data/try/case_singleton.rb +18 -0
  55. data/try/case_untested.rb +14 -0
  56. data/try/fixtures/calculator.rb +15 -0
  57. data/{demo/fixture → try/fixtures}/example-use.rb +0 -0
  58. data/{demo/fixture → try/fixtures}/example.rb +0 -0
  59. data/try/helpers/loadpath.rb +1 -0
  60. data/{.config → work/deprecated}/cucumber.yml +0 -0
  61. data/{features → work/deprecated/features}/coverage.feature +0 -0
  62. data/{features → work/deprecated/features}/generate.feature +0 -0
  63. data/{features → work/deprecated/features}/step_definitions/coverage_steps.rb +0 -0
  64. data/{features → work/deprecated/features}/support/ae.rb +0 -0
  65. data/{features → work/deprecated/features}/support/aruba.rb +0 -0
  66. data/{features → work/deprecated/features}/test.feature +0 -0
  67. data/work/deprecated/model/dsl/advice.rb +78 -0
  68. data/work/deprecated/model/dsl/subject.rb +40 -0
  69. data/{lib/lemon → work/deprecated}/model/main.rb +40 -29
  70. data/work/deprecated/model/test.rb +54 -0
  71. data/work/deprecated/model/test_base_dsl.rb +88 -0
  72. data/work/deprecated/model/test_clause.rb +112 -0
  73. data/{lib/lemon → work/deprecated}/model/test_context.rb +24 -24
  74. data/work/deprecated/model/test_feature.rb +128 -0
  75. data/work/deprecated/model/test_scenario.rb +137 -0
  76. data/{lib/lemon → work/deprecated}/model/test_suite.rb +113 -32
  77. data/work/deprecated/rake.rb +103 -0
  78. data/{test → work/deprecated/test}/case_coverage_analyzer.rb +0 -0
  79. data/{test → work/deprecated/test}/case_test_case_dsl.rb +2 -2
  80. data/{test → work/deprecated/test}/fixtures/case_complete.rb +0 -0
  81. data/{test → work/deprecated/test}/fixtures/case_inclusion.rb +0 -0
  82. data/{test → work/deprecated/test}/fixtures/case_incomplete.rb +0 -0
  83. data/{test → work/deprecated/test}/fixtures/example.rb +0 -0
  84. data/{test → work/deprecated/test}/fixtures/helper.rb +0 -0
  85. data/{test → work/deprecated/test}/runner +0 -0
  86. data/work/old-tests/case_example.rb +15 -0
  87. data/work/old-tests/feature_example.rb +40 -0
  88. data/work/reference/dsl2.rb +4 -0
  89. metadata +101 -98
  90. data/README.rdoc +0 -103
  91. data/bin/lemon +0 -4
  92. data/demo/case_example_error.rb +0 -10
  93. data/demo/case_example_fail.rb +0 -15
  94. data/demo/case_example_pass.rb +0 -32
  95. data/demo/case_example_pending.rb +0 -14
  96. data/demo/case_example_untested.rb +0 -10
  97. data/lib/lemon/controller/test_runner.rb +0 -299
  98. data/lib/lemon/model/pending.rb +0 -10
  99. data/lib/lemon/model/test_case.rb +0 -305
  100. data/lib/lemon/model/test_unit.rb +0 -147
  101. data/lib/lemon/view/test_reports/abstract.rb +0 -256
  102. data/lib/lemon/view/test_reports/dotprogress.rb +0 -73
  103. data/lib/lemon/view/test_reports/html.rb +0 -146
  104. data/lib/lemon/view/test_reports/outline.rb +0 -118
  105. data/lib/lemon/view/test_reports/summary.rb +0 -131
  106. data/lib/lemon/view/test_reports/tap.rb +0 -49
  107. data/lib/lemon/view/test_reports/tapj.rb +0 -130
  108. data/lib/lemon/view/test_reports/tapy.rb +0 -141
  109. data/lib/lemon/view/test_reports/verbose.rb +0 -197
  110. data/work/sandbox/lib/sample.rb +0 -13
  111. data/work/sandbox/test/sample_case.rb +0 -12
  112. data/work/trash/example-cover.rb +0 -5
  113. data/work/trash/example.rb +0 -16
@@ -1,118 +0,0 @@
1
- require 'lemon/view/test_reports/abstract'
2
-
3
- module Lemon::TestReports
4
-
5
- # Outline Reporter
6
- class Outline < Abstract
7
-
8
- #
9
- def start_case(testcase)
10
- puts "* #{testcase.target}".ansi(:bold)
11
- end
12
-
13
- #
14
- def context(context)
15
- if context
16
- if context.to_s.empty?
17
- puts " * general context"
18
- else
19
- puts " * #{context}"
20
- end
21
- else
22
- puts " * general context"
23
- end
24
- end
25
-
26
- #
27
- def start_unit(unit)
28
- instance = unit.instance
29
- if @context != context
30
- @context = context
31
- context(context)
32
- end
33
- end
34
-
35
- #
36
- def pass(unit)
37
- puts " * #{unit.name} #{unit.aspect}".ansi(:green)
38
- end
39
-
40
- #
41
- def fail(unit, exception)
42
- puts " * #{unit.name} #{unit.aspect} (FAIL)".ansi(:red)
43
- end
44
-
45
- #
46
- def error(unit, exception)
47
- puts " * #{unit.name} #{unit.aspect} (ERROR)".ansi(:red)
48
- end
49
-
50
- #
51
- def omit(unit)
52
- puts " * #{unit.name} #{unit.aspect} (OMIT)".ansi(:cyan)
53
- end
54
-
55
- #
56
- def pending(unit, exception)
57
- puts " * #{unit.name} #{unit.aspect} (PENDING)".ansi(:yellow)
58
- #puts
59
- #puts " PENDING #{exception.backtrace[0]}"
60
- #puts
61
- end
62
-
63
- #
64
- def finish_suite(suite)
65
- puts
66
-
67
- unless record[:fail].empty?
68
- puts "FAILURES:\n\n"
69
- record[:fail].each do |testunit, exception|
70
- puts " #{testunit}"
71
- puts " #{exception}"
72
- puts " #{exception.backtrace[0]}"
73
- puts
74
- end
75
- end
76
-
77
- unless record[:error].empty?
78
- puts "ERRORS:\n\n"
79
- record[:error].each do |testunit, exception|
80
- puts " #{testunit}"
81
- puts " #{exception}"
82
- puts " #{exception.backtrace[0]}"
83
- puts
84
- end
85
- end
86
-
87
- #unless record[:pending].empty?
88
- # puts "PENDING:\n\n"
89
- # record[:pending].each do |testunit, exception|
90
- # puts " #{testunit}"
91
- # end
92
- #end
93
-
94
- #unless uncovered.empty?
95
- # puts "UNCOVERED:\n\n"
96
- # unc = uncovered.map do |testunit|
97
- # yellow("* " +testunit.join('#'))
98
- # end.join("\n")
99
- # puts unc
100
- # puts
101
- #end
102
-
103
- #unless undefined.empty?
104
- # puts "UNDEFINED:\n\n"
105
- # unc = undefined.map do |testunit|
106
- # yellow("* " + testunit.join('#'))
107
- # end.join("\n")
108
- # puts unc
109
- # puts
110
- #end
111
-
112
- puts tally
113
- end
114
-
115
- end
116
-
117
- end
118
-
@@ -1,131 +0,0 @@
1
- require 'lemon/view/test_reports/abstract'
2
-
3
- module Lemon::TestReports
4
-
5
- # Summary Reporter
6
- class Summary < Abstract
7
-
8
- #
9
- def start_suite(suite)
10
- timer_reset
11
- end
12
-
13
- #
14
- #def start_case(tc)
15
- # puts
16
- # puts tc.to_s.ansi(:bold)
17
- #end
18
-
19
- #
20
- #def report_instance(instance)
21
- # puts
22
- # puts instance #"== #{concern.description}\n\n" unless concern.description.empty?
23
- # #timer_reset
24
- #end
25
-
26
- #
27
- def omit(unit)
28
- puts " %s %s %s" % [" OMIT".ansi(:cyan), unit.name, unit.aspect]
29
- end
30
-
31
- #
32
- #def start_unit(unit)
33
- # context = unit.context
34
- # if @instance != context
35
- # @context = context
36
- # puts
37
- # puts " #{context}"
38
- # puts
39
- # end
40
- #end
41
-
42
- #
43
- def omit(unit)
44
- puts " %s %s %s" % [" OMIT".ansi(:cyan), unit.to_s.ansi(:bold), unit.aspect]
45
- end
46
-
47
- #
48
- def pass(unit)
49
- puts " %s %s %s" % [" PASS".ansi(:green), unit.to_s.ansi(:bold), unit.aspect]
50
- end
51
-
52
- #
53
- def fail(unit, exception)
54
- puts " %s %s %s" % [" FAIL".ansi(:red), unit.to_s.ansi(:bold), unit.aspect]
55
- #puts
56
- #puts " FAIL #{exception.backtrace[0]}"
57
- #puts " #{exception}"
58
- #puts
59
- end
60
-
61
- #
62
- def error(unit, exception)
63
- puts " %s %s %s" % [" ERROR".ansi(:red), unit.to_s.ansi(:bold), unit.aspect]
64
- #puts
65
- #puts " ERROR #{exception.class}"
66
- #puts " #{exception}"
67
- #puts " " + exception.backtrace.join("\n ")
68
- #puts
69
- end
70
-
71
- #
72
- def pending(unit, exception)
73
- puts " %s %s %s" % ["PENDING".ansi(:yellow), unit.to_s.ansi(:bold), unit.aspect]
74
- end
75
-
76
- #
77
- def finish_suite(suite)
78
- puts
79
-
80
- unless record[:pending].empty?
81
- puts "PENDING:\n\n"
82
- record[:pending].each do |unit, exception|
83
- puts " #{unit}"
84
- puts " #{file_and_line(exception)}"
85
- puts
86
- end
87
- end
88
-
89
- unless record[:fail].empty?
90
- puts "FAILURES:\n\n"
91
- record[:fail].each do |unit, exception|
92
- puts " #{unit}"
93
- puts " #{file_and_line(exception)}"
94
- puts " #{exception}"
95
- puts code_snippet(exception)
96
- #puts " #{exception.backtrace[0]}"
97
- puts
98
- end
99
- end
100
-
101
- unless record[:error].empty?
102
- puts "ERRORS:\n\n"
103
- record[:error].each do |unit, exception|
104
- puts " #{unit}"
105
- puts " #{file_and_line(exception)}"
106
- puts " #{exception}"
107
- puts code_snippet(exception)
108
- #puts " #{exception.backtrace[0]}"
109
- puts
110
- end
111
- end
112
-
113
- puts tally
114
- end
115
-
116
- #
117
- def timer
118
- secs = Time.now - @time
119
- @time = Time.now
120
- return "%0.5fs" % [secs.to_s]
121
- end
122
-
123
- #
124
- def timer_reset
125
- @time = Time.now
126
- end
127
-
128
- end
129
-
130
- end
131
-
@@ -1,49 +0,0 @@
1
- require 'lemon/view/test_reports/abstract'
2
-
3
- module Lemon::TestReports
4
-
5
- # Timed Reporter
6
- class Tap < Abstract
7
-
8
- #
9
- def start_suite(suite)
10
- @start = Time.now
11
- @i = 0
12
- n = suite.testcases.inject(0){ |c, tc| c = c + tc.size; c }
13
- puts "1..#{n}"
14
- end
15
-
16
- def start_unit(unit)
17
- @i += 1
18
- end
19
-
20
- #
21
- def pass(unit)
22
- puts "ok #{@i} - #{unit.description}"
23
- end
24
-
25
- #
26
- def fail(unit, exception)
27
- puts "not ok #{@i} - #{unit.description}"
28
- puts " FAIL #{exception.backtrace[0]}"
29
- puts " #{exception}"
30
- end
31
-
32
- #
33
- def error(unit, exception)
34
- puts "not ok #{@i} - #{unit.description}"
35
- puts " ERROR #{exception.class}"
36
- puts " #{exception}"
37
- puts " " + exception.backtrace.join("\n ")
38
- end
39
-
40
- #
41
- def pending(unit, exception)
42
- puts "not ok #{@i} - #{unit.description}"
43
- puts " PENDING"
44
- puts " #{exception.backtrace[1]}"
45
- end
46
- end
47
-
48
- end
49
-
@@ -1,130 +0,0 @@
1
- require 'lemon/view/test_reports/abstract'
2
-
3
- module Lemon::TestReports
4
-
5
- # TAP-J Reporter
6
- #
7
- # TODO: Lemon needs some improvements in order to supply all the
8
- # information TAP-J supports. In particular, `file` and `line` information.
9
- class Tapj < Abstract
10
-
11
- #
12
- def start_suite(suite)
13
- require 'json'
14
-
15
- @start = Time.now
16
- @i = 0
17
- @n = suite.testcases.inject(0){ |c, tc| c = c + tc.size; c }
18
- h = {
19
- 'type' => "header",
20
- 'count' => @n,
21
- 'range' => "1..#{@n}"
22
- }
23
- puts h.to_json
24
- end
25
-
26
- #
27
- def start_case(tcase)
28
- h = {
29
- 'type' => 'case',
30
- 'description' => "#{tcase.to_s} #{tcase.aspect}".strip
31
- }
32
- puts h.to_json
33
- end
34
-
35
- #
36
- def start_unit(unit)
37
- @i += 1
38
- end
39
-
40
- #
41
- def pass(unit)
42
- h = {
43
- 'type' => 'test',
44
- 'status' => 'pass',
45
- 'file' => unit.file,
46
- 'line' => unit.line,
47
- 'description' => unit.description,
48
- #'returned' => '',
49
- #'expected' => '',
50
- 'source' => code_line(unit.caller),
51
- 'snippet' => code_snippet_omap(unit.caller, 3),
52
- 'message' => unit.to_s,
53
- 'time' => Time.now - @start
54
- }
55
- puts h.to_json
56
- end
57
-
58
- #
59
- def fail(unit, exception)
60
- h = {
61
- 'type' => 'test',
62
- 'status' => 'fail',
63
- 'file' => file(exception),
64
- 'line' => line(exception),
65
- 'description' => unit.description,
66
- #'returned' => '',
67
- #'expected' => '',
68
- 'source' => code_line(exception),
69
- 'snippet' => code_snippet_omap(exception, 3),
70
- 'message' => exception.message,
71
- 'time' => Time.now - @start
72
- #'backtrace' => exception.backtrace
73
- }
74
- puts h.to_json
75
- end
76
-
77
- #
78
- def error(unit, exception)
79
- h = {
80
- 'type' => 'test',
81
- 'status' => 'error',
82
- 'file' => file(exception),
83
- 'line' => line(exception),
84
- 'description' => unit.description,
85
- 'source' => code_line(exception),
86
- 'snippet' => code_snippet_omap(exception, 3),
87
- 'message' => exception.message,
88
- 'trace' => exception.backtrace,
89
- 'time' => Time.now - @start
90
- }
91
- puts h.to_json
92
- end
93
-
94
- # TODO: why was this using expception.backtrace[1] and now [0].
95
- def pending(unit, exception)
96
- h = {
97
- 'type' => 'test',
98
- 'status' => 'pending',
99
- 'file' => file(exception),
100
- 'line' => line(exception),
101
- 'description' => unit.description,
102
- 'source' => code_line(exception),
103
- 'snippet' => code_snippet_omap(exception, 3),
104
- 'message' => exception.message,
105
- 'time' => Time.now - @start
106
- #'backtrace' => exception.backtrace
107
- }
108
- puts h.to_json
109
- end
110
-
111
- #
112
- def finish_suite(suite)
113
- h = {
114
- 'type' => 'footer',
115
- 'time' => Time.now - @start,
116
- 'count' => @n, #total
117
- 'tally' => {
118
- 'pass' => record[:pass].size,
119
- 'fail' => record[:fail].size,
120
- 'error' => record[:error].size,
121
- 'omit' => record[:omit].size,
122
- 'pending' => record[:pending].size # TODO: rename to `hold`?
123
- }
124
- }
125
- puts h.to_json
126
- end
127
- end
128
-
129
- end
130
-
@@ -1,141 +0,0 @@
1
- require 'lemon/view/test_reports/abstract'
2
-
3
- module Lemon::TestReports
4
-
5
- #--
6
- #returned: true
7
- #expected: true
8
- #source: ok 1, 2
9
- #snippet:
10
- # 44: ok 0,0
11
- # 45: ok 1,2
12
- # 46: ok 2,4
13
- #++
14
-
15
- # TAP-Y Reporter
16
- #
17
- # TODO: Lemon needs some improvements in order to supply all the
18
- # information TAP-Y supports. In particular, `file` and `line` information.
19
- class Tapy < Abstract
20
-
21
- #
22
- def start_suite(suite)
23
- require 'yaml'
24
-
25
- @start = Time.now
26
- @i = 0
27
- @n = suite.testcases.inject(0){ |c, tc| c = c + tc.size; c }
28
- h = {
29
- 'type' => "header",
30
- 'count' => @n,
31
- 'range' => "1..#{@n}"
32
- }
33
- puts h.to_yaml
34
- end
35
-
36
- #
37
- def start_case(tcase)
38
- h = {
39
- 'type' => 'case',
40
- 'description' => "#{tcase.to_s} #{tcase.aspect}".strip
41
- }
42
- puts h.to_yaml
43
- end
44
-
45
- #
46
- def start_unit(unit)
47
- @i += 1
48
- end
49
-
50
- #
51
- def pass(unit) #, backtrace=nil)
52
- h = {
53
- 'type' => 'test',
54
- 'status' => 'pass',
55
- 'file' => unit.file,
56
- 'line' => unit.line,
57
- 'description' => unit.description,
58
- #'returned' => '',
59
- #'expected' => '',
60
- 'source' => code_line(unit.caller),
61
- 'snippet' => code_snippet_omap(unit.caller, 3),
62
- 'message' => unit.to_s,
63
- 'time' => Time.now - @start
64
- }
65
- puts h.to_yaml
66
- end
67
-
68
- #
69
- def fail(unit, exception)
70
- h = {
71
- 'type' => 'test',
72
- 'status' => 'fail',
73
- 'file' => file(exception),
74
- 'line' => line(exception),
75
- 'description' => unit.description,
76
- #'returned' => '',
77
- #'expected' => '',
78
- 'source' => code_line(exception),
79
- 'snippet' => code_snippet_omap(exception, 3),
80
- 'message' => exception.message,
81
- 'time' => Time.now - @start
82
- #'backtrace' => exception.backtrace
83
- }
84
- puts h.to_yaml
85
- end
86
-
87
- #
88
- def error(unit, exception)
89
- h = {
90
- 'type' => 'test',
91
- 'status' => 'error',
92
- 'file' => file(exception),
93
- 'line' => line(exception),
94
- 'description' => unit.description,
95
- 'source' => code_line(exception),
96
- 'snippet' => code_snippet_omap(exception, 3),
97
- 'message' => exception.message,
98
- 'backtrace' => exception.backtrace,
99
- 'time' => Time.now - @start
100
- }
101
- puts h.to_yaml
102
- end
103
-
104
- #
105
- def pending(unit, exception)
106
- h = {
107
- 'type' => 'test',
108
- 'status' => 'pending',
109
- 'file' => file(exception),
110
- 'line' => line(exception),
111
- 'description' => unit.description,
112
- 'source' => code_line(exception),
113
- 'snippet' => code_snippet_omap(exception, 3),
114
- 'message' => exception.message,
115
- 'time' => Time.now - @start
116
- #'backtrace' => exception.backtrace
117
- }
118
- puts h.to_yaml
119
- end
120
-
121
- #
122
- def finish_suite(suite)
123
- h = {
124
- 'type' => 'footer',
125
- 'time' => Time.now - @start,
126
- 'count' => @n, #total
127
- 'tally' => {
128
- 'pass' => record[:pass].size,
129
- 'fail' => record[:fail].size,
130
- 'error' => record[:error].size,
131
- 'omit' => record[:omit].size,
132
- 'pending' => record[:pending].size # TODO: rename to `hold`?
133
- }
134
- }
135
- puts h.to_yaml
136
- puts "..."
137
- end
138
- end
139
-
140
- end
141
-