I want to test that a user can log in and that a visitor can sign up. The log in works well but for sign up it is not working for some reason. This is my feature spec:
require 'rails_helper'
RSpec.feature "Devise interactions", type: :feature do
let(:user) { FactoryBot.create(:non_admin_user) }
scenario "user logs in sucessfully" do
visit new_user_session_path
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Log in"
expect(page).to have_current_path "/"
end
scenario "user logs in unsuccesfully" do
visit new_user_session_path
fill_in "Password", with: user.password
click_button "Log in"
expect(page).to have_text('Invalid Email or password')
end
scenario "visitor signs up succesfully", js:true do
visit new_user_registration_path
fill_in "Username", with: "josem"
fill_in "Email", with: "abcd@test.com"
within ".user_password" do
fill_in 'Password', with: 'testing'
end
within ".user_password_confirmation" do
fill_in 'Password confirmation', with: 'testing'
end
#save_and_open_screenshot
click_button "Sign up"
#save_and_open_screenshot
expect(page).to have_text('Welcome! You have signed up successfully.')
end
scenario "visitor signs up unsuccesfully" do
visit new_user_registration_path
fill_in "Username", with: "josem"
fill_in "Email", with: "abcd"
within ".user_password" do
fill_in 'Password', with: 'password'
end
within ".user_password_confirmation" do
fill_in 'Password confirmation', with: 'password'
end
click_button "Sign up"
expect(page).to have_text('Email is invalid')
end
end
The third scenario:
scenario "visitor signs up succesfully", js:true do
visit new_user_registration_path
fill_in "Username", with: "josem"
fill_in "Email", with: "abcd@test.com"
within ".user_password" do
fill_in 'Password', with: 'testing'
end
within ".user_password_confirmation" do
fill_in 'Password confirmation', with: 'testing'
end
#save_and_open_screenshot
click_button "Sign up"
#save_and_open_screenshot
expect(page).to have_text('Welcome! You have signed up successfully.')
end
Is the one that is not working. Been trying to debug:
- Before the
Sign upbutton is clicked, everything is written correctly - After the
Sign upbutton is clicked, I only get an error ofPlease review the problems below:but it doesn´t say what type of error (there shouldn't be any error since the validations are all successful). - When I go to my Rails app and try to sign up manually, every time I have an error, it will point it out but it doesn't in the spec.
Since the log in is working, I doubt it is an error from the Devise config and I can´t find out why. Any ideas on why is it happening? Thanks!!