Class: Speq::Group

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

Overview

Common interface for all for Test and Expression

Direct Known Subclasses

Expression, Test

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Group

Returns a new instance of Group.



50
51
52
53
54
# File 'lib/speq.rb', line 50

def initialize(parent = nil)
  @parent = parent
  @context = Context.new
  @units = []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

#unitsObject (readonly)

Returns the value of attribute units.



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

def units
  @units
end

Instance Method Details

#<<(unit) ⇒ Object



72
73
74
# File 'lib/speq.rb', line 72

def <<(unit)
  units << unit
end

#error?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/speq.rb', line 68

def error?
  outcome.error?
end

#fail?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/speq.rb', line 64

def fail?
  outcome.fail?
end

#full_contextObject



76
77
78
# File 'lib/speq.rb', line 76

def full_context
  parent ? context.merge(parent.full_context) : context
end

#indentObject



17
18
19
# File 'lib/speq/string_fmt.rb', line 17

def indent
  parent ? parent.indent + '  ' : ''
end

#newlineObject



21
22
23
# File 'lib/speq/string_fmt.rb', line 21

def newline
  "\n#{indent}"
end

#outcomeObject



56
57
58
# File 'lib/speq.rb', line 56

def outcome
  Outcome.aggregate(units.map(&:outcome))
end

#pass?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/speq.rb', line 60

def pass?
  outcome.pass?
end

#reportObject



13
14
15
# File 'lib/speq/string_fmt.rb', line 13

def report
  outcome.report
end