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
-
#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 ⇒ Suite
constructor
A new instance of Suite.
- #result_count(type = nil) ⇒ Object
- #results ⇒ Object (also: #ordered_results)
- #run_time ⇒ Object
- #runner_seed ⇒ Object
- #setup(&block) ⇒ Object (also: #startup)
- #teardown(&block) ⇒ Object (also: #shutdown)
- #test_count ⇒ Object
Constructor Details
#initialize ⇒ Suite
Returns a new instance of Suite.
28 29 30 31 32 33 |
# File 'lib/assert/suite.rb', line 28 def initialize @tests = [] @test_methods = [] @start_time = 0 @end_time = 0 end |
Instance Attribute Details
#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.
26 27 28 |
# File 'lib/assert/suite.rb', line 26 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.
26 27 28 |
# File 'lib/assert/suite.rb', line 26 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.
26 27 28 |
# File 'lib/assert/suite.rb', line 26 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.
26 27 28 |
# File 'lib/assert/suite.rb', line 26 def tests @tests end |
Instance Method Details
#count(thing) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/assert/suite.rb', line 53 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 |
#result_count(type = nil) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/assert/suite.rb', line 78 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 |
#results ⇒ Object Also known as: ordered_results
48 49 50 |
# File 'lib/assert/suite.rb', line 48 def results tests.inject([]) {|results, test| results += test.results} end |
#run_time ⇒ Object
35 36 37 |
# File 'lib/assert/suite.rb', line 35 def run_time @end_time - @start_time end |
#runner_seed ⇒ Object
39 40 41 42 43 44 |
# File 'lib/assert/suite.rb', line 39 def runner_seed @run_seed ||= (ENV["runner_seed"] || begin srand srand % 0xFFFF end).to_i end |
#setup(&block) ⇒ Object Also known as: startup
88 89 90 91 92 93 94 |
# File 'lib/assert/suite.rb', line 88 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
97 98 99 100 101 102 103 |
# File 'lib/assert/suite.rb', line 97 def teardown(&block) if block_given? self.teardowns << block else self.teardowns.reverse.each{|teardown| teardown.call} end end |
#test_count ⇒ Object
74 75 76 |
# File 'lib/assert/suite.rb', line 74 def test_count self.tests.size end |