Class: Speq::Test

Inherits:
Group
  • Object
show all
Defined in:
lib/speq.rb,
lib/speq/string_fmt.rb

Overview

A test group is a collection of tests with a description

Instance Attribute Summary collapse

Attributes inherited from Group

#context, #parent, #units

Instance Method Summary collapse

Methods inherited from Group

#<<, #error?, #fail?, #full_context, #indent, #newline, #outcome, #pass?, #report

Constructor Details

#initialize(description, parent = nil, &block) ⇒ Test

Returns a new instance of Test.



85
86
87
88
89
# File 'lib/speq.rb', line 85

def initialize(description, parent = nil, &block)
  super(parent)
  @description = description
  run &block if block_given?
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



83
84
85
# File 'lib/speq.rb', line 83

def description
  @description
end

Instance Method Details

#run(&block) ⇒ Object



91
92
93
# File 'lib/speq.rb', line 91

def run(&block)
  TestBlock.new(self, &block)
end

#speq(description, &block) ⇒ Object



95
96
97
# File 'lib/speq.rb', line 95

def speq(description, &block)
  self << Test.new(description, self, &block)
end

#titleObject



27
28
29
# File 'lib/speq/string_fmt.rb', line 27

def title
  "#{outcome} #{description}"
end

#to_sObject



31
32
33
# File 'lib/speq/string_fmt.rb', line 31

def to_s
  [newline, title, units.join(''), parent ? '' : newline + report].join('')
end