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, *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 definition.



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

def initialize(definition, negate, object, *challenges)
  @got = negate ^ matcher(definition).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.



35
36
37
# File 'lib/spectus/sandbox.rb', line 35

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.



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

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.



46
47
48
# File 'lib/spectus/sandbox.rb', line 46

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.



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

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.



51
52
53
54
55
56
57
# File 'lib/spectus/sandbox.rb', line 51

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