Class: XSpec::NestedUnitOfWork

Inherits:
Struct
  • Object
show all
Defined in:
lib/xspec/data_structures.rb

Overview

Units of work can be nested inside contexts. This is the main object that other components of the system work with.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentsObject

Returns the value of attribute parents

Returns:

  • (Object)

    the current value of parents



155
156
157
# File 'lib/xspec/data_structures.rb', line 155

def parents
  @parents
end

#unit_of_workObject

Returns the value of attribute unit_of_work

Returns:

  • (Object)

    the current value of unit_of_work



155
156
157
# File 'lib/xspec/data_structures.rb', line 155

def unit_of_work
  @unit_of_work
end

Instance Method Details

#blockObject



156
# File 'lib/xspec/data_structures.rb', line 156

def block; unit_of_work.block; end

#full_nameObject



159
160
161
# File 'lib/xspec/data_structures.rb', line 159

def full_name
  (parents + [self]).map(&:name).compact.join(' ')
end

#immediate_parentObject



163
164
165
# File 'lib/xspec/data_structures.rb', line 163

def immediate_parent
  parents.last
end

#nameObject



157
# File 'lib/xspec/data_structures.rb', line 157

def name;  unit_of_work.name; end

#nest_under(parent) ⇒ Object



167
168
169
# File 'lib/xspec/data_structures.rb', line 167

def nest_under(parent)
  self.class.new([parent] + parents, unit_of_work)
end