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, &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)


14
15
16
17
18
# File 'lib/spectus/sandbox.rb', line 14

def initialize(definition, &actual)
  @got = ::Expect.this(&actual).to(definition)
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?(negate) ⇒ 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 as a positive or a negative assertion.

Parameters:

  • negate (Boolean)

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?(negate)
  if defined?(@exception)
    false
  else
    negate ^ @got
  end
end