Sha256: 028a8176dea09e3eb583d332bf21bdd05238159dd62591e6f4c844083b9fa83f
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true class BCDD::Result class Expectations require_relative 'expectations/mixin' def self.mixin(success: nil, failure: nil, with: nil) addons = Mixin::Addons.options(with) mod = Mixin.module! mod.const_set(:Result, new(success: success, failure: failure).freeze) mod.module_eval(Mixin::METHODS) mod.send(:include, *addons) unless addons.empty? mod end def initialize(subject: nil, success: nil, failure: nil, contract: nil) @subject = subject @contract = contract if contract.is_a?(Contract::Evaluator) @contract ||= Contract.new(success: success, failure: failure).freeze end def Success(type, value = nil) Success.new(type: type, value: value, subject: subject, expectations: contract) end def Failure(type, value = nil) Failure.new(type: type, value: value, subject: subject, expectations: contract) end def with(subject:) self.class.new(subject: subject, contract: contract) end private attr_reader :subject, :contract end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bcdd-result-0.7.0 | lib/bcdd/result/expectations.rb |