I'm trying to use capybara to simulate a login to test my login form, however it cannot find the email or password fields.
I have checked the page source to confirm that I am using the right ID, and I have also tried using the field names.
Here is my current test:
it "returns http success" do
user = FactoryGirl.create(:user)
visit sessions_new_path
fill_in 'email', :with => user.email
fill_in 'password', :with => user.password
click_button('submit')
expect(response).to have_http_status(:success)
end
My form:
= form_for(:session, url: login_path, :html => {class: 'login_form'}) do |f|
.field
= f.email_field :email, 'data-msg-required' => t('email_required'), :placeholder => t('.form_email'), id: 'email'
.field
= f.password_field :password, 'data-msg-required' => t('password_required'), :placeholder => t('.form_pwd'), id: 'password'
= f.submit t('.form_sbmt'), class: 'btn-submit'
When viewing the page source the IDs are listed as email and password (for the respective fields), and the names follow the format "session[email]". I've tried using "sessions[email]" (and equiv for password) for fill_in but had no luck.
Error I'm getting:
Failure/Error: fill_in 'email', :with => user.email
Capybara::ElementNotFound:
Unable to find field "email"
Any help would be appreciated.