Class: FunWith::Gems::TestResults

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_with/gems/test_results.rb

Constant Summary collapse

TEST_SUITE_DATA_REGEX =
/(?<tests>\d+) (?:tests|runs), (?<assertions>\d+) assertions, (?<failures>\d+) failures, (?<errors>\d+) errors, (?<skips>\d+) skips/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(g) ⇒ TestResults

Returns a new instance of TestResults.



8
9
10
# File 'lib/fun_with/gems/test_results.rb', line 8

def initialize g
  self.gem_const = g
end

Instance Attribute Details

#fail_countObject

Returns the value of attribute fail_count.



6
7
8
# File 'lib/fun_with/gems/test_results.rb', line 6

def fail_count
  @fail_count
end

#gem_constObject

Returns the value of attribute gem_const.



6
7
8
# File 'lib/fun_with/gems/test_results.rb', line 6

def gem_const
  @gem_const
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/fun_with/gems/test_results.rb', line 6

def output
  @output
end

#test_results_foundObject

Returns the value of attribute test_results_found.



6
7
8
# File 'lib/fun_with/gems/test_results.rb', line 6

def test_results_found
  @test_results_found
end

Instance Method Details

#no_failures_or_errors?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fun_with/gems/test_results.rb', line 21

def no_failures_or_errors?
  fail_count == 0
end

#passed?Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/fun_with/gems/test_results.rb', line 12

def passed?
  self.scan_test_results
  self.test_results_found? && no_failures_or_errors?
end

#scan_test_resultsObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fun_with/gems/test_results.rb', line 25

def scan_test_results
  raise "No output to scan!" if self.output.nil?
  
  if m = self.output.match( TEST_SUITE_DATA_REGEX )
    self.test_results_found = true
    self.fail_count = m[:failures].to_i + m[:errors].to_i
  else
    self.fail_count = -1
    self.test_results_found = false
  end
end

#test_results_found?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fun_with/gems/test_results.rb', line 17

def test_results_found?
  self.test_results_found
end