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(definition, negate, object, meth, *args) ⇒ 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 definition.

Parameters:

  • definition (Array, Hash, Symbol)
  • negate (Boolean)
  • object (#object_id)

    the front object which is challenged.

  • meth (Symbol)

    the name of the method.

  • args (Array)

    the arguments of the method.



16
17
18
19
20
21
22
# File 'lib/spectus/sandbox.rb', line 16

def initialize(definition, negate, object, meth, *args)
  @got = negate ^ matcher(definition).matches? do
    @actual = object.public_send(meth, *args)
  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.



28
29
30
# File 'lib/spectus/sandbox.rb', line 28

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.



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

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.



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

def got
  @got
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.



44
45
46
47
48
49
50
# File 'lib/spectus/sandbox.rb', line 44

def valid?
  if defined?(@exception)
    false
  else
    @got
  end
end