Class: RubyDocTest::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/test.rb

Overview

This is the top-level 'test' container that holds an optional description and one or more CodeBlock objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, code_blocks) ⇒ Test

Returns a new instance of Test.


8
9
10
# File 'lib/test.rb', line 8

def initialize(description, code_blocks)
  @description, @code_blocks = description, code_blocks
end

Instance Attribute Details

#code_blocksObject (readonly)

Returns the value of attribute code_blocks


6
7
8
# File 'lib/test.rb', line 6

def code_blocks
  @code_blocks
end

#descriptionObject

Returns the value of attribute description


5
6
7
# File 'lib/test.rb', line 5

def description
  @description
end

#passedObject (readonly)

Returns the value of attribute passed


6
7
8
# File 'lib/test.rb', line 6

def passed
  @passed
end

Instance Method Details

#actual_resultObject


20
21
22
# File 'lib/test.rb', line 20

def actual_result
  first_failed.actual_result.inspect
end

#expected_resultObject


24
25
26
# File 'lib/test.rb', line 24

def expected_result
  first_failed.expected_result
end

#first_failedObject


16
17
18
# File 'lib/test.rb', line 16

def first_failed
  @code_blocks.detect{ |cb| !cb.pass? }
end

#pass?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/test.rb', line 12

def pass?
  @passed = @code_blocks.all?{ |c| c.pass? }
end