I followed all the instructions in chapter 7 Ruby on Rails tutorial, when I finally run $ Bundle exec rspec spec/ a series of errors are being displayed. I doubled checked if my codes had any spelling mistakes or any symbols left out. Everything seems to fine. Could you please kindly interpret the errors and tell me where I am going wrong??? Thanks
USER_PAGES_SPEC.RB
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before {visit signup_path}
it { should have_selector('h1', text: 'Sign ') }
it { should have_selector('title', text: full_title('Sign up')) }
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_selector('h1', text: user.name) }
it { should have_selector('title', text: user.name) }
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
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
describe "after saving a user" do
before {click_button submit}
let (:user) {user.find_by_email("[email protected]")}
it {should have_selector('title', text:user.name)}
end
end
end
end
USER_CONTROLLER.RB
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
end
ERRORS DISPLAYED ON COMMAND LINE
3) User pages signup page
←[31mFailure/Error:←[0m ←[31mit { should have_selector('title', text: full_
title('Sign up')) }←[0m
←[31mNoMethodError:←[0m
←[31mundefined method full_title' for #<RSpec::Core::ExampleGroup::Neste
d_2::Nested_1:0x461b260>←[0m
←[36m # ./spec/requests/user_pages_spec.rb:11:in
block (3 levels) in '←[0m
4) User pages profile page ←[31mFailure/Error:←[0m ←[31mit { should have_selector('title', text: user. name) }←[0m ←[31mexpected css "title" with text "Michael Hartl" to return something←[ 0m ←[36m # ./spec/requests/user_pages_spec.rb:19:in `block (3 levels) in '←[0m
5) User pages signup with valid information should create a user
←[31mFailure/Error:←[0m ←[31mexpect { click_button submit }.to change(User,
:count).by(1)←[0m
←[31mNoMethodError:←[0m
←[31mundefined method sign_in' for #<UsersController:0x45a8f00>←[0m
←[36m # ./app/controllers/users_controller.rb:14:in
create'←[0m
←[36m # (eval):2:in click_button'←[0m
←[36m # ./spec/requests/user_pages_spec.rb:43:in
block (5 levels) in '←[0m
←[36m # ./spec/requests/user_pages_spec.rb:43:in `block (4 levels) in '←[0m
6) User pages signup with valid information after saving a user
←[31mFailure/Error:←[0m ←[31mbefore {click_button submit}←[0m
←[31mNoMethodError:←[0m
←[31mundefined method sign_in' for #<UsersController:0x46341c0>←[0m
←[36m # ./app/controllers/users_controller.rb:14:in
create'←[0m
←[36m # (eval):2:in click_button'←[0m
←[36m # ./spec/requests/user_pages_spec.rb:47:in
block (5 levels) in '←[0m
models/user.rb
? – mu is too short