Friends I'm in Michael Hartl Ruby Tutorial 9.1.3(Successful edits). After completing instruction when i run
bundle exec rspec spec /
following error occurs..
1) User pages edit with valid information
Failure/Error: it { should have_link('Sign out', href: signout_path) }
expected #has_link?("Sign out", {:href=>"/signout"}) to return true, got false
# ./spec/requests/user_pages_spec.rb:82:in `block (4 levels) in <top (required)>'
Finished in 2.71 seconds 63 examples, 1 failure, 3 pending
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:82 # User pages edit with valid information
I'm unable to find error I also upload my code where it says error occured. User_pages_spec.rb
User_pages_spec.rb (complete)
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "[email protected]"
fill_in "Password", with: "foobar"
fill_in "Confirmation", with: "foobar"
end
describe "after saving the user" do
before { click_button submit }
let(:user) { User.find_by(email: '[email protected]') }
it { should have_link("Sign out") }
it { should have_title(user.name) }
it { should have_selector('div.alert.alert-success', text: 'Welcome') }
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
end
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
end
describe "edit" do
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
before { visit edit_user_path(user) }
describe "with valid information" do
let(:new_name) { "New Name" }
let(:new_email) { "[email protected]" }
before do
fill_in "Name", with: new_name
fill_in "Email", with: new_email
fill_in "Password", with: user.password
fill_in "Confirm Password", with: user.password
click_button "Save changes"
end
it { should have_title(new_name) }
it { should have_selector('div.alert.alert-success') }
it { should have_link('Sign out', href: signout_path) }
specify { expect(user.reload.name).to eq new_name }
specify { expect(user.reload.email).to eq new_email }
end
describe "page" do
it { should have_content("Update your profile") }
it { should have_title("Edit user") }
it { should have_link('change', href: 'http://gravatar.com/emails') }
end
describe "with invalid information" do
before { click_button "Save changes" }
it { should have_content('error') }
end
end
end
end