-
-
Save benschac/5682020 to your computer and use it in GitHub Desktop.
Failures: | |
1) Authentication with valid information | |
Failure/Error: fill_in "Email", with: user.email.upcase | |
Capybara::ElementNotFound: | |
Unable to find field "Email" | |
# ./spec/requests/authentication_pages_spec.rb:33:in `block (3 levels) in <top (required)>' | |
2) Authentication with valid information | |
Failure/Error: fill_in "Email", with: user.email.upcase | |
Capybara::ElementNotFound: | |
Unable to find field "Email" | |
# ./spec/requests/authentication_pages_spec.rb:33:in `block (3 levels) in <top (required)>' | |
3) Authentication with valid information | |
Failure/Error: fill_in "Email", with: user.email.upcase | |
Capybara::ElementNotFound: | |
Unable to find field "Email" | |
# ./spec/requests/authentication_pages_spec.rb:33:in `block (3 levels) in <top (required)>' | |
4) Authentication with valid information | |
Failure/Error: fill_in "Email", with: user.email.upcase | |
Capybara::ElementNotFound: | |
Unable to find field "Email" | |
# ./spec/requests/authentication_pages_spec.rb:33:in `block (3 levels) in <top (required)>' | |
Finished in 0.57909 seconds | |
44 examples, 4 failures | |
Failed examples: | |
rspec ./spec/requests/authentication_pages_spec.rb:40 # Authentication with valid information | |
rspec ./spec/requests/authentication_pages_spec.rb:38 # Authentication with valid information | |
rspec ./spec/requests/authentication_pages_spec.rb:39 # Authentication with valid information | |
rspec ./spec/requests/authentication_pages_spec.rb:41 # Authentication with valid information | |
Randomized with seed 43243 | |
Here is my rspec code: | |
require 'spec_helper' | |
describe "Authentication" do | |
subject { page } | |
describe "sign page" do | |
before { visit signin_path } | |
it { should have_content('Sign in') } | |
it { should have_title('Sign in') } | |
end | |
describe "signin" do | |
before { visit signin_path } | |
describe "with invalid information" do | |
before { click_button "Sign in" } | |
it { should have_title('Sign in') } | |
it { should have_selector('div.alert.alert-error', text: 'Invalid') } | |
end | |
describe "after visiting another page" do | |
before { click_link "Home" } | |
it { should_not have_selector('div.alert.alert-error') } | |
end | |
end | |
describe "with valid information" do | |
let(:user) { FactoryGirl.create(:user) } | |
before do | |
fill_in "Email", with: user.email.upcase | |
fill_in "Password", with: user.password | |
click_button "Sign in" | |
end | |
it { should have _title(user.name) } | |
it { should have_link('Profile', href: user_path(user)) } | |
it { should have_link('Sign out', href: signout_path) } | |
it { should_not have_link('Sign in', href: signin_path) } | |
end | |
end | |
The Authentication page code: | |
<% provide(:title, "Sign in") %> | |
<h1>Sign in</h1> | |
<div class="row"> | |
<div class="span6 offset3"> | |
<%= form_for(:session, url: sessions_path) do |f| %> | |
<%= f.label :email %> | |
<%= f.text_field :email %> | |
<%= f.label :password %> | |
<%= f.password_field :password %> | |
<%= f.submit "Sign in", class: "btn btn-large btn-primary" %> | |
<% end %> | |
<p>New user? <%= link_to "Sign up now!", signup_path %></p> | |
</div> | |
</div> | |
Do you kno what's going on? |
Hey, I'm still getting the same error. I'll push the most current version I have.
I'm having the EXACT same issue and it's driving me nuts :) The full error I get is:
- Authentication with valid information
Failure/Error: fill_in "Email", with: user.email.upcase
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Email' found(eval):2:in `fill_in'
./spec/requests/authentication_pages_spec.rb:34:in`block (3 levels) in <top (required)>'
Hey @benschac, I forked your repo and just pull requested a fix. The short answer to your problem is that you were missing a visit signin_path
before line 79 in your gist. Capybara wasn't visiting the signin page and therefore could not find the fields to fill in.
Check out the commit for the fix here: https://github.com/donokuda/railsapp4/commit/cda4e2d7ec6238d85b9a30a0406a70e2f2458fbf
There is also a typo on line 84:
it { should have _title(user.name) }
should be it { should have_title(user.name) }
(you had a space between "have" and "_title"
Let me know if this worked out and if you ran into any more problems.
Hey Ben,
On line 105 try change
<%= f.label :email %>
to<%= f.label :email, 'Email' %>
and on line 106 change<%= f.label :password %>
to<%= f.label :password, 'Password' %>
Let me know if that helped or gave you a different error message.