Sorbet can help with type inference in tests if the setup is right. Otherwise types will be reduced to T.untyped
.
class Test < ActiveSupport::TestCase
def setup # Don't use `dev setup`.
@user = make_fixture(User, :alex) # Don't forget `T.let`
end
end
class Test < ActiveSupport::TestCase
setup do
@user = T.let(make_fixture(User, :alex), User)
end
end
With this latter @user
will be infered as type User
, and it does not need to be nilable.