Class: Kontrast::TestSuite

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestSuite

Returns a new instance of TestSuite.



5
6
7
8
# File 'lib/kontrast/test_suite.rb', line 5

def initialize
    @tests = []
    @lazy_tests = []
end

Instance Attribute Details

#lazy_testsObject (readonly)

Returns the value of attribute lazy_tests.



3
4
5
# File 'lib/kontrast/test_suite.rb', line 3

def lazy_tests
  @lazy_tests
end

#testsObject (readonly)

Returns the value of attribute tests.



3
4
5
# File 'lib/kontrast/test_suite.rb', line 3

def tests
  @tests
end

Instance Method Details

#<<(test) ⇒ Object



10
11
12
13
14
15
# File 'lib/kontrast/test_suite.rb', line 10

def <<(test)
    if(!test.is_a?(Test))
        raise TestSuiteException.new("Cannot add a #{test.class} to the test suite.")
    end
    @tests << test
end

#bind_specsObject

Binds specs to tests automatically by matching the test’s name to the spec’s name



18
19
20
21
22
23
24
# File 'lib/kontrast/test_suite.rb', line 18

def bind_specs
    specs = Kontrast.get_spec_builder.specs
    specs.each do |spec|
        matched_tests = @tests.select { |t| t.to_s.include?(spec.name) }
        matched_tests.each { |t| t.bind_spec(spec) }
    end
end

#clear!Object



38
39
40
# File 'lib/kontrast/test_suite.rb', line 38

def clear!
    @tests = []
end

#to_hObject

For rspec



27
28
29
30
31
32
33
34
35
36
# File 'lib/kontrast/test_suite.rb', line 27

def to_h
    suite_hash = Hash.new

    @tests.each do |test|
        suite_hash[test.width] ||= {}
        suite_hash[test.width][test.name] = test.path
    end

    return suite_hash
end