railstutorial.org - Errors encountered in 10.3.3 of Michael Hartl's Rails Tutorial -


i ran following errors when running rspec tests:

failures:

1) authentication authorization wrong user visiting users#edit page   failure/error: before { visit edit_user_path(wrong_user) }  actionview::template::error:    undefined local variable or method `feed_item' #<#<class:0x007f89628593f8>:0x007f895fcdcd38>  # ./app/views/shared/_feed.html.erb:1:in `_app_views_shared__feed_html_erb___2268788413810348528_70113969385200'  # ./app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__501962788019734978_70114020097480'  # ./spec/requests/authentication_pages_spec.rb:108:in `block (5 levels) in <top (required)>'  2) micropost pages micropost creation invalid information should not create micropost  failure/error: before { visit root_path }  actionview::template::error:    undefined local variable or method `feed_item' #<#<class:0x007f89628593f8>:0x007f895ff8c3a8>  # ./app/views/shared/_feed.html.erb:1:in `_app_views_shared__feed_html_erb___2268788413810348528_70113969385200'  # ./app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__501962788019734978_70114020097480'  # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'  3) micropost pages micropost creation invalid information error messages   failure/error: before { visit root_path }  actionview::template::error:    undefined local variable or method `feed_item' #<#<class:0x007f89628593f8>:0x007f8962b99798>  # ./app/views/shared/_feed.html.erb:1:in `_app_views_shared__feed_html_erb___2268788413810348528_70113969385200'  # ./app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__501962788019734978_70114020097480'  # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'   4) micropost pages micropost creation valid information should create micropost  failure/error: before { visit root_path }  actionview::template::error:    undefined local variable or method `feed_item' #<#<class:0x007f89628593f8>:0x007f895de6c3a8>  # ./app/views/shared/_feed.html.erb:1:in `_app_views_shared__feed_html_erb___2268788413810348528_70113969385200'  # ./app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__501962788019734978_70114020097480'  # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'  5) static pages signed-in users should render user's feed  failure/error: visit root_path  actionview::template::error:    undefined local variable or method `feed_item' #<#<class:0x007f89628593f8>:0x007f895dd16f80>  # ./app/views/shared/_feed.html.erb:1:in `_app_views_shared__feed_html_erb___2268788413810348528_70113969385200'  # ./app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__501962788019734978_70114020097480'  # ./spec/requests/static_pages_spec 

code:

the code authentication_pages_spec.rb

    require 'spec_helper'  describe "authentication"    subject { page }    describe "signin page"     before { visit signin_path }      { should have_selector('h1',    text: 'sign in') }     { should have_selector('title', text: 'sign in') }   end    describe "signin"     before { visit signin_path }      describe "with invalid information"       before { click_button "sign in" }        { should have_selector('title', text: 'sign in') }       { should have_selector('div.alert.alert-error', text: 'invalid') }        describe "after visiting page"         before { click_link "home" }         { should_not have_selector('div.alert.alert-error') }       end     end      describe "with valid information"       let(:user) { factorygirl.create(:user) }       before { sign_in user }        { should have_selector('title', text: user.name) }       { should have_link('profile',  href: user_path(user)) }       { should have_link('sign out', href: signout_path) }       { should have_link('settings', href: edit_user_path(user)) }       { should have_link('users',    href: users_path) }       { should_not have_link('sign in', href: signin_path) }        describe "followed signout"         before { click_link "sign out" }         { should have_link('sign in') }       end     end   end    describe "authorization"      describe "for non-signed-in users"       let(:user) { factorygirl.create(:user) }          describe "when attempting visit protected page"         before           visit edit_user_path(user)           fill_in "email",    with: user.email           fill_in "password", with: user.password           click_button "sign in"         end          describe "after signing in"            "should render desired protected page"             page.should have_selector('title', text: 'edit user')           end         end       end        describe "in users controller"          describe "visiting edit page"           before { visit edit_user_path(user) }           { should have_selector('title', text: 'sign in') }         end          describe "submitting update action"           before { put user_path(user) }           specify { response.should redirect_to(signin_path) }         end          describe "visiting user index"           before { visit users_path }           { should have_selector('title', text: 'sign in') }         end       end     end      describe "in microposts controller"        describe "submitting create action"         before { post microposts_path }         specify { response.should redirect_to(signin_path) }       end        describe "submitting destroy action"         before { delete micropost_path(factorygirl.create(:micropost)) }         specify { response.should redirect_to(signin_path) }       end     end      describe "as wrong user"       let(:user) { factorygirl.create(:user) }       let(:wrong_user) { factorygirl.create(:user, email: "wrong@example.com") }       before { sign_in user }        describe "visiting users#edit page"         before { visit edit_user_path(wrong_user) }         { should_not have_selector('title', text: full_title('edit user')) }       end        describe "submitting put request users#update action"         before { put user_path(wrong_user) }         specify { response.should redirect_to(root_path) }       end     end      describe "as non-admin user"       let(:user) { factorygirl.create(:user) }       let(:non_admin) { factorygirl.create(:user) }        before { sign_in non_admin }        describe "submitting delete request users#destroy action"         before { delete user_path(user) }         specify { response.should redirect_to(root_path) }       end     end   end end 

the code _feed.html.erb**

    <li id="<%= feed_item.id %>">   <%= link_to gravatar_for(feed_item.user), feed_item.user %>   <span class="user">     <%= link_to feed_item.user.name, feed_item.user %>   </span>   <span class="content"><%= feed_item.content %></span>   <span class="timestamp">     posted <%= time_ago_in_words(feed_item.created_at) %> ago.   </span> </li> 

the code _feed_item.html.erb

    <li id="<%= feed_item.id %>">   <%= link_to gravatar_for(feed_item.user), feed_item.user %>     <span class="user">       <%= link_to feed_item.user.name, feed_item.user %>     </span>     <span class="content"><%= feed_item.content %></span>     <span class="timestamp">       posted <%= time_ago_in_words(feed_item.created_at) %> ago.     </span>   <% if current_user?(feed_item.user) %>     <%= link_to "delete", feed_item, method: :delete,                                      data: { confirm: "you sure?" },                                      title: feed_item.content %>   <% end %> </li> 

please let me know if there additional files should include. thanks!

you have issues _feed.html.erb , _feed_item.html.erb files: @ moment, you're referencing feed_item without having defined anywhere.

refer equivalent files in rails tutorial: _feed.html.erb, _feed_item.html.erb.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -