Class: Spectus::Sandbox Private

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

This class evaluate the expectation with the passed block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher, negate, object, *challenges) ⇒ Sandbox

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.

Execute the untested code from the passed block against the matcher.

Parameters:

  • matcher (#matches?)

    The matcher.

  • negate (Boolean)

    The negation of the matcher’s result.

  • object (#object_id)

    The front object which is challenged.

  • challenges (Array)

    The list of challenges.



17
18
19
20
21
22
23
24
25
26
# File 'lib/spectus/sandbox.rb', line 17

def initialize(matcher, negate, object, *challenges)
  @got = negate ^ matcher.matches? do
    @actual = challenges.inject(object) do |subject, challenge|
      @last_challenge = challenge
      @last_challenge.to(subject)
    end
  end
rescue => e
  @exception = e
end

Instance Attribute Details

#actual#object_id (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 value that the subject return through its challenge.

Returns:

  • (#object_id)

    The value that the subject return through its challenge.



39
40
41
# File 'lib/spectus/sandbox.rb', line 39

def actual
  @actual
end

#exception#exception? (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 Any possible raised exception.

Returns:

  • (#exception, nil)

    Any possible raised exception.



44
45
46
# File 'lib/spectus/sandbox.rb', line 44

def exception
  @exception
end

#got#object_id (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 result of the boolean comparison between the actual value and the expected value.

Returns:

  • (#object_id)

    The result of the boolean comparison between the actual value and the expected value.



50
51
52
# File 'lib/spectus/sandbox.rb', line 50

def got
  @got
end

#last_challengeDefi::Challenge (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 last evaluated challenge.

Returns:

  • (Defi::Challenge)

    The last evaluated challenge.



33
34
35
# File 'lib/spectus/sandbox.rb', line 33

def last_challenge
  @last_challenge
end

Instance Method Details

#valid?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.

Report to the spec’s requirement level if the test is true or false.

Returns:

  • (Boolean)

    Report if the test was true or false.



55
56
57
58
59
# File 'lib/spectus/sandbox.rb', line 55

def valid?
  return false if defined?(@exception)

  got
end