Module: Petitest::DSL

Defined in:
lib/petitest/dsl.rb,
lib/petitest/dsl/version.rb

Constant Summary collapse

VERSION =
"0.3.0"

Instance Method Summary collapse

Instance Method Details

#desc(current_description) ⇒ Object

Parameters:

  • current_description (String)

6
7
8
# File 'lib/petitest/dsl.rb', line 6

def desc(current_description)
  self.current_description = current_description
end

#sub_test(description, metadata = {}, &block) ⇒ Object

Parameters:

  • description (String)
  • metadata (Hash{Symbol => Object}) (defaults to: {})

12
13
14
15
16
17
18
19
# File 'lib/petitest/dsl.rb', line 12

def sub_test(description,  = {}, &block)
  child = ::Class.new(self)
  child.description = description
  child. = self..merge()
  child.undefine_test_methods
  child.class_eval(&block)
  child
end

#test(description, metadata = {}, &block) ⇒ Object

Parameters:

  • description (String)
  • metadata (Hash{Symbol => Object}) (defaults to: {})

23
24
25
26
27
# File 'lib/petitest/dsl.rb', line 23

def test(description,  = {}, &block)
  block ||= -> { skip }
  desc(description)
  define_method("test_#{description}", &block)
end