Class: Lemon::TestModule::Scope

Inherits:
Lemon::TestCase::Scope show all
Defined in:
lib/lemon/test_module.rb

Overview

Evaluation scope for TestModule.

Direct Known Subclasses

Lemon::TestClass::Scope

Instance Method Summary collapse

Methods inherited from Lemon::TestCase::Scope

#after, #before, #initialize, #setup, #teardown

Constructor Details

This class inherits a constructor from Lemon::TestCase::Scope

Instance Method Details

#class_unit(method, &block) ⇒ Object Also known as: ClassUnit, class_method, ClassMethod

Define a class-method unit test for this case.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/lemon/test_module.rb', line 64

def class_unit(method, &block)
  meth = TestMethod.new(
    :context  => @_testcase,
    :setup    => @_setup,
    :skip     => @_skip,
    :target   => method.to_sym,
    :function => true,
    &block
  )
  @_testcase.tests << meth
  meth
end

#context(label, &block) ⇒ Object Also known as: Context

Create a subcase of module testcase.



91
92
93
94
95
96
97
98
99
100
# File 'lib/lemon/test_module.rb', line 91

def context(label, &block)
  @_testcase.tests << TestModule.new(
    :context => @_testcase,
    :target  => @_testcase.target,
    :setup   => @_setup,
    :skip    => @_skip,
    :label   => label,
    &block
  )
end

#skip(reason = true, &block) ⇒ Object



104
105
106
107
108
# File 'lib/lemon/test_module.rb', line 104

def skip(reason=true, &block)
  @_skip = reason
  block.call
  @_skip = nil
end

#unit(method, &block) ⇒ Object Also known as: Unit, method, Method

Define a method/unit subcase for the class/module testcase.

Examples:

unit :puts do
  test "print message with new line to stdout" do
    puts "Hello"
  end
end


44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/lemon/test_module.rb', line 44

def unit(method, &block)
  meth = TestMethod.new(
    :context  => @_testcase, 
    :setup    => @_setup,
    :skip     => @_skip,
    :target   => method.to_sym,
    :function => false,
    &block
  )
  @_testcase.tests << meth
  meth
end