diff --git a/lib/rspec/sorbet/doubles.rb b/lib/rspec/sorbet/doubles.rb index 18c81c3..b2ff838 100644 --- a/lib/rspec/sorbet/doubles.rb +++ b/lib/rspec/sorbet/doubles.rb @@ -23,7 +23,7 @@ def allow_doubles! private INLINE_DOUBLE_REGEX = - /T.(?:let|cast): Expected type (?:T.(?any|nilable|class_of)\()?(?[a-zA-Z0-9:: ,]*)(\))?, got (?:type .* with value )?#<(?Instance|Class|Object)?Double([\(]|[ ])(?[a-zA-Z0-9:: ,]*)(\))?/.freeze + /T.(?:let|cast): Expected type (?:T.(?any|nilable|class_of)\()*(?[a-zA-Z0-9:: ,]*)(\))*, got (?:type .* with value )?#<(?Instance|Class|Object)?Double([\(]|[ ])(?[a-zA-Z0-9:: ,]*)(\))?/.freeze def handle_call_validation_error(signature, opts) diff --git a/spec/lib/rspec/sorbet_spec.rb b/spec/lib/rspec/sorbet_spec.rb index 53c323a..a32aeb2 100644 --- a/spec/lib/rspec/sorbet_spec.rb +++ b/spec/lib/rspec/sorbet_spec.rb @@ -171,11 +171,15 @@ def rectangular_class?(klass); end expect { T.let(class_double(Rectangle), Rectangle) }.to raise_error(TypeError) expect { T.let(Rectangle, T.class_of(Rectangle)) }.not_to raise_error expect { T.let(class_double(Rectangle), T.class_of(Rectangle)) }.to raise_error(TypeError) + expect { T.let(Rectangle, T.nilable(T.class_of(Rectangle))) }.not_to raise_error + expect { T.let(class_double(Rectangle), T.nilable(T.class_of(Rectangle))) }.to raise_error(TypeError) subject expect { T.let(Rectangle, Rectangle) }.to raise_error(TypeError) expect { T.let(class_double(Rectangle), Rectangle) }.to raise_error(TypeError) expect { T.let(Rectangle, T.class_of(Rectangle)) }.not_to raise_error expect { T.let(class_double(Rectangle), T.class_of(Rectangle)) }.not_to raise_error + expect { T.let(Rectangle, T.nilable(T.class_of(Rectangle))) }.not_to raise_error + expect { T.let(class_double(Rectangle), T.nilable(T.class_of(Rectangle))) }.not_to raise_error end specify 'method signatures' do