Class: PryTest::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-test/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatter, options = {}) ⇒ Runner

Returns a new instance of Runner.



18
19
20
21
# File 'lib/pry-test/runner.rb', line 18

def initialize(formatter, options = {})
  @formatter = formatter
  @options = options
end

Instance Attribute Details

#duration ⇒ Object (readonly)

Returns the value of attribute duration.



16
17
18
# File 'lib/pry-test/runner.rb', line 16

def duration
  @duration
end

#formatter ⇒ Object (readonly)

Returns the value of attribute formatter.



16
17
18
# File 'lib/pry-test/runner.rb', line 16

def formatter
  @formatter
end

#options ⇒ Object (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/pry-test/runner.rb', line 16

def options
  @options
end

Class Method Details

.terminate ⇒ Object



7
8
9
# File 'lib/pry-test/runner.rb', line 7

def terminate
  @terminate = true
end

.terminate? ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pry-test/runner.rb', line 11

def terminate?
  !!@terminate
end

Instance Method Details

#failed ⇒ Object



42
43
44
# File 'lib/pry-test/runner.rb', line 42

def failed
  failed_tests.length
end

#failed_tests ⇒ Object



38
39
40
# File 'lib/pry-test/runner.rb', line 38

def failed_tests
  tests.select { |test| test.invoked? && !test.passed? }
end

#passed ⇒ Object



50
51
52
# File 'lib/pry-test/runner.rb', line 50

def passed
  passed_tests.length
end

#passed_tests ⇒ Object



46
47
48
# File 'lib/pry-test/runner.rb', line 46

def passed_tests
  tests.select { |test| test.invoked? && test.passed? }
end

#run ⇒ Object



23
24
25
26
27
28
# File 'lib/pry-test/runner.rb', line 23

def run
  formatter.before_suite(test_classes)
  run_test_classes
  formatter.after_suite(test_classes)
  failed
end

#test_classes ⇒ Object



30
31
32
# File 'lib/pry-test/runner.rb', line 30

def test_classes
  @test_classes ||= PryTest::Test.subclasses.shuffle
end

#tests ⇒ Object



34
35
36
# File 'lib/pry-test/runner.rb', line 34

def tests
  @tests ||= test_classes.map { |klass| klass.tests }.flatten
end