Module: Docspec::Testable

Includes:
Colsole
Included in:
Document
Defined in:
lib/docspec/testable.rb

Instance Method Summary collapse

Instance Method Details

#failed_examplesObject



11
12
13
# File 'lib/docspec/testable.rb', line 11

def failed_examples
  @failed_examples ||= examples.select(&:consider_failed?)
end

#success?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/docspec/testable.rb', line 7

def success?
  failed_examples.count.zero?
end

#testObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/docspec/testable.rb', line 15

def test
  examples.each do |example|
    if example.empty?
      say "m`void :` #{example.label}"
    elsif example.success?
      say "g`pass :` #{example.label}"
    else
      say "r`FAIL : #{example.label}`"
      say '---'
      puts example.diff
      say '---'
    end
  end
end