module RSpec::Sorbet::Doubles
def call_validation_error_handler(signature, opts)
def call_validation_error_handler(signature, opts) should_raise = true message = opts.fetch(:pretty_message, opts.fetch(:message, "")) if message.match?(VERIFYING_DOUBLE_OR_DOUBLE) typing = opts[:type] value = opts[:value].is_a?(Array) ? opts[:value].first : opts[:value] target = value.instance_variable_get(:@doubled_module)&.target return if target.nil? case typing when T::Types::TypedArray, T::Types::TypedEnumerable typing = typing.type end case typing when T::Types::ClassOf should_raise = !(target <= typing.type) when T::Types::Simple should_raise = !target.ancestors.include?(typing.raw_type) when T::Types::Union valid = typing.types.any? do |type| next false unless type.respond_to?(:raw_type) target.ancestors.include?(type.raw_type) end should_raise = !valid else should_raise = !target.ancestors.include?(typing) end end handle_call_validation_error(signature, opts) if should_raise end