Class: Fix::It Private

Inherits:
Spectus::ExpectationTarget
  • Object
show all
Includes:
Spectus::Matchers
Defined in:
lib/fix/it.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.

Wraps the target of an expectation.

Instance Method Summary collapse

Constructor Details

#initialize(subject, challenges, helpers) ⇒ It

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.

Create a new expection target

Parameters:

  • subject (BasicObject)

    The front object.

  • challenges (Array)

    The list of challenges.

  • helpers (Hash)

    The list of helpers.



19
20
21
22
23
24
25
26
27
28
# File 'lib/fix/it.rb', line 19

def initialize(subject, challenges, helpers)
  @subject    = subject
  @challenges = challenges

  helpers.each do |method_name, method_block|
    define_singleton_method(method_name) do
      method_block.call
    end
  end
end

Instance Method Details

#verify(&spec) ⇒ ::Spectus::Result::Pass, ::Spectus::Result::Fail

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.

Verify the expectation.

Parameters:

  • spec (Proc)

    A spec to compare against the computed actual value.

Returns:

  • (::Spectus::Result::Pass, ::Spectus::Result::Fail)

    Pass or fail.



35
36
37
38
39
# File 'lib/fix/it.rb', line 35

def verify(&spec)
  instance_eval(&spec)
rescue ::Spectus::Result::Fail => e
  e
end