require_relative File.join 'expectation_set' require 'spectus' module Fix class Expectation include Spectus::DSL def initialize positive, definition, *args @positive = positive @matcher, @expected = definition.to_a.flatten 1 @args = args freeze ExpectationSet.instance.add self end private def pass? result, _subject = nil result.equal? true end def exception result result unless [ true, false ].include? result end def negated? !@positive end def presenter result, got, subject = nil { pass: pass?(result, subject), negated: negated?, matcher: @matcher, expected: @expected, exception: exception(result), got: got } end def meta subject { level: level, params: subject.params, challenge: subject.challenge, subject_exception: subject.error } end def target negated? ? :not_to : :to end end end