ruby on rails - functional test: NomethodError -


"itemprop =" text ">

I am starting Rails on Rails (and English :)), and I try to use functional testing I'm doing, but test_should_get_new (MicropostControllerTest) NoMethodError: 'microposts' the undefined method for zero: NilClass

I fist my micropost_controller_test.rb

  1) There was an error in the error  
  requires the 'test_helper' class MicropostControllerTest & lt; ActionController :: testcase test should get "new" tax: new assert_response: success end end  

my micropost_controller.rb

  class micropostController & lt; (: Content = & gt; parameter [: content]) ApplicationController def new @post = Micropost.new @posts = current_user.microposts.all end DEF @post = current_user.microposts.create create logger.debug "new post: # { @ Post.attributes.inspect} "logger.debug" post should be valid: #{@post.valid} "If @post redirect_to micropost_new_path any other end end end  

In tried Microposts.yml but it did not work So, where can I find a microprot method for functional testing and how can I fix it? Please help me

P / S: my application is still local host

If you are using Devise for user authentication, then you have to do your work

current_user in MicropostController needs to be validated and set, for example before_action as follows:
  Class Microprost Controller & lt; ApplicationController before_action: authenticate_user! Def new @ post = micropost.new @posts = current_user.microposts.all # end code expiration  

If you are in heaven, in your trial, you will be asked to help WikiLeaks It has to be imported into your test_helper

  class MicropostControllerTest & lt; Action Controller :: In the test season, you can use the  sign_in  method to sign into the user using the fixtures in your test:  

on that Search for some tutorials or give feedback on getting some clues here: