Class: Assert::Test
- Inherits:
-
Object
- Object
- Assert::Test
- Defined in:
- lib/assert/test.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
a Test is some code/method to run in the scope of a Context.
-
#config ⇒ Object
readonly
a Test is some code/method to run in the scope of a Context.
-
#context_info ⇒ Object
readonly
a Test is some code/method to run in the scope of a Context.
-
#name ⇒ Object
readonly
a Test is some code/method to run in the scope of a Context.
-
#output ⇒ Object
Returns the value of attribute output.
-
#results ⇒ Object
Returns the value of attribute results.
-
#run_time ⇒ Object
Returns the value of attribute run_time.
Instance Method Summary collapse
- #<=>(other_test) ⇒ Object
- #context_class ⇒ Object
-
#initialize(name, suite_ci, config, opts = nil, &block) ⇒ Test
constructor
A new instance of Test.
- #inspect ⇒ Object
- #result_count(type = nil) ⇒ Object
- #result_rate ⇒ Object
- #run(&result_callback) ⇒ Object
Constructor Details
#initialize(name, suite_ci, config, opts = nil, &block) ⇒ Test
Returns a new instance of Test.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/assert/test.rb', line 13 def initialize(name, suite_ci, config, opts = nil, &block) @context_info = suite_ci @name, @config = name_from_context(name), config o = opts || {} @code = o[:code] || block || Proc.new{} @results = Result::Set.new @output = "" @run_time = 0 @result_rate = 0 end |
Instance Attribute Details
#code ⇒ Object (readonly)
a Test is some code/method to run in the scope of a Context. After a a test runs, it should have some assertions which are its results.
10 11 12 |
# File 'lib/assert/test.rb', line 10 def code @code end |
#config ⇒ Object (readonly)
a Test is some code/method to run in the scope of a Context. After a a test runs, it should have some assertions which are its results.
10 11 12 |
# File 'lib/assert/test.rb', line 10 def config @config end |
#context_info ⇒ Object (readonly)
a Test is some code/method to run in the scope of a Context. After a a test runs, it should have some assertions which are its results.
10 11 12 |
# File 'lib/assert/test.rb', line 10 def context_info @context_info end |
#name ⇒ Object (readonly)
a Test is some code/method to run in the scope of a Context. After a a test runs, it should have some assertions which are its results.
10 11 12 |
# File 'lib/assert/test.rb', line 10 def name @name end |
#output ⇒ Object
Returns the value of attribute output.
11 12 13 |
# File 'lib/assert/test.rb', line 11 def output @output end |
#results ⇒ Object
Returns the value of attribute results.
11 12 13 |
# File 'lib/assert/test.rb', line 11 def results @results end |
#run_time ⇒ Object
Returns the value of attribute run_time.
11 12 13 |
# File 'lib/assert/test.rb', line 11 def run_time @run_time end |
Instance Method Details
#<=>(other_test) ⇒ Object
61 62 63 |
# File 'lib/assert/test.rb', line 61 def <=>(other_test) self.name <=> other_test.name end |
#context_class ⇒ Object
26 27 28 |
# File 'lib/assert/test.rb', line 26 def context_class self.context_info.klass end |
#inspect ⇒ Object
65 66 67 68 69 70 |
# File 'lib/assert/test.rb', line 65 def inspect attributes_string = ([ :name, :context_info, :results ].collect do |attr| "@#{attr}=#{self.send(attr).inspect}" end).join(" ") "#<#{self.class}:#{'0x0%x' % (object_id << 1)} #{attributes_string}>" end |
#result_count(type = nil) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/assert/test.rb', line 49 def result_count(type=nil) if Assert::Result.types.include?(type) self.send("#{type}_results").size else @results.size end end |
#result_rate ⇒ Object
57 58 59 |
# File 'lib/assert/test.rb', line 57 def result_rate get_rate(self.result_count, self.run_time) end |
#run(&result_callback) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/assert/test.rb', line 30 def run(&result_callback) @results = Result::Set.new(result_callback) scope = self.context_class.new(self, self.config) start_time = Time.now capture_output do self.context_class.send('run_arounds', scope){ run_test_main(scope) } end @run_time = Time.now - start_time @results end |