Class: TestBench::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/test_bench/result.rb,
lib/test_bench/result/null.rb,
lib/test_bench/result/assertions.rb

Defined Under Namespace

Modules: Assertions, Null

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assertionsObject

Returns the value of attribute assertions

Returns:

  • (Object)

    the current value of assertions



2
3
4
# File 'lib/test_bench/result.rb', line 2

def assertions
  @assertions
end

#clockObject



15
16
17
# File 'lib/test_bench/result.rb', line 15

def clock
  @clock ||= Time
end

#errorsObject

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



2
3
4
# File 'lib/test_bench/result.rb', line 2

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures

Returns:

  • (Object)

    the current value of failures



2
3
4
# File 'lib/test_bench/result.rb', line 2

def failures
  @failures
end

#filesObject

Returns the value of attribute files

Returns:

  • (Object)

    the current value of files



2
3
4
# File 'lib/test_bench/result.rb', line 2

def files
  @files
end

#passesObject

Returns the value of attribute passes

Returns:

  • (Object)

    the current value of passes



2
3
4
# File 'lib/test_bench/result.rb', line 2

def passes
  @passes
end

#skipsObject

Returns the value of attribute skips

Returns:

  • (Object)

    the current value of skips



2
3
4
# File 'lib/test_bench/result.rb', line 2

def skips
  @skips
end

#start_timeObject

Returns the value of attribute start_time

Returns:

  • (Object)

    the current value of start_time



2
3
4
# File 'lib/test_bench/result.rb', line 2

def start_time
  @start_time
end

#stop_timeObject

Returns the value of attribute stop_time

Returns:

  • (Object)

    the current value of stop_time



2
3
4
# File 'lib/test_bench/result.rb', line 2

def stop_time
  @stop_time
end

Class Method Details

.buildObject



5
6
7
8
9
# File 'lib/test_bench/result.rb', line 5

def self.build
  instance = new [], 0, 0, 0, 0, 0
  instance.started
  instance
end

Instance Method Details

#assertedObject



11
12
13
# File 'lib/test_bench/result.rb', line 11

def asserted
  self.assertions += 1
end

#elapsed_timeObject



19
20
21
# File 'lib/test_bench/result.rb', line 19

def elapsed_time
  stop_time - start_time
end

#error_raised(error) ⇒ Object



23
24
25
# File 'lib/test_bench/result.rb', line 23

def error_raised error
  self.errors += 1
end

#failed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/test_bench/result.rb', line 27

def failed?
  not passed?
end

#file_finished(file) ⇒ Object



31
32
33
# File 'lib/test_bench/result.rb', line 31

def file_finished file
  files << file
end

#finishedObject Also known as: run_finished



35
36
37
# File 'lib/test_bench/result.rb', line 35

def finished
  self.stop_time ||= clock.now
end

#passed?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/test_bench/result.rb', line 40

def passed?
  failures.zero? and errors.zero?
end

#startedObject Also known as: run_started



44
45
46
# File 'lib/test_bench/result.rb', line 44

def started
  self.start_time = clock.now
end

#test_failed(prose) ⇒ Object



49
50
51
# File 'lib/test_bench/result.rb', line 49

def test_failed prose
  self.failures += 1
end

#test_passed(prose) ⇒ Object



53
54
55
# File 'lib/test_bench/result.rb', line 53

def test_passed prose
  self.passes += 1
end

#test_skipped(prose) ⇒ Object



57
58
59
# File 'lib/test_bench/result.rb', line 57

def test_skipped prose
  self.skips += 1
end

#testsObject



61
62
63
# File 'lib/test_bench/result.rb', line 61

def tests
  failures + passes + skips
end

#tests_per_secondObject



65
66
67
68
69
# File 'lib/test_bench/result.rb', line 65

def tests_per_second
  elapsed_time = self.elapsed_time
  elapsed_time = elapsed_time.next_float if elapsed_time.zero?
  Rational tests, elapsed_time
end