Search⌘ K
AI Features

The Third Test: Fill and Submit Form

Explore how to write feature tests for filling and submitting forms in Ruby on Rails. Understand the importance of test-first development as you identify and resolve issues such as missing form fields, controllers, and routes. This lesson helps you ensure your application behaves as expected by using tests to guide development and catch errors early.

Setting up the test

Our third step is "I fill in and submit the registration form".

Considering what the step needs to accomplish, the code below illustrates how a user might complete that step:

Ruby
When("I fill in and submit the registration form") do
fill_in "user-name", with: "jdoe"
fill_in "user-email", with: "jdoe@example.com"
fill_in "user-password", with: "secret1234"
fill_in "user-password-confirmation", with: "secret1234"
click_on "user-registration-submit"
end

Looking good. That’s what we imagine the user doing when they fill in the ...