ruby on rails - RoR Tutorial Hartl Chapter 9.3 -


i got stuck tutorial , have been pulling shape. (i'm 2 week newbie). when run

bundle exec rspec spec/requests/user_pages_spec.rb -e "edit page" 

i get

sis-macbook-pro:sample_app lagaspi$ bundle exec rspec spec/requests/user_pages_spec.rb -e "edit page" run options: include {:full_description=>/(?-mix:edit\ page)/} fff  failures:  1) user pages signup valid information edit page   failure/error: before { visit edit_user_path(user) }  actionview::template::error:    undefined method `model_name' nilclass:class  # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___432836341465923353_70096274496380'  # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'  2) user pages signup valid information edit page   failure/error: before { visit edit_user_path(user) }  actionview::template::error:    undefined method `model_name' nilclass:class  # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___432836341465923353_70096274496380'  # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'  3) user pages signup valid information edit page   failure/error: before { visit edit_user_path(user) }  actionview::template::error:    undefined method `model_name' nilclass:class  # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___432836341465923353_70096274496380'  # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'  finished in 0.29628 seconds 3 examples, 3 failures  failed examples:  rspec ./spec/requests/user_pages_spec.rb:99 # user pages signup valid information edit page  rspec ./spec/requests/user_pages_spec.rb:100 # user pages signup valid information edit page  rspec ./spec/requests/user_pages_spec.rb:101 # user pages signup valid information edit page  

here's /spec/requests/user_pages_spec.rb

require 'spec_helper'  describe "user pages"  subject { page }  describe "profile page" let(:user) { factorygirl.create(:user) } before { visit user_path(user) }  { should have_selector('h1', text: user.name) } { should have_selector('title', text: user.name) } end  describe "signup page" before { visit signup_path }  { should have_selector('h1', text: 'sign up') } { should have_selector('title', text: full_title('sign up')) } end  describe "signup"  before { visit signup_path }  describe "with invalid information"   "should not create user"     expect { click_button "create account" }.not_to change(user, :count)   end    describe "error messages"     before { click_button "create account" }      { should have_selector('title', text: 'sign up') }     { should have_content('error') }   end end    describe "with valid information"   before     fill_in "name", with: "example user"     fill_in "email", with: "user@example.com"     fill_in "password", with: "foobar"     fill_in "confirmation", with: "foobar"   end    "should create user"     expect       click_button "create account"     end.to change(user, :count).by(1)   end    describe "after saving user"     before { click_button "create account" }     let(:user) { user.find_by_email('user@example.com') }      { should have_selector('title', text: user.name) }     { should have_selector('div.alert.alert-success', text: 'welcome') }     { should have_link('sign out') }    end  end end  describe "signup page" before { visit signup_path }  { should have_selector('h1', text: 'sign up') } { should have_selector('title', text: full_title('sign up')) } end      describe "signup"  before { visit signup_path }  let(:submit) { "create account" }  describe "with invalid information"   "should not create user"     expect { click_button submit }.not_to change(user, :count)   end end  describe "with valid information"   before     fill_in "name", with: "example user"     fill_in "email", with: "user@example.com"     fill_in "password", with: "foobar"     fill_in "confirmation", with: "foobar"   end    "should create user"     expect { click_button submit }.to change(user, :count).by(1)   end   describe "edit"     let(:user) { factorygirl.create(:user) }     before { visit edit_user_path(user) }      describe "page"       { should have_selector('h1', text: "update profile") }       { should have_selector('title', text: "edit user") }       { should have_link('change', href: 'http://gravatar.com/emails') }     end      describe "with invalid information"       before { click_button "save changes" }        { should have_content('error') }       end     end    end  end end 

any ideas?

users_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 sample app!"   redirect_to @user else   render 'new'    end  end end 

your problem seems don't have edit action. add this

def edit     @user = user.find(params[:id]) end 

to users controller.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -