Note that there are some explanatory texts on larger screens.

plurals
  1. POErrors encountered in 10.3.3 of Michael Hartl's Rails Tutorial
    primarykey
    data
    text
    <p>I ran into the following errors when running my RSpec tests:</p> <p><strong>Failures:</strong></p> <pre><code>1) Authentication authorization as 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' for #&lt;#&lt;Class:0x007f89628593f8&gt;:0x007f895fcdcd38&gt; # ./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 &lt;top (required)&gt;' 2) Micropost pages micropost creation with invalid information should not create a micropost Failure/Error: before { visit root_path } ActionView::Template::Error: undefined local variable or method `feed_item' for #&lt;#&lt;Class:0x007f89628593f8&gt;:0x007f895ff8c3a8&gt; # ./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 &lt;top (required)&gt;' 3) Micropost pages micropost creation with invalid information error messages Failure/Error: before { visit root_path } ActionView::Template::Error: undefined local variable or method `feed_item' for #&lt;#&lt;Class:0x007f89628593f8&gt;:0x007f8962b99798&gt; # ./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 &lt;top (required)&gt;' 4) Micropost pages micropost creation with valid information should create a micropost Failure/Error: before { visit root_path } ActionView::Template::Error: undefined local variable or method `feed_item' for #&lt;#&lt;Class:0x007f89628593f8&gt;:0x007f895de6c3a8&gt; # ./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 &lt;top (required)&gt;' 5) Static pages for signed-in users should render the user's feed Failure/Error: visit root_path ActionView::Template::Error: undefined local variable or method `feed_item' for #&lt;#&lt;Class:0x007f89628593f8&gt;:0x007f895dd16f80&gt; # ./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></pre> <p><strong>Code:</strong></p> <p>The code for authentication_pages_spec.rb</p> <pre><code> require 'spec_helper' describe "Authentication" do subject { page } describe "signin page" do before { visit signin_path } it { should have_selector('h1', text: 'Sign in') } it { should have_selector('title', text: 'Sign in') } end describe "signin" do before { visit signin_path } describe "with invalid information" do before { click_button "Sign in" } it { should have_selector('title', text: 'Sign in') } it { should have_selector('div.alert.alert-error', text: 'Invalid') } describe "after visiting another page" do before { click_link "Home" } it { should_not have_selector('div.alert.alert-error') } end end describe "with valid information" do let(:user) { FactoryGirl.create(:user) } before { sign_in user } it { should have_selector('title', text: user.name) } it { should have_link('Profile', href: user_path(user)) } it { should have_link('Sign out', href: signout_path) } it { should have_link('Settings', href: edit_user_path(user)) } it { should have_link('Users', href: users_path) } it { should_not have_link('Sign in', href: signin_path) } describe "followed by signout" do before { click_link "Sign out" } it { should have_link('Sign in') } end end end describe "authorization" do describe "for non-signed-in users" do let(:user) { FactoryGirl.create(:user) } describe "when attempting to visit a protected page" do before do 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" do it "should render the desired protected page" do page.should have_selector('title', text: 'Edit user') end end end describe "in the Users controller" do describe "visiting the edit page" do before { visit edit_user_path(user) } it { should have_selector('title', text: 'Sign in') } end describe "submitting to the update action" do before { put user_path(user) } specify { response.should redirect_to(signin_path) } end describe "visiting the user index" do before { visit users_path } it { should have_selector('title', text: 'Sign in') } end end end describe "in the Microposts controller" do describe "submitting to the create action" do before { post microposts_path } specify { response.should redirect_to(signin_path) } end describe "submitting to the destroy action" do before { delete micropost_path(FactoryGirl.create(:micropost)) } specify { response.should redirect_to(signin_path) } end end describe "as wrong user" do let(:user) { FactoryGirl.create(:user) } let(:wrong_user) { FactoryGirl.create(:user, email: "wrong@example.com") } before { sign_in user } describe "visiting Users#edit page" do before { visit edit_user_path(wrong_user) } it { should_not have_selector('title', text: full_title('Edit user')) } end describe "submitting a PUT request to the Users#update action" do before { put user_path(wrong_user) } specify { response.should redirect_to(root_path) } end end describe "as non-admin user" do let(:user) { FactoryGirl.create(:user) } let(:non_admin) { FactoryGirl.create(:user) } before { sign_in non_admin } describe "submitting a DELETE request to the Users#destroy action" do before { delete user_path(user) } specify { response.should redirect_to(root_path) } end end end end </code></pre> <p>The code for _feed.html.erb**</p> <pre><code> &lt;li id="&lt;%= feed_item.id %&gt;"&gt; &lt;%= link_to gravatar_for(feed_item.user), feed_item.user %&gt; &lt;span class="user"&gt; &lt;%= link_to feed_item.user.name, feed_item.user %&gt; &lt;/span&gt; &lt;span class="content"&gt;&lt;%= feed_item.content %&gt;&lt;/span&gt; &lt;span class="timestamp"&gt; Posted &lt;%= time_ago_in_words(feed_item.created_at) %&gt; ago. &lt;/span&gt; &lt;/li&gt; </code></pre> <p>The code for _feed_item.html.erb</p> <pre><code> &lt;li id="&lt;%= feed_item.id %&gt;"&gt; &lt;%= link_to gravatar_for(feed_item.user), feed_item.user %&gt; &lt;span class="user"&gt; &lt;%= link_to feed_item.user.name, feed_item.user %&gt; &lt;/span&gt; &lt;span class="content"&gt;&lt;%= feed_item.content %&gt;&lt;/span&gt; &lt;span class="timestamp"&gt; Posted &lt;%= time_ago_in_words(feed_item.created_at) %&gt; ago. &lt;/span&gt; &lt;% if current_user?(feed_item.user) %&gt; &lt;%= link_to "delete", feed_item, method: :delete, data: { confirm: "You sure?" }, title: feed_item.content %&gt; &lt;% end %&gt; &lt;/li&gt; </code></pre> <p>Please let me know if there are additional files I should include. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload