Class: Sapphire::DSL::TestPlans::TestPlan

Inherits:
Object
  • Object
show all
Defined in:
lib/sapphire/DSL/TestPlans/TestPlan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, &block) ⇒ TestPlan

Returns a new instance of TestPlan.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 15

def initialize(text, &block)
  @value = text
  @text = text.to_s
  @block = block

  @items = []
  @handlers = []
  @coverage = []

  AddHandler :file => FileHandler.new
  AddHandler :path => PathHandler.new

end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



11
12
13
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 11

def block
  @block
end

#textObject (readonly)

Returns the value of attribute text.



13
14
15
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 13

def text
  @text
end

#valueObject (readonly)

Returns the value of attribute value.



12
13
14
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 12

def value
  @value
end

Instance Method Details

#Add(item) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 33

def Add(item)
  item.keys.each do |key|
    @handlers.each do |handler|
      handler.keys.each do |handler_key|
        if(handler_key == key)
          handler[handler_key].Handle item[key]
        end
      end
    end
  end
end

#AddHandler(handler) ⇒ Object



45
46
47
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 45

def AddHandler(handler)
  @handlers << handler
end

#Cover(item) ⇒ Object



29
30
31
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 29

def Cover(item)
  @coverage << item
end

#executeObject



49
50
51
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 49

def execute
  @block.call
end

#Report(&block) ⇒ Object



53
54
55
56
57
# File 'lib/sapphire/DSL/TestPlans/TestPlan.rb', line 53

def Report(&block)
  $instances.each do |reporter|
    block.call reporter
  end
end