Note that there are some explanatory texts on larger screens.

plurals
  1. POruby on rails tutorial - rails 3.0 chapter 11 rspec fails after code listing 11.27
    primarykey
    data
    text
    <p>I have run through the book. I run "rspec spec/" after each step.</p> <p>Chapter 11 fails starting listin 11.27 adding app/views/pages/home.html.erb After Listing 11.30. Adding a micropost instance variable to the home action. app/controllers/pages_controller.rb</p> <p>Everything is supposed to be working. It isn't. I am just digging into rails for the very first time. since this was cut and paste code, I did not expect errors.</p> <p>I will be grateful for any help in leaning to debug this. Firure out if I cut and paste wrong, or if Michel's code example is not fully tested.</p> <p>Here is the rspec output:</p> <p>MPECHNER-MBP:sample_app michael.pechner$ rspec spec/ ..FF.............................................................................................FF....</p> <p>Failures:</p> <p>1) MicropostsController POST 'create' failure should not create a micropost Failure/Error: post :create, :micropost => @attr ActionView::Template::Error: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.errors # ./app/views/shared/_error_messages.html.erb:1:in <code>_app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680' # ./app/views/shared/_micropost_form.html.erb:2:in</code>block in _app_views_shared__micropost_form_html_erb_<strong>732794408121469484_2179844600__1418926388395345268' # ./app/views/shared/_micropost_form.html.erb:1:in <code>_app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268' # ./app/views/pages/home.html.erb:6:in</code>_app_views_pages_home_html_erb</strong>_1781066003698849377_2179862020__1594538359887050056' # ./app/controllers/microposts_controller.rb:10:in <code>create' # ./spec/controllers/microposts_controller_spec.rb:34:in</code>block (5 levels) in ' # ./spec/controllers/microposts_controller_spec.rb:33:in `block (4 levels) in '</p> <p>2) MicropostsController POST 'create' failure should render the home page Failure/Error: post :create, :micropost => @attr ActionView::Template::Error: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.errors # ./app/views/shared/_error_messages.html.erb:1:in <code>_app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680' # ./app/views/shared/_micropost_form.html.erb:2:in</code>block in _app_views_shared__micropost_form_html_erb_<strong>732794408121469484_2179844600__1418926388395345268' # ./app/views/shared/_micropost_form.html.erb:1:in <code>_app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268' # ./app/views/pages/home.html.erb:6:in</code>_app_views_pages_home_html_erb</strong>_1781066003698849377_2179862020__1594538359887050056' # ./app/controllers/microposts_controller.rb:10:in <code>create' # ./spec/controllers/microposts_controller_spec.rb:39:in</code>block (4 levels) in '</p> <p>3) LayoutLinks when signed in should have a signout link Failure/Error: visit root_path ActionView::Template::Error: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.errors # ./app/views/shared/_error_messages.html.erb:1:in <code>_app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680' # ./app/views/shared/_micropost_form.html.erb:2:in</code>block in _app_views_shared__micropost_form_html_erb_<strong>732794408121469484_2179844600__1418926388395345268' # ./app/views/shared/_micropost_form.html.erb:1:in <code>_app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268' # ./app/views/pages/home.html.erb:6:in</code>_app_views_pages_home_html_erb</strong>_1781066003698849377_2179862020__1594538359887050056' # :10:in <code>synchronize' # ./spec/requests/layout_links_spec.rb:51:in</code>block (3 levels) in '</p> <p>4) LayoutLinks when signed in should have a profile link Failure/Error: visit root_path ActionView::Template::Error: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.errors # ./app/views/shared/_error_messages.html.erb:1:in <code>_app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680' # ./app/views/shared/_micropost_form.html.erb:2:in</code>block in _app_views_shared__micropost_form_html_erb_<strong>732794408121469484_2179844600__1418926388395345268' # ./app/views/shared/_micropost_form.html.erb:1:in <code>_app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268' # ./app/views/pages/home.html.erb:6:in</code>_app_views_pages_home_html_erb</strong>_1781066003698849377_2179862020__1594538359887050056' # :10:in <code>synchronize' # ./spec/requests/layout_links_spec.rb:57:in</code>block (3 levels) in '</p> <p>Finished in 2.04 seconds 103 examples, 4 failures MPECHNER-MBP:sample_app michael.pechner$ </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.
 

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