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) {|actual| ... } ⇒ 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 (Hash)
  • negate (Boolean)

Yield Parameters:

  • actual

    the value which is compared with the expected value.



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

def initialize(definition, negate, &actual)
  @got = negate ^ Matcher.pass?(definition, &actual)
rescue => e
  @exception = e
end

Instance Attribute Details

#exceptionObject (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.



9
10
11
# File 'lib/spectus/sandbox.rb', line 9

def exception
  @exception
end

#gotObject (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.



9
10
11
# File 'lib/spectus/sandbox.rb', line 9

def got
  @got
end

Instance Method Details

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

Return the result.

Returns:

  • (Boolean)

    Report if the test was true or false.



25
26
27
28
29
30
31
# File 'lib/spectus/sandbox.rb', line 25

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