ruby on rails - converting to devise - capybara::ElementNotFound: -
i in process of converting user authentication scratch devise gem. completed , appears working fine. changed rspec tests over, have 1 recurring problem have searched find solution to.
the error
2) authenticationpages authorization non-signed-in users when attempting visit protected page after signing in should render desired protected page failure/error: fill_in :email, with: user.email capybara::elementnotfound: cannot fill in, no text field, text area or password field id, name, or label 'email' found # (eval):2:in `fill_in' # ./spec/requests/authentication_pages_spec.rb:53:in `block (5 levels) in <top (required)>'
the test
describe "for non-signed-in users" let(:user) { factorygirl.create(:user)} describe "when attempting visit protected page" before visit edit_user_registration_path(user) fill_in "email", with: user.email fill_in "password", with: user.password click_button "sign in" end describe "after signing in" "should render desired protected page" page.should have_selector('title', text: 'edit user') end end end
the devise form (new_user_session - appears before being allowed see edit user info)
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) |f| %> <%= f.label :email %> <%= f.email_field :email, :autofocus => true %> <%= f.label :password %> <%= f.password_field :password %> <% if devise_mapping.rememberable? -%> <%= f.check_box :remember_me %> <%= f.label :remember_me %> <% end -%> <%= f.submit "sign in", class: "btn btn-large btn-primary" %> <% end %> <%= render "devise/shared/links" %>
the behavior works when testing in browser, rspec test fails.
capybara cannot find input email; form seems built, capybara being redirected page before reaching form.
are sure path follow form edit_user_registration_path(user)
, not instance new_user_registration_path
or (even better if testing sign_in , not sign_up) new_user_session_path
?
Comments
Post a Comment