minitest - I'm getting an undefined method error when running tests on rails 4 with guard -


i happily working along in hartl's tut (exactly here https://www.railstutorial.org/book/filling_in_the_layout#code-contact_page_test) when started getting error in guard , have not been able find methods or method calls regarding '[]', appreciated. https://github.com/mgmacri/sample-app

02:23:12 - info - running: /home/ubuntu/workspace/sample_app/db/schema.rb doesn't exist yet. run `rake db:migrate` create it, try again. if not intend use database, should instead alter /home/ubuntu/workspace/sample_app/config/application.rb limit frameworks loaded. started  error["test_should_get_contact", staticpagescontrollertest, 5.435833117]  test_should_get_contact#staticpagescontrollertest (5.44s) actionview::template::error:         actionview::template::error: undefined method `[]' nil:nilclass             app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'             test/controllers/static_pages_controller_test.rb:24:in `block in <class:staticpagescontrollertest>'         app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'         test/controllers/static_pages_controller_test.rb:24:in `block in <class:staticpagescontrollertest>'  error["test_should_get_help", staticpagescontrollertest, 10.237566481]  test_should_get_help#staticpagescontrollertest (10.24s) actionview::template::error:         actionview::template::error: undefined method `[]' nil:nilclass             app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'             test/controllers/static_pages_controller_test.rb:12:in `block in <class:staticpagescontrollertest>'         app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'         test/controllers/static_pages_controller_test.rb:12:in `block in <class:staticpagescontrollertest>'  error["test_should_get_about", staticpagescontrollertest, 14.55194709]  test_should_get_about#staticpagescontrollertest (14.55s) actionview::template::error:         actionview::template::error: undefined method `[]' nil:nilclass             app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'             test/controllers/static_pages_controller_test.rb:18:in `block in <class:staticpagescontrollertest>'         app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'         test/controllers/static_pages_controller_test.rb:18:in `block in <class:staticpagescontrollertest>'  error["test_should_get_home", staticpagescontrollertest, 19.535717523]  test_should_get_home#staticpagescontrollertest (19.54s) actionview::template::error:         actionview::template::error: undefined method `[]' nil:nilclass             app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'             test/controllers/static_pages_controller_test.rb:6:in `block in <class:staticpagescontrollertest>'         app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280'         test/controllers/static_pages_controller_test.rb:6:in `block in <class:staticpagescontrollertest>'    4/4: [===================================] 100% time: 00:00:19, time: 00:00:19  finished in 19.54385s 4 tests, 0 assertions, 0 failures, 4 errors, 0 skips  ================================================================== 

app/views/layouts/application.html.erb

<!doctype html> <html>   <head>     <title><%= full_title(yield(:title)) %></title>     <%= stylesheet_link_tag "application", media: "all",                                            "data-turbolinks-track" =>   true %>     <%= javascript_include_tag "application", "data-turbolinks-track" => true %>     <%= csrf_meta_tags %>     <%= render 'layouts/shim' %>   </head>   <body>     <%= render 'layouts/header' %>     <div class="container">       <%= yield %>       <%= render 'layouts/footer' %>     </div>   </body> </html> 

========================================================== app/helpers/application_helper.rb

module applicationhelper    # returns full title on per-page basis.   def full_title(page_title = '')     base_title = "ruby on rails tutorial sample app"     if page_title.empty?       base_title     else       "#{page_title} | #{base_title}"     end   end end 

=========================================================================== test/controllers/static_pages_controller.rb

require 'test_helper'  class staticpagescontrollertest < actioncontroller::testcase    test "should home"     :home     assert_response :success     assert_select "title", "ruby on rails tutorial sample app"   end    test "should help"     :help     assert_response :success     assert_select "title", "help | ruby on rails tutorial sample app"   end    test "should about"     :about     assert_response :success     assert_select "title", "about | ruby on rails tutorial sample app"   end    test "should contact"     :contact     assert_response :success     assert_select "title", "contact | ruby on rails tutorial sample app"   end end 

====================

https://github.com/mgmacri/sample-app

the book missed line. add gem 'guard' on gemfile on part group :development gem 'guard' # note: necessary in newer versions gem 'guard-minitest' end

source: here


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -