I have run through the book. I run "rspec spec/" after each step.
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
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.
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.
Here is the rspec output:
MPECHNER-MBP:sample_app michael.pechner$ rspec spec/ ..FF.............................................................................................FF....
Failures:
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 _app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680'
# ./app/views/shared/_micropost_form.html.erb:2:in
block in _app_views_shared__micropost_form_html_erb_732794408121469484_2179844600__1418926388395345268'
# ./app/views/shared/_micropost_form.html.erb:1:in _app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268'
# ./app/views/pages/home.html.erb:6:in
_app_views_pages_home_html_erb_1781066003698849377_2179862020__1594538359887050056'
# ./app/controllers/microposts_controller.rb:10:in create'
# ./spec/controllers/microposts_controller_spec.rb:34:in
block (5 levels) in '
# ./spec/controllers/microposts_controller_spec.rb:33:in `block (4 levels) in '
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 _app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680'
# ./app/views/shared/_micropost_form.html.erb:2:in
block in _app_views_shared__micropost_form_html_erb_732794408121469484_2179844600__1418926388395345268'
# ./app/views/shared/_micropost_form.html.erb:1:in _app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268'
# ./app/views/pages/home.html.erb:6:in
_app_views_pages_home_html_erb_1781066003698849377_2179862020__1594538359887050056'
# ./app/controllers/microposts_controller.rb:10:in create'
# ./spec/controllers/microposts_controller_spec.rb:39:in
block (4 levels) in '
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 _app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680'
# ./app/views/shared/_micropost_form.html.erb:2:in
block in _app_views_shared__micropost_form_html_erb_732794408121469484_2179844600__1418926388395345268'
# ./app/views/shared/_micropost_form.html.erb:1:in _app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268'
# ./app/views/pages/home.html.erb:6:in
_app_views_pages_home_html_erb_1781066003698849377_2179862020__1594538359887050056'
# :10:in synchronize'
# ./spec/requests/layout_links_spec.rb:51:in
block (3 levels) in '
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 _app_views_shared__error_messages_html_erb___2864847557408089106_2179824440__3563936241835894680'
# ./app/views/shared/_micropost_form.html.erb:2:in
block in _app_views_shared__micropost_form_html_erb_732794408121469484_2179844600__1418926388395345268'
# ./app/views/shared/_micropost_form.html.erb:1:in _app_views_shared__micropost_form_html_erb___732794408121469484_2179844600__1418926388395345268'
# ./app/views/pages/home.html.erb:6:in
_app_views_pages_home_html_erb_1781066003698849377_2179862020__1594538359887050056'
# :10:in synchronize'
# ./spec/requests/layout_links_spec.rb:57:in
block (3 levels) in '
Finished in 2.04 seconds 103 examples, 4 failures MPECHNER-MBP:sample_app michael.pechner$