diff --git a/R/fit.R b/R/fit.R index 249adc0d1..21dc461b7 100644 --- a/R/fit.R +++ b/R/fit.R @@ -438,6 +438,9 @@ check_xy_interface <- function(x, y, cl, model) { if (df_interface) { return("data.frame") } + + check_outcome(y, model) + rlang::abort("Error when checking the interface") } diff --git a/tests/testthat/_snaps/misc.md b/tests/testthat/_snaps/misc.md index fd4ededa4..cb16c16e5 100644 --- a/tests/testthat/_snaps/misc.md +++ b/tests/testthat/_snaps/misc.md @@ -167,6 +167,15 @@ ! `linear_reg()` was unable to find an outcome. i Ensure that you have specified an outcome column and that it hasn't been removed in pre-processing. +--- + + Code + fit_xy(reg_spec, data.frame(x = 1:5), y = NULL) + Condition + Error: + ! `linear_reg()` was unable to find an outcome. + i Ensure that you have specified an outcome column and that it hasn't been removed in pre-processing. + --- Code diff --git a/tests/testthat/test_misc.R b/tests/testthat/test_misc.R index 88c4325ba..643f60e05 100644 --- a/tests/testthat/test_misc.R +++ b/tests/testthat/test_misc.R @@ -220,6 +220,11 @@ test_that('check_outcome works as expected', { fit(reg_spec, ~ mpg, mtcars) ) + expect_snapshot( + error = TRUE, + fit_xy(reg_spec, data.frame(x = 1:5), y = NULL) + ) + class_spec <- logistic_reg() expect_no_error(