I am doing the Michael Hartl Rails 3 Tutorial, Chapter 8.4 pages 316-320. I run the users_spec.rb test and both tests don’t pass with the following error:
Failures:
1) Users signup failure should not make a new user
Failure/Error: fill_in "Name", :with => ""
Webrat::NotFoundError:
Could not find field: "Name"
# ./spec/requests/users_spec.rb:12:in `block (5 levels) in <top (required)>'
# ./spec/requests/users_spec.rb:10:in `block (4 levels) in <top (required)>'
2) Users signup success should make a new user
Failure/Error: fill_in "Name", :with => "Example User"
Webrat::NotFoundError:
Could not find field: "Name"
# ./spec/requests/users_spec.rb:28:in `block (5 levels) in <top (required)>'
# ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'
Finished in 3.97 seconds
2 examples, 2 failures**
MY USERS_SPEC.RB FILE –
require 'spec_helper'
describe "Users" do
describe "signup" do
describe "failure" do
it "should not make a new user" do
lambda do
visit signup_path
fill_in "Name", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirmation", :with => ""
click_button
response.should render_template('users/new')
response.should have_selector("div#error_explanation")
end.should_not change(User, :count)
end
end
describe "success" do
it "should make a new user" do
lambda do
visit signup_path
fill_in "Name", :with => "Example User"
fill_in "Email", :with => "user@example.com"
fill_in "Password", :with => "foobar"
fill_in "Confirmation", :with => "foobar"
click_button
response.should have_selector("div.flash.success",:content => "Welcome")
response.should render_template('users/show')
end.should change(User, :count).by(1)
end
end
end
end
Can anyone help me?
Thank you!
OK i solved the problem. I am using the Rails 3 Tutorial to make my authentication system for my own Website so i changed the Sign Up Form at app/views/users/new up a little bit from the original of Michael Hartls:
Original =
My own Edit=
The parentheses (Name & Username) are important because it goes in spec/requests/users_spec.rb:
Original=
My Own Edit =
I got the test to pass completely, just remember whatever you put in the parentheses has to be the same as the view parentheses.