Class: Tunit::Runnable
- Inherits:
-
Object
- Object
- Tunit::Runnable
- Defined in:
- lib/tunit/runnable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Returns the value of attribute assertions.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#name ⇒ Object
Returns the value of attribute name.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
- .inherited(klass) ⇒ Object
- .run(reporter, options = {}) ⇒ Object
- .runnable_methods ⇒ Object
- .runnables ⇒ Object
- .runnables=(runnable) ⇒ Object
Instance Method Summary collapse
-
#initialize(name) ⇒ Runnable
constructor
A new instance of Runnable.
- #run ⇒ Object
Constructor Details
#initialize(name) ⇒ Runnable
Returns a new instance of Runnable.
33 34 35 36 37 |
# File 'lib/tunit/runnable.rb', line 33 def initialize name self.name = name self.assertions = 0 self.failures = [] end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions.
38 39 40 |
# File 'lib/tunit/runnable.rb', line 38 def assertions @assertions end |
#failures ⇒ Object
Returns the value of attribute failures.
38 39 40 |
# File 'lib/tunit/runnable.rb', line 38 def failures @failures end |
#name ⇒ Object
Returns the value of attribute name.
38 39 40 |
# File 'lib/tunit/runnable.rb', line 38 def name @name end |
#time ⇒ Object
Returns the value of attribute time.
38 39 40 |
# File 'lib/tunit/runnable.rb', line 38 def time @time end |
Class Method Details
.inherited(klass) ⇒ Object
15 16 17 18 |
# File 'lib/tunit/runnable.rb', line 15 def self.inherited klass self.runnables << klass super end |
.run(reporter, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tunit/runnable.rb', line 20 def self.run reporter, = {} filter = .fetch(:filter) { '/./' } filter = Regexp.new $1 if filter =~ /\/(.*)\// filtered_methods = self.runnable_methods.select { |m| filter === m || filter === "#{self}##{m}" } filtered_methods.each { |test| reporter.record self.new(test).run } end |
.runnable_methods ⇒ Object
3 4 5 |
# File 'lib/tunit/runnable.rb', line 3 def self.runnable_methods raise NotImplementedError, "subclass responsibility" end |
.runnables ⇒ Object
7 8 9 |
# File 'lib/tunit/runnable.rb', line 7 def self.runnables @@runnables ||= [] end |
.runnables=(runnable) ⇒ Object
11 12 13 |
# File 'lib/tunit/runnable.rb', line 11 def self.runnables= runnable @@runnables = [runnable].flatten end |
Instance Method Details
#run ⇒ Object
41 42 43 |
# File 'lib/tunit/runnable.rb', line 41 def run fail NotImplementedError, "subclass responsibility" end |