Class: Fix::Set Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fix/set.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.

Collection of specifications.

Constant Summary collapse

LOG_LEVELS =

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

The type of result.

Passed expectations can be classified as:

* `success`
* `warning`
* `info`

Failed expectations can be classified as:

* `failure`
* `error`
%w[
  none
  error
  failure
  warning
  info
  success
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*contexts) ⇒ Set

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 a new instance of Set.

Parameters:

  • contexts (Array<::Fix::Dsl>)

    The list of contexts document.



43
44
45
46
# File 'lib/fix/set.rb', line 43

def initialize(*contexts)
  @specs  = Doc.specs(*contexts)
  @passed = true
end

Instance Attribute Details

#specsArray (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 A list of specifications.

Returns:

  • (Array)

    A list of specifications.



33
34
35
# File 'lib/fix/set.rb', line 33

def specs
  @specs
end

Class Method Details

.load(name) ⇒ Object

Parameters:

  • name (String, Symbol)

    The constant name of the specifications.



38
39
40
# File 'lib/fix/set.rb', line 38

def self.load(name)
  new(*Doc.fetch(name))
end

Instance Method Details

#test(log_level: 5, &subject) ⇒ Object

Parameters:

  • subject (Proc)

    The block of code to be tested.

Raises:

  • (::SystemExit)

    The test set failed!



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fix/set.rb', line 53

def test(log_level: 5, &subject)
  randomize!

  specs.each do |environment, location, requirement, challenges|
    runner = Run.new(environment, requirement, *challenges)
    result = runner.test(&subject)

    failed! if result.failed?
    report!(location, result, log_level: log_level)
  end

  passed? || ::Kernel.exit(false)
end