lib/rspec/sorbet/doubles.rb in rspec-sorbet-1.7.0 vs lib/rspec/sorbet/doubles.rb in rspec-sorbet-1.8.0

- old
+ new

@@ -34,10 +34,11 @@ t_method = match[:t_method] expected_types = match[:expected_types].split(',').map do |expected_type| Object.const_get(expected_type.strip) end double_type = match[:double_type] + return if double_type.nil? doubled_type = Object.const_get(match[:doubled_type]) if double_type == 'Class' raise error if t_method != 'class_of' @@ -94,11 +95,13 @@ 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.map(&:raw_type).any? do |type| - target.ancestors.include?(type) + 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