Class: Assert::Suite
- Inherits:
-
Object
- Object
- Assert::Suite
- Defined in:
- lib/assert/suite.rb
Defined Under Namespace
Classes: ContextInfo
Constant Summary collapse
- TEST_METHOD_REGEX =
/^test./
Instance Attribute Summary collapse
-
#config ⇒ Object
A suite is a set of tests to run.
-
#end_time ⇒ Object
A suite is a set of tests to run.
-
#start_time ⇒ Object
A suite is a set of tests to run.
-
#test_methods ⇒ Object
A suite is a set of tests to run.
-
#tests ⇒ Object
(also: #ordered_tests)
A suite is a set of tests to run.
Instance Method Summary collapse
- #count(thing) ⇒ Object
-
#initialize(config) ⇒ Suite
constructor
A new instance of Suite.
- #inspect ⇒ Object
- #result_count(type = nil) ⇒ Object
- #result_rate ⇒ Object
- #results ⇒ Object (also: #ordered_results)
- #run_time ⇒ Object
- #setup(&block) ⇒ Object (also: #startup)
- #teardown(&block) ⇒ Object (also: #shutdown)
- #test_count ⇒ Object
- #test_rate ⇒ Object
Constructor Details
#initialize(config) ⇒ Suite
Returns a new instance of Suite.
13 14 15 16 17 18 19 |
# File 'lib/assert/suite.rb', line 13 def initialize(config) @config = config @tests = [] @test_methods = [] @start_time = 0 @end_time = 0 end |
Instance Attribute Details
#config ⇒ Object
A suite is a set of tests to run. When a test class subclasses the Context class, that test class is pushed to the suite.
11 12 13 |
# File 'lib/assert/suite.rb', line 11 def config @config end |
#end_time ⇒ Object
A suite is a set of tests to run. When a test class subclasses the Context class, that test class is pushed to the suite.
11 12 13 |
# File 'lib/assert/suite.rb', line 11 def end_time @end_time end |
#start_time ⇒ Object
A suite is a set of tests to run. When a test class subclasses the Context class, that test class is pushed to the suite.
11 12 13 |
# File 'lib/assert/suite.rb', line 11 def start_time @start_time end |
#test_methods ⇒ Object
A suite is a set of tests to run. When a test class subclasses the Context class, that test class is pushed to the suite.
11 12 13 |
# File 'lib/assert/suite.rb', line 11 def test_methods @test_methods end |
#tests ⇒ Object Also known as: ordered_tests
A suite is a set of tests to run. When a test class subclasses the Context class, that test class is pushed to the suite.
11 12 13 |
# File 'lib/assert/suite.rb', line 11 def tests @tests end |
Instance Method Details
#count(thing) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/assert/suite.rb', line 40 def count(thing) case thing when :tests test_count when :results result_count when :passed, :pass result_count(:pass) when :failed, :fail result_count(:fail) when :ignored, :ignore result_count(:ignore) when :skipped, :skip result_count(:skip) when :errored, :error result_count(:error) else 0 end end |
#inspect ⇒ Object
93 94 95 96 97 |
# File 'lib/assert/suite.rb', line 93 def inspect "#<#{self.class}:#{'0x0%x' % (object_id << 1)}"\ " test_count=#{self.test_count.inspect}"\ " result_count=#{self.result_count.inspect}>" end |
#result_count(type = nil) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/assert/suite.rb', line 65 def result_count(type=nil) if type self.tests.inject(0) do |count, test| count += test.result_count(type) end else self.results.size end end |
#result_rate ⇒ Object
29 30 31 |
# File 'lib/assert/suite.rb', line 29 def result_rate get_rate(self.results.size, self.run_time) end |
#results ⇒ Object Also known as: ordered_results
35 36 37 |
# File 'lib/assert/suite.rb', line 35 def results tests.inject([]) {|results, test| results += test.results} end |
#run_time ⇒ Object
21 22 23 |
# File 'lib/assert/suite.rb', line 21 def run_time @end_time - @start_time end |
#setup(&block) ⇒ Object Also known as: startup
75 76 77 78 79 80 81 |
# File 'lib/assert/suite.rb', line 75 def setup(&block) if block_given? self.setups << block else self.setups.each{ |setup| setup.call } end end |
#teardown(&block) ⇒ Object Also known as: shutdown
84 85 86 87 88 89 90 |
# File 'lib/assert/suite.rb', line 84 def teardown(&block) if block_given? self.teardowns << block else self.teardowns.reverse.each{ |teardown| teardown.call } end end |
#test_count ⇒ Object
61 62 63 |
# File 'lib/assert/suite.rb', line 61 def test_count self.tests.size end |
#test_rate ⇒ Object
25 26 27 |
# File 'lib/assert/suite.rb', line 25 def test_rate get_rate(self.tests.size, self.run_time) end |