Module: Assert::Context::SubjectDSL

Included in:
Assert::Context
Defined in:
lib/assert/context/subject_dsl.rb

Instance Method Summary collapse

Instance Method Details

#description(text = nil) ⇒ Object Also known as: desc, describe

Add a piece of description text or return the full description for the context.



9
10
11
12
13
14
15
16
17
# File 'lib/assert/context/subject_dsl.rb', line 9

def description(text = nil)
  if text
    descriptions << text.to_s
  else
    parent = superclass.desc if superclass.respond_to?(:desc)
    own = descriptions
    [parent, *own].compact.reject(&:empty?).join(" ")
  end
end

#subject(&block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/assert/context/subject_dsl.rb', line 21

def subject(&block)
  if block_given?
    @subject = block
  else
    @subject || (superclass.subject if superclass.respond_to?(:subject))
  end
end