Allow stubs returning nil to be used on NoReturn calls

This commit is contained in:
Michael Miller 2021-07-10 20:19:10 -06:00
parent e47ae613a5
commit 384fb3093f
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -20,6 +20,8 @@ module Spectator::Mocks
value = call(args) { |*ya| yield *ya } value = call(args) { |*ya| yield *ya }
if value.is_a?(RT) if value.is_a?(RT)
value.as(RT) value.as(RT)
elsif value.nil? && RT == NoReturn
raise SystemExit.new
else else
raise TypeCastError.new("The return type of stub #{self} doesn't match the expected type #{RT}") raise TypeCastError.new("The return type of stub #{self} doesn't match the expected type #{RT}")
end end