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, 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) (defaults to: {})

    Some options.

  • specs (Proc)

    The specs to test against the object.



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

def initialize(front_object, options = {}, &specs)
  @configuration = { verbose: true }
  @configuration.update(options)

  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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

def statistics
  {
    pass_percent:   pass_percent,
    total_infos:    results.count { |r| r.to_char == 'I' },
    total_failures: results.count { |r| r.to_char == 'F' },
    total_errors:   results.count { |r| r.to_char == 'E' }
  }
end