class Fix::It

Wraps the target of an expectation.

@api private

Public Class Methods

new(subject, challenges, helpers) click to toggle source

Create a new expection target

@param subject [BasicObject] The front object. @param challenges [Array] The list of challenges. @param helpers [Hash] The list of helpers.

# 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

Public Instance Methods

verify(&spec) click to toggle source

Verify the expectation.

@param spec [Proc] A spec to compare against the computed actual value.

@return [::Spectus::Result::Pass, ::Spectus::Result::Fail] Pass or fail.

# File lib/fix/it.rb, line 35
def verify(&spec)
  instance_eval(&spec)
rescue ::Spectus::Result::Fail => e
  e
end