Class: Kontrast::TestSuite
- Inherits:
-
Object
- Object
- Kontrast::TestSuite
- Defined in:
- lib/kontrast/test_suite.rb
Instance Attribute Summary collapse
-
#lazy_tests ⇒ Object
readonly
Returns the value of attribute lazy_tests.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
- #<<(test) ⇒ Object
-
#bind_specs ⇒ Object
Binds specs to tests automatically by matching the test’s name to the spec’s name.
- #clear! ⇒ Object
-
#initialize ⇒ TestSuite
constructor
A new instance of TestSuite.
-
#to_h ⇒ Object
For rspec.
Constructor Details
#initialize ⇒ TestSuite
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_tests ⇒ Object (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 |
#tests ⇒ Object (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_specs ⇒ Object
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_h ⇒ Object
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 |