Class: Whitestone::Test

Inherits:
Object show all
Defined in:
lib/whitestone.rb

Overview

A Test object is what results when the following code is executed:

D "civil" do
  Eq @d.year,   1972
  Eq @d.month,  5
  Eq @d.day,    13
end

Test objects gather in a tree structure, useful for reporting.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, block, sandbox) ⇒ Test

Returns a new instance of Test.



54
55
56
57
58
59
60
# File 'lib/whitestone.rb', line 54

def initialize(description, block, sandbox)
  @description, @block, @sandbox = description, block, sandbox
  @result = :blank  # A 'blank' result until an assertion is run.
  @error  = nil     # The exception object, if any.
  @parent = nil     # The test object in whose scope this test is defined.
  @children = []    # The children of this test.
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



49
50
51
# File 'lib/whitestone.rb', line 49

def block
  @block
end

#childrenObject (readonly)

Returns the value of attribute children.



53
54
55
# File 'lib/whitestone.rb', line 53

def children
  @children
end

#descriptionObject

Returns the value of attribute description.



49
50
51
# File 'lib/whitestone.rb', line 49

def description
  @description
end

#errorObject

Returns the value of attribute error.



51
52
53
# File 'lib/whitestone.rb', line 51

def error
  @error
end

#parentObject

Returns the value of attribute parent.



52
53
54
# File 'lib/whitestone.rb', line 52

def parent
  @parent
end

#resultObject

Returns the value of attribute result.



50
51
52
# File 'lib/whitestone.rb', line 50

def result
  @result
end

#sandboxObject

Returns the value of attribute sandbox.



49
50
51
# File 'lib/whitestone.rb', line 49

def sandbox
  @sandbox
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


70
# File 'lib/whitestone.rb', line 70

def blank?;  @result == :blank; end

#error?Boolean

Returns:

  • (Boolean)


69
# File 'lib/whitestone.rb', line 69

def error?;  @result == :error; end

#failed?Boolean

Returns:

  • (Boolean)


68
# File 'lib/whitestone.rb', line 68

def failed?; @result == :fail;  end

#passed?Boolean

Returns:

  • (Boolean)


67
# File 'lib/whitestone.rb', line 67

def passed?; @result == :pass;  end