lemon 0.9.0 → 0.9.1
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/.ruby +23 -14
- data/.yardopts +6 -0
- data/Config.rb +14 -0
- data/{HISTORY.rdoc → HISTORY.md} +26 -11
- data/LICENSE.txt +27 -0
- data/README.md +42 -28
- data/SPECSHEET.md +314 -0
- data/bin/{lemonade → lemons} +0 -0
- data/lib/lemon.yml +23 -14
- data/lib/lemon/cli.rb +19 -8
- data/lib/lemon/cli/base.rb +50 -20
- data/lib/lemon/cli/generate.rb +51 -16
- data/lib/lemon/cli/lemon.ascii +84 -0
- data/lib/lemon/cli/obrother.rb +35 -0
- data/lib/lemon/cli/scaffold.rb +116 -0
- data/lib/lemon/core_ext.rb +2 -2
- data/lib/lemon/core_ext/module.rb +9 -0
- data/lib/lemon/coverage/analyzer.rb +76 -5
- data/lib/lemon/coverage/cover_unit.rb +38 -14
- data/lib/lemon/coverage/formats/verbose.rb +1 -1
- data/lib/lemon/coverage/generator.rb +196 -0
- data/lib/lemon/coverage/snapshot.rb +16 -16
- data/lib/lemon/coverage/source_parser.rb +103 -37
- data/lib/lemon/ignore_callers.rb +19 -0
- data/lib/lemon/test_case.rb +135 -26
- data/lib/lemon/test_class.rb +16 -3
- data/lib/lemon/test_class_method.rb +58 -0
- data/lib/lemon/test_method.rb +57 -68
- data/lib/lemon/test_module.rb +47 -44
- data/lib/lemon/test_proc.rb +28 -2
- data/lib/lemon/test_scope.rb +14 -0
- data/lib/lemon/test_setup.rb +1 -1
- data/lib/lemon/test_world.rb +7 -0
- data/{work/deprecated/features/support → spec/applique}/ae.rb +0 -0
- data/spec/coverage/{01_complete.rdoc → 01_complete.md} +3 -3
- data/spec/coverage/{02_incomplete.rdoc → 02_incomplete.md} +2 -2
- data/spec/coverage/{03_extensions.rdoc → 03_extensions.md} +2 -2
- data/try/case_scope.rb +19 -0
- metadata +50 -102
- data/.gemspec +0 -152
- data/.gitignore +0 -8
- data/.reap/digest +0 -678
- data/.reap/test.reap +0 -7
- data/Assembly +0 -37
- data/COPYING.rdoc +0 -33
- data/MANIFEST +0 -55
- data/PROFILE +0 -30
- data/Rakefile +0 -23
- data/VERSION +0 -1
- data/lib/lemon/core_ext/omission.rb +0 -18
- data/lib/lemon/generator.rb +0 -149
- data/notes/2010-05-05-coverage.rdoc +0 -47
- data/notes/2010-05-06-files-not-classes.rdoc +0 -19
- data/notes/2010-07-11-acid-testing.rdoc +0 -52
- data/notes/2010-08-02-enforcing-the-unit.md +0 -68
- data/notes/2010-08-03-new-api.md +0 -37
- data/notes/2011-07-07-nailing-down-the-nomenclature.md +0 -6
- data/site/.rsync-filter +0 -8
- data/site/assets/images/cut-lemon.png +0 -0
- data/site/assets/images/forkme.png +0 -0
- data/site/assets/images/github-logo.png +0 -0
- data/site/assets/images/lemon.jpg +0 -0
- data/site/assets/images/lemon.svg +0 -39
- data/site/assets/images/lemons-are-good.png +0 -0
- data/site/assets/images/opensource.png +0 -0
- data/site/assets/images/ruby-logo.png +0 -0
- data/site/assets/images/skin.jpg +0 -0
- data/site/assets/images/skin1.jpg +0 -0
- data/site/assets/images/tap.png +0 -0
- data/site/assets/images/title.png +0 -0
- data/site/assets/styles/class.css +0 -6
- data/site/assets/styles/reset.css +0 -17
- data/site/assets/styles/site.css +0 -33
- data/site/index.html +0 -218
- data/work/deprecated/command/abstract.rb +0 -29
- data/work/deprecated/command/coverage.rb +0 -115
- data/work/deprecated/command/generate.rb +0 -124
- data/work/deprecated/command/test.rb +0 -112
- data/work/deprecated/cucumber.yml +0 -3
- data/work/deprecated/features/coverage.feature +0 -65
- data/work/deprecated/features/generate.feature +0 -66
- data/work/deprecated/features/step_definitions/coverage_steps.rb +0 -1
- data/work/deprecated/features/support/aruba.rb +0 -1
- data/work/deprecated/features/test.feature +0 -67
- data/work/deprecated/model/dsl/advice.rb +0 -78
- data/work/deprecated/model/dsl/subject.rb +0 -40
- data/work/deprecated/model/main.rb +0 -87
- data/work/deprecated/model/test.rb +0 -54
- data/work/deprecated/model/test_base_dsl.rb +0 -88
- data/work/deprecated/model/test_clause.rb +0 -112
- data/work/deprecated/model/test_context.rb +0 -90
- data/work/deprecated/model/test_feature.rb +0 -128
- data/work/deprecated/model/test_scenario.rb +0 -137
- data/work/deprecated/model/test_suite.rb +0 -297
- data/work/deprecated/rake.rb +0 -103
- data/work/deprecated/test/case_coverage_analyzer.rb +0 -25
- data/work/deprecated/test/case_test_case_dsl.rb +0 -46
- data/work/deprecated/test/fixtures/case_complete.rb +0 -25
- data/work/deprecated/test/fixtures/case_inclusion.rb +0 -18
- data/work/deprecated/test/fixtures/case_incomplete.rb +0 -12
- data/work/deprecated/test/fixtures/example.rb +0 -13
- data/work/deprecated/test/fixtures/helper.rb +0 -13
- data/work/deprecated/test/runner +0 -2
- data/work/old-tests/case_example.rb +0 -15
- data/work/old-tests/feature_example.rb +0 -40
- data/work/reference/dsl2.rb +0 -140
- data/work/reference/dynamic_constant_lookup.rb +0 -76
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
Feature: Coverage
|
|
2
|
-
As a developer
|
|
3
|
-
In order to improve test coverge
|
|
4
|
-
I want to able to generate test scaffolding
|
|
5
|
-
And limit the scaffolding to test units not already covered
|
|
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 ; X.new.a.assert.is_a?(String) ; end
|
|
25
|
-
Unit :b => "Returns a String" do ; X.new.b.assert.is_a?(String) ; end
|
|
26
|
-
Unit :c => "Returns a String" do ; X.new.c.assert.is_a?(String) ; end
|
|
27
|
-
end
|
|
28
|
-
TestCase Y do
|
|
29
|
-
Unit :q => "Returns a String" do ; Y.new.q.assert.is_a?(String) ; end
|
|
30
|
-
end
|
|
31
|
-
"""
|
|
32
|
-
When I cd to "example"
|
|
33
|
-
And I run "lemon -g -u -Ilib test/case_complete.rb"
|
|
34
|
-
Then the stdout should not contain "Unit :a"
|
|
35
|
-
And the stdout should not contain "Unit :b"
|
|
36
|
-
And the stdout should not contain "Unit :c"
|
|
37
|
-
And the stdout should not contain "Unit :q"
|
|
38
|
-
|
|
39
|
-
Scenario: Incomplete Example Case
|
|
40
|
-
Given a directory named "example"
|
|
41
|
-
Given a file named "example/lib/example.rb" with:
|
|
42
|
-
"""
|
|
43
|
-
class X
|
|
44
|
-
def a; "a"; end
|
|
45
|
-
def b; "b"; end
|
|
46
|
-
def c; "c"; end
|
|
47
|
-
end
|
|
48
|
-
class Y
|
|
49
|
-
def q; "q"; end
|
|
50
|
-
end
|
|
51
|
-
"""
|
|
52
|
-
Given a file named "example/test/case_complete.rb" with:
|
|
53
|
-
"""
|
|
54
|
-
Covers 'example'
|
|
55
|
-
TestCase X do
|
|
56
|
-
Unit :a => "Returns a String" do ; X.new.a.assert.is_a?(String) ; end
|
|
57
|
-
Unit :b => "Returns a String" do ; X.new.b.assert.is_a?(Fixnum) ; end
|
|
58
|
-
Unit :d => "Returns a String" do ; X.new.d.assert.is_a?(String) ; end
|
|
59
|
-
end
|
|
60
|
-
"""
|
|
61
|
-
When I cd to "example"
|
|
62
|
-
And I run "lemon -g -u -Ilib test/case_complete.rb"
|
|
63
|
-
Then the stdout should not contain "Unit :a"
|
|
64
|
-
And the stdout should not contain "Unit :b"
|
|
65
|
-
And the stdout should contain "Unit :c"
|
|
66
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'aruba'
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
Feature: Coverage
|
|
2
|
-
As a developer
|
|
3
|
-
In order to improve test coverge
|
|
4
|
-
I want to able to write unit tests that target methods
|
|
5
|
-
And run those tests
|
|
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 ; X.new.a.assert.is_a?(String) ; end
|
|
25
|
-
Unit :b => "Returns a String" do ; X.new.b.assert.is_a?(String) ; end
|
|
26
|
-
Unit :c => "Returns a String" do ; X.new.c.assert.is_a?(String) ; end
|
|
27
|
-
end
|
|
28
|
-
TestCase Y do
|
|
29
|
-
Unit :q => "Returns a String" do ; Y.new.q.assert.is_a?(String) ; end
|
|
30
|
-
end
|
|
31
|
-
"""
|
|
32
|
-
When I cd to "example"
|
|
33
|
-
And I run "lemon -Ilib -v test/case_complete.rb"
|
|
34
|
-
Then the stdout should contain "4 tests"
|
|
35
|
-
And the stdout should contain "4 pass"
|
|
36
|
-
And the stdout should contain "0 fail"
|
|
37
|
-
And the stdout should contain "0 err"
|
|
38
|
-
|
|
39
|
-
Scenario: Incomplete Example Case
|
|
40
|
-
Given a directory named "example"
|
|
41
|
-
Given a file named "example/lib/example.rb" with:
|
|
42
|
-
"""
|
|
43
|
-
class X
|
|
44
|
-
def a; "a"; end
|
|
45
|
-
def b; "b"; end
|
|
46
|
-
def c; "c"; end
|
|
47
|
-
end
|
|
48
|
-
class Y
|
|
49
|
-
def q; "q"; end
|
|
50
|
-
end
|
|
51
|
-
"""
|
|
52
|
-
Given a file named "example/test/case_complete.rb" with:
|
|
53
|
-
"""
|
|
54
|
-
Covers 'example'
|
|
55
|
-
TestCase X do
|
|
56
|
-
Unit :a => "Returns a String" do ; X.new.a.assert.is_a?(String) ; end
|
|
57
|
-
Unit :b => "Returns a String" do ; X.new.b.assert.is_a?(Fixnum) ; end
|
|
58
|
-
Unit :d => "Returns a String" do ; X.new.d.assert.is_a?(String) ; end
|
|
59
|
-
end
|
|
60
|
-
"""
|
|
61
|
-
When I cd to "example"
|
|
62
|
-
And I run "lemon -Ilib -v test/case_complete.rb"
|
|
63
|
-
Then the stdout should contain "3 tests"
|
|
64
|
-
And the stdout should contain "1 pass"
|
|
65
|
-
And the stdout should contain "1 fail"
|
|
66
|
-
And the stdout should contain "1 err"
|
|
67
|
-
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# NOTE: This code is not being used. It is here for the time being
|
|
2
|
-
# on the outseide change that I decide to go back to a toplevel design.
|
|
3
|
-
|
|
4
|
-
require 'lemon/model/test_suite'
|
|
5
|
-
|
|
6
|
-
class << self
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
def Covers(script)
|
|
10
|
-
Lemon.suite.dsl.covers(script)
|
|
11
|
-
end
|
|
12
|
-
alias :Coverage :Covers
|
|
13
|
-
|
|
14
|
-
# Define a general test case.
|
|
15
|
-
def Case(target, &block)
|
|
16
|
-
Lemon.suite.dsl.test_case(target, &block)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Define a class test.
|
|
20
|
-
def Class(target_class, &block)
|
|
21
|
-
Lemon.suite.dsl.test_class(target_class, &block)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Define a module test.
|
|
25
|
-
def Module(target_module, &block)
|
|
26
|
-
Lemon.suite.dsl.test_module(target_module, &block)
|
|
27
|
-
end
|
|
28
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
=begin
|
|
51
|
-
# FIXME: This is a BIG FAT HACK! For the life of me I cannot find
|
|
52
|
-
# a way to resolve module constants included in the test cases.
|
|
53
|
-
# Because of closure, the constant lookup goes through here, and not
|
|
54
|
-
# the Case singleton class. So to work around we must note each test
|
|
55
|
-
# before it is run, and reroute the missing constants.
|
|
56
|
-
#
|
|
57
|
-
# This sucks and it is not thread safe. If anyone know how to fix,
|
|
58
|
-
# please let me know. See Unit#call for the other end of this hack.
|
|
59
|
-
#
|
|
60
|
-
def Object.const_missing(name)
|
|
61
|
-
if unit = Lemon.test_stack.last
|
|
62
|
-
begin
|
|
63
|
-
(class << unit.test_case; self; end).const_get(name)
|
|
64
|
-
rescue NameError
|
|
65
|
-
super(name)
|
|
66
|
-
end
|
|
67
|
-
else
|
|
68
|
-
super(name)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
#def Object.const_missing(name)
|
|
73
|
-
# if unit = Lemon.test_stack.last
|
|
74
|
-
# klass = (class << unit.test_case; self; end)
|
|
75
|
-
# if klass.const_defined?(name)
|
|
76
|
-
# return klass.const_get(name)
|
|
77
|
-
# end
|
|
78
|
-
# end
|
|
79
|
-
# super(name)
|
|
80
|
-
#end
|
|
81
|
-
|
|
82
|
-
# Get current running test. Used for the BIG FAT HACK.
|
|
83
|
-
def Lemon.test_stack
|
|
84
|
-
@@test_stack ||= []
|
|
85
|
-
end
|
|
86
|
-
=end
|
|
87
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
module Lemon
|
|
2
|
-
|
|
3
|
-
# Base class for TestCase DSLs.
|
|
4
|
-
class BaseDSL < Module
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
def initialize(context, &code)
|
|
8
|
-
@context = context
|
|
9
|
-
@subject = context.subject
|
|
10
|
-
|
|
11
|
-
module_eval(&code)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
def context(description, &block)
|
|
16
|
-
@context.tests << TestCase.new(@context, description, &block)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
def test(description, &procedure)
|
|
21
|
-
test = TestProc.new(
|
|
22
|
-
@context,
|
|
23
|
-
:description => description,
|
|
24
|
-
:subject => subject,
|
|
25
|
-
&procedure
|
|
26
|
-
)
|
|
27
|
-
@context.tests << test
|
|
28
|
-
test
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Omit a test or test case from being run.
|
|
32
|
-
#
|
|
33
|
-
# omit test "something or other" do
|
|
34
|
-
# # ...
|
|
35
|
-
# end
|
|
36
|
-
#
|
|
37
|
-
def omit(test_or_case)
|
|
38
|
-
test_or_case.omit = true
|
|
39
|
-
end
|
|
40
|
-
alias_method :Omit, :omit
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# Load a helper script applicable to this test case. Unlike requiring
|
|
46
|
-
# a helper script, the #helper method will eval the file's contents
|
|
47
|
-
# directly into the test context (using instance_eval).
|
|
48
|
-
#
|
|
49
|
-
# @param [String] file
|
|
50
|
-
# File to eval into test context.
|
|
51
|
-
#
|
|
52
|
-
# FIXME: This is at odds with loading helpers automatically. How
|
|
53
|
-
# to handle?
|
|
54
|
-
def helper(file)
|
|
55
|
-
instance_eval(File.read(file), file)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
alias_method :Helper, :helper
|
|
59
|
-
|
|
60
|
-
#def include(*mods)
|
|
61
|
-
# extend *mods
|
|
62
|
-
#end
|
|
63
|
-
|
|
64
|
-
#def pending(message=nil)
|
|
65
|
-
# raise Pending.new(message)
|
|
66
|
-
#end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# Before All and After All advice are bad form.
|
|
70
|
-
#
|
|
71
|
-
# # Define a "before all" procedure.
|
|
72
|
-
# def prepare(&procedure)
|
|
73
|
-
# before(&procedure)
|
|
74
|
-
# end
|
|
75
|
-
#
|
|
76
|
-
# alias_method :Prepare, :prepare
|
|
77
|
-
#
|
|
78
|
-
# # Define an "after all" procedure.
|
|
79
|
-
# def cleanup(&procedure)
|
|
80
|
-
# after(&procedure)
|
|
81
|
-
# end
|
|
82
|
-
#
|
|
83
|
-
# alias_method :Cleanup, :cleanup
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
end
|