lemon 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -12,14 +12,18 @@ Given an example script in 'lib/extensions_example.rb' as follows:
12
12
 
13
13
  And given a test case in 'test/extensions_example_case.rb' as follows:
14
14
 
15
- covers 'extensions_example.rb'
15
+ Covers 'extensions_example.rb'
16
16
 
17
- tests Kernel do
18
- unit :f1 do
19
- fl.assert == "f1"
17
+ TestCase Kernel do
18
+ method :f1 do
19
+ test do
20
+ fl.assert == "f1"
21
+ end
20
22
  end
21
- unit :f2 do
22
- f2.assert == "f2"
23
+ method :f2 do
24
+ test do
25
+ f2.assert == "f2"
26
+ end
23
27
  end
24
28
  end
25
29
 
@@ -0,0 +1 @@
1
+ require 'lemon/coverage/analyzer'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Test.run :default do |r|
4
+ require 'ae'
5
+ require 'lemon'
6
+ $:.unshift 'fixtures'
7
+ end
8
+
@@ -0,0 +1,18 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example do
4
+
5
+ method :f do
6
+
7
+ test "one and one is two" do
8
+ ExampleUnknown.new.f(1,1).assert == 2
9
+ end
10
+
11
+ test "two and two is four" do
12
+ ExampleUnknown.new.f(2,2).assert == 4
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,19 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example do
4
+
5
+ method :f do
6
+
7
+ test "one and one is two" do
8
+ Example.new.f(1,1).assert == 2
9
+ end
10
+
11
+ test "two and two is four" do
12
+ ex = Example.new
13
+ ex.f(1,2).assert == 4
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
@@ -0,0 +1,42 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example do
4
+
5
+ method :f do
6
+
7
+ setup "without multipler" do
8
+ @ex = Example.new
9
+ end
10
+
11
+ test "1,2" do
12
+ @ex.f(1,2).assert == 3
13
+ end
14
+
15
+ test "2,2" do
16
+ @ex.f(2,2).assert == 4
17
+ end
18
+
19
+
20
+ setup "with multipler" do
21
+ @ex = Example.new(2)
22
+ end
23
+
24
+ test "1,2" do
25
+ @ex.f(1,2).assert == 4
26
+ end
27
+
28
+ test "2,2" do
29
+ @ex.f(2,2).assert == 6
30
+ end
31
+
32
+ teardown do
33
+ # ...
34
+ end
35
+
36
+ #class_method :m do
37
+ # Example.m(1,1).assert == 1
38
+ #end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,18 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example do
4
+
5
+ method :f do
6
+
7
+ test "one and one is two"do
8
+ Example.new.f(1,1).assert == 2
9
+ end
10
+
11
+ test "pending" do
12
+ raise NotImplementedError
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example.singleton_class do
4
+
5
+ method :m do
6
+
7
+ setup "Example class" do
8
+ Example
9
+ end
10
+
11
+ test "using singleton_class" do
12
+ Example.m(1,1).assert == 1
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,14 @@
1
+ covers 'example.rb'
2
+
3
+ test_case Example do
4
+
5
+ method :f do
6
+
7
+ test "nothing doing" do
8
+ # notice Example#f has not been called
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,15 @@
1
+ class Calculator
2
+
3
+ def initialize
4
+ @stack = []
5
+ end
6
+
7
+ def push(int)
8
+ @stack << int
9
+ end
10
+
11
+ def add
12
+ @stack.inject(0){ |sum, val| sum += val; sum }
13
+ end
14
+
15
+ end
@@ -0,0 +1 @@
1
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../fixtures')
@@ -0,0 +1,78 @@
1
+ module Lemon
2
+
3
+ module DSL
4
+
5
+ #
6
+ #--
7
+ # TODO: Allow Before and After to handle before and after
8
+ # concerns in addition to units?
9
+ #++
10
+ module Advice
11
+
12
+ # Define a _complex_ before procedure. The #before method allows
13
+ # before procedures to be defined that are triggered by a match
14
+ # against the unit's target method name or _aspect_ description.
15
+ # This allows groups of tests to be defined that share special
16
+ # setup code.
17
+ #
18
+ # @example
19
+ # Method :puts do
20
+ # Test "standard output (@stdout)" do
21
+ # puts "Hello"
22
+ # end
23
+ #
24
+ # Before /@stdout/ do
25
+ # $stdout = StringIO.new
26
+ # end
27
+ #
28
+ # After /@stdout/ do
29
+ # $stdout = STDOUT
30
+ # end
31
+ # end
32
+ #
33
+ # @param [Array<Symbol,Regexp>] matches
34
+ # List of match critera that must _all_ be matched
35
+ # to trigger the before procedure.
36
+ #
37
+ def Before(*matches, &procedure)
38
+ @context.advice[:before][matches] = procedure
39
+ end
40
+
41
+ alias_method :before, :Before
42
+
43
+ # Define a _complex_ after procedure. The #before method allows
44
+ # before procedures to be defined that are triggered by a match
45
+ # against the unit's target method name or _aspect_ description.
46
+ # This allows groups of tests to be defined that share special
47
+ # teardown code.
48
+ #
49
+ # @example
50
+ # Method :puts do
51
+ # Test "standard output (@stdout)" do
52
+ # puts "Hello"
53
+ # end
54
+ #
55
+ # Before /@stdout/ do
56
+ # $stdout = StringIO.new
57
+ # end
58
+ #
59
+ # After /@stdout/ do
60
+ # $stdout = STDOUT
61
+ # end
62
+ # end
63
+ #
64
+ # @param [Array<Symbol,Regexp>] matches
65
+ # List of match critera that must _all_ be matched
66
+ # to trigger the after procedure.
67
+ #
68
+ def After(*matches, &procedure)
69
+ @context.advice[:after][matches] = procedure
70
+ end
71
+
72
+ alias_method :after, :After
73
+
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,40 @@
1
+ module Lemon
2
+
3
+ module DSL
4
+
5
+ #
6
+ module Subject
7
+
8
+ # Setup is used to set things up for each unit test.
9
+ # The setup procedure is run before each unit.
10
+ #
11
+ # @param [String] description
12
+ # A brief description of what the setup procedure sets-up.
13
+ #
14
+ def Setup(description=nil, &procedure)
15
+ if procedure
16
+ @subject = TestSubject.new(@test_case, description, &procedure)
17
+ end
18
+ end
19
+
20
+ alias_method :setup, :Setup
21
+
22
+ alias_method :Concern, :Setup
23
+ alias_method :concern, :Setup
24
+
25
+ alias_method :Subject, :Setup
26
+ alias_method :subject, :Setup
27
+
28
+ # Teardown procedure is used to clean-up after each unit test.
29
+ #
30
+ def Teardown(&procedure)
31
+ @subject.teardown = procedure
32
+ end
33
+
34
+ alias_method :teardown, :Teardown
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -3,38 +3,49 @@
3
3
 
4
4
  require 'lemon/model/test_suite'
5
5
 
6
- #
7
- #def Before(match=nil, &block)
8
- # Lemon.suite.Before(match, &block)
9
- #end
6
+ class << self
10
7
 
11
- #
12
- #def After(match=nil, &block)
13
- # Lemon.suite.After(match, &block)
14
- #end
8
+ #
9
+ def Covers(script)
10
+ Lemon.suite.dsl.covers(script)
11
+ end
12
+ alias :Coverage :Covers
15
13
 
16
- #
17
- def testcase(target_class, &block)
18
- Lemon.suite.dsl.testcase(target_class, &block)
19
- end
20
- alias :TestCase :testcase
21
- alias :Case :testcase
22
- alias :tests :testcase # can't use test b/c of kernel method
14
+ # Define a general test case.
15
+ def Case(target, &block)
16
+ Lemon.suite.dsl.test_case(target, &block)
17
+ end
23
18
 
24
- #
25
- def covers(script)
26
- Lemon.suite.dsl.covers(script)
27
- end
28
- alias :Covers :covers
19
+ # Define a class test.
20
+ def Class(target_class, &block)
21
+ Lemon.suite.dsl.test_class(target_class, &block)
22
+ end
29
23
 
30
- #
31
- #def Helper(script)
32
- # Lemon.suite.Helper(script)
33
- #end
24
+ # Define a module test.
25
+ def Module(target_module, &block)
26
+ Lemon.suite.dsl.test_module(target_module, &block)
27
+ end
34
28
 
35
- #def Subtest(script)
36
- # Lemon.suite.Subtest(script)
37
- #end
29
+ # Define a test feature.
30
+ def Feature(target, &block)
31
+ Lemon.suite.dsl.test_feature(target, &block)
32
+ end
33
+
34
+ #
35
+ #def Before(match=nil, &block)
36
+ # Lemon.suite.Before(match, &block)
37
+ #end
38
+
39
+ #
40
+ #def After(match=nil, &block)
41
+ # Lemon.suite.After(match, &block)
42
+ #end
43
+
44
+ #
45
+ #def Helper(script)
46
+ # Lemon.suite.Helper(script)
47
+ #end
48
+ end
38
49
 
39
50
  =begin
40
51
  # FIXME: This is a BIG FAT HACK! For the life of me I cannot find
@@ -49,7 +60,7 @@ alias :Covers :covers
49
60
  def Object.const_missing(name)
50
61
  if unit = Lemon.test_stack.last
51
62
  begin
52
- (class << unit.testcase; self; end).const_get(name)
63
+ (class << unit.test_case; self; end).const_get(name)
53
64
  rescue NameError
54
65
  super(name)
55
66
  end
@@ -60,7 +71,7 @@ end
60
71
 
61
72
  #def Object.const_missing(name)
62
73
  # if unit = Lemon.test_stack.last
63
- # klass = (class << unit.testcase; self; end)
74
+ # klass = (class << unit.test_case; self; end)
64
75
  # if klass.const_defined?(name)
65
76
  # return klass.const_get(name)
66
77
  # end
@@ -0,0 +1,54 @@
1
+ require 'lemon/model/test_suite'
2
+
3
+ module Test
4
+ extend self
5
+
6
+ #
7
+ def covers(script)
8
+ Lemon.suite.dsl.covers(script)
9
+ end
10
+ alias :Covers :covers
11
+
12
+ alias :coverage :covers
13
+ alias :Coverage :covers
14
+
15
+ # Define a general test case.
16
+ def case(target, &block)
17
+ Lemon.suite.dsl.test_case(target, &block)
18
+ end
19
+ alias :Case :case
20
+
21
+ # Define a class test.
22
+ def class(target_class, &block)
23
+ Lemon.suite.dsl.test_class(target_class, &block)
24
+ end
25
+ alias :Class :class
26
+
27
+ # Define a module test.
28
+ def module(target_module, &block)
29
+ Lemon.suite.dsl.test_module(target_module, &block)
30
+ end
31
+ alias :Module :module
32
+
33
+ # Define a test feature.
34
+ def feature(target, &block)
35
+ Lemon.suite.dsl.test_feature(target, &block)
36
+ end
37
+ alias :Feature :feature
38
+
39
+ #
40
+ #def Before(match=nil, &block)
41
+ # Lemon.suite.Before(match, &block)
42
+ #end
43
+
44
+ #
45
+ #def After(match=nil, &block)
46
+ # Lemon.suite.After(match, &block)
47
+ #end
48
+
49
+ #
50
+ #def Helper(script)
51
+ # Lemon.suite.Helper(script)
52
+ #end
53
+
54
+ end