Class: Tunit::Runnable

Inherits:
Object
  • Object
show all
Defined in:
lib/tunit/runnable.rb

Direct Known Subclasses

Test

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#assertionsObject

Returns the value of attribute assertions.



38
39
40
# File 'lib/tunit/runnable.rb', line 38

def assertions
  @assertions
end

#failuresObject

Returns the value of attribute failures.



38
39
40
# File 'lib/tunit/runnable.rb', line 38

def failures
  @failures
end

#nameObject

Returns the value of attribute name.



38
39
40
# File 'lib/tunit/runnable.rb', line 38

def name
  @name
end

#timeObject

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, options = {}
  filter = options.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_methodsObject

Raises:

  • (NotImplementedError)


3
4
5
# File 'lib/tunit/runnable.rb', line 3

def self.runnable_methods
  raise NotImplementedError, "subclass responsibility"
end

.runnablesObject



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

#runObject



41
42
43
# File 'lib/tunit/runnable.rb', line 41

def run
  fail NotImplementedError, "subclass responsibility"
end