I am starting to test my app and I am stuck on the user register form...
h2 Sign up
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :first_name, required: true, autofocus: true
= f.input :last_name, required: true
= f.input :nickname, required: true
= f.input :email, required: true
= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length)
= f.input :password_confirmation, required: true
.form-actions
=f.button :submit , class:'btn btn-primary'
I am following an exemple like this one:
describe "Signing up " do
it "allows a user to sign up for the site and create object in the database" do
expect(User.count).to eq(0)
visit "/en/users/sign_up"
expect(page).to have_content("Sign up")
fill_in "First Name", with: "John"
fill_in "Last Name", with: "Doe"
fill_in "Nickname", with: "JD"
fill_in "Email", with: "john@email.com"
fill_in "Password", with: "password"
fill_in "Password (again)", with: "password"
click_button "Create User"
expect(User.count).to eq(1)
#
end
end
I dont know how to test the simple form labels?I tried with adding an id to:
= f.input :first_name, required: true, autofocus: true, id: "first_name"
and the in the spec:
fill_in "first_name", with: "John"
It doesn't make the job... What should I do ?
Found a hint here
fill_in "user_first_name", with: "John"
works :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.