lib/bcdd/result/context/expectations.rb in bcdd-result-0.7.0 vs lib/bcdd/result/context/expectations.rb in bcdd-result-0.8.0

- old
+ new

@@ -1,41 +1,25 @@ # frozen_string_literal: true class BCDD::Result::Context - class Expectations + class Expectations < BCDD::Result::Expectations require_relative 'expectations/mixin' - def self.mixin(success: nil, failure: nil, with: nil) - addons = Mixin::Addons.options(with) - - mod = ::BCDD::Result::Expectations::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 + def self.mixin_module + Mixin end - def initialize(subject: nil, success: nil, failure: nil, contract: nil) - @subject = subject - - @contract = contract if contract.is_a?(::BCDD::Result::Contract::Evaluator) - - @contract ||= ::BCDD::Result::Contract.new(success: success, failure: failure).freeze + def self.result_factory_without_expectations + ::BCDD::Result::Context end + private_class_method :mixin!, :mixin_module, :result_factory_without_expectations + def Success(type, **value) Success.new(type: type, value: value, subject: subject, expectations: contract) end def Failure(type, **value) 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