Russell Beckwith

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Rails 7.1 Authentication From Scratch - Test Helpers

In Rails 7.1 without Devise, you can stub current_user in your request specs by defining helper methods or using Warden test helpers if you’re using Warden. Another common way is to directly set the session or use allow_any_instance_of to mock current_user in controller tests. For request specs, consider creating a helper that logs in a test user by posting to the login path or setting the session manually.

Thank you for the instruction

Posted in Test some simple javascript with Minitest and Capybara

To test JavaScript that runs after a POST request using Minitest and Capybara, you need to use Capybara's system tests or feature tests with a JavaScript-enabled driver like Selenium. IntegrationTest alone won’t execute JS. Try writing a Capybara::DSL test with js: true option and use visit or click_button to trigger actions. This way, Capybara can wait for JS changes and let you interact with the updated page.