Class: Attest::TestContainer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description) ⇒ TestContainer

Returns a new instance of TestContainer.



9
10
11
12
13
# File 'lib/attest/test_container.rb', line 9

def initialize(description)
  @file = Attest.current_file
  @description = description
  @test_objects = []
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



7
8
9
# File 'lib/attest/test_container.rb', line 7

def after
  @after
end

#beforeObject

Returns the value of attribute before.



7
8
9
# File 'lib/attest/test_container.rb', line 7

def before
  @before
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#test_objectsObject (readonly)

Returns the value of attribute test_objects.



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

def test_objects
  @test_objects
end

Instance Method Details

#add(test) ⇒ Object



15
16
17
# File 'lib/attest/test_container.rb', line 15

def add(test)
  @test_objects << test
end

#execute_allObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/attest/test_container.rb', line 19

def execute_all
  Attest.output_writer.before_container(self)
  container_context = Attest::ExecutionContext.new
  begin
    container_context.instance_eval(&@before) if @before
    @test_objects.each do |test_object|
      test_object.run container_context
    end
    container_context.instance_eval(&@after) if @after
  rescue => e
    Attest.output_writer.an_error(e)
    Attest.output_writer.ignore_container(self)
  end
  Attest.output_writer.after_container(self)
end