Class: Lemon::TestModule::DSL

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

Overview

Evaluation scope for TestModule.

Direct Known Subclasses

Lemon::TestClass::DSL

Instance Method Summary collapse

Methods inherited from Lemon::TestCase::DSL

#after, #before, #context, #initialize, #omit, #setup, #skip, #teardown

Methods inherited from Module

#namespace

Constructor Details

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

Instance Method Details

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

Define a class-method unit test for this case.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/lemon/test_module.rb', line 88

def class_unit(method, *tags, &block)
  return if @_omit

  meth = TestClassMethod.new(
    :context   => @_testcase,
    :setup     => @_setup,
    :skip      => @_skip,
    :target    => method.to_sym,
    :tags      => tags,
    :singleton => true,
    &block
  )

  @_testcase.tests << meth

  meth
end

#context_classObject

The class for which this is a DSL context.



48
49
50
# File 'lib/lemon/test_module.rb', line 48

def context_class
  TestModule
end

#unit(method, *tags, &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


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

def unit(method, *tags, &block)
  return if @_omit

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