ruby on rails - Spec not logging in to edit profile -


i using rspec , capybara write tests editing devise user profile:

require 'rails_helper'  feature "edit profile"   scenario "visiting site edit profile"     given_i_am_logged_in     and_i_visit_edit_registration_page     when_i_edit_profile     i_should_be_redirected_to_home_page   end end  def given_i_am_logged_in   @user ||= factorygirl.create :user   login_as @user end  def and_i_visit_edit_registration_page   visit edit_user_registration_url end  def when_i_edit_profile   fill_in_fields end  def fill_in_fields   fill_in "user[name]", with: @user.name   fill_in "user[hospital]", with: @user.hospital   fill_in "user[email]", with: @user.email   fill_in "user[current_password]", with: @user.password   click_button "update" end  def i_should_be_redirected_to_home_page   expect(page).to have_content("home page")   expect(page).to have_link("sign out") end 

the error is

failures:    1) edit profile visiting site edit profile      failure/error: fill_in "user[name]", with: @user.name      capybara::elementnotfound:        unable find field "user[name]" 

but happens because user not accessing edit_user_registration_path. being redirected login page. how set routes file:

  devise_for :admin_users, activeadmin::devise.config   activeadmin.routes(self)   devise_for :users, controllers: { registrations: "users/registrations", sessions: "users/sessions" }    root to: 'home#index' 

can see happening?

thanks!

can give more information? sure problem user being redirected? , if so, sure user being logged in correctly? if need to, try using pry figure out step failing. if user getting edit page, can use inspect element make sure "user[name]" correct input, think that's right.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -