From 174f76507482d1ca31db85e03722d362c793060c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 17 Oct 2021 16:29:43 +0200 Subject: [PATCH] Make component tests fail when using `within` This way we avoid writing useless tests which always pass. --- spec/rails_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 874273bad..6714ebdb4 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -18,6 +18,10 @@ module ViewComponent def sign_in(user) allow(controller).to receive(:current_user).and_return(user) end + + def within(...) + raise "`within` doesn't work in component tests. Use `page.find` instead." + end end end