Class: Fix::Test Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fix/test.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Wraps the target of the specs document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(front_object, verbose: true, color: true, **options, &specs) ⇒ Test

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the test class.

Parameters:

  • front_object (BasicObject)

    The front object of the test.

  • options (Hash)

    Some options.

  • specs (Proc)

    The specs to test against the object.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fix/test.rb', line 14

def initialize(front_object, verbose: true, color: true, **options, &specs)
  @configuration = options.merge(
    verbose: verbose,
    color: color
  )

  start_time = ::Time.now

  g = On.new(front_object, [], [], {}, @configuration)
  g.instance_eval(&specs)

  @results    = g.results
  @total_time = ::Time.now - start_time
end

Instance Attribute Details

#configurationHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The settings.

Returns:

  • (Hash)

    The settings.



32
33
34
# File 'lib/fix/test.rb', line 32

def configuration
  @configuration
end

#resultsArray (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The results.

Returns:

  • (Array)

    The results.



37
38
39
# File 'lib/fix/test.rb', line 37

def results
  @results
end

#total_timeFloat (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The total time.

Returns:

  • (Float)

    The total time.



42
43
44
# File 'lib/fix/test.rb', line 42

def total_time
  @total_time
end

Instance Method Details

#fail?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return false if the test fail.

Returns:

  • (Boolean)

    Return false if the test fail.



71
72
73
# File 'lib/fix/test.rb', line 71

def fail?
  !pass?
end

#pass?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The state of the test.

Returns:

  • (Boolean)

    Return true if the test pass.



66
67
68
# File 'lib/fix/test.rb', line 66

def pass?
  results.all?(&:result?)
end

#reportReport

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The report of the test.

Returns:

  • (Report)

    The report of the test.



59
60
61
# File 'lib/fix/test.rb', line 59

def report
  Report.new(self)
end

#statisticsHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Some statistics.

Returns:

  • (Hash)

    Some statistics.



47
48
49
50
51
52
53
54
# File 'lib/fix/test.rb', line 47

def statistics
  {
    pass_percent: pass_percent,
    total_infos: results.count { |r| r.to_sym.equal?(:info) },
    total_failures: results.count { |r| r.to_sym.equal?(:failure) },
    total_errors: results.count { |r| r.to_sym.equal?(:error) }
  }
end