Here's my Code for controller
def create
  @post = Post.new(post_params)
    if @post.save
    redirect_to @post
  else
    render 'new'
  end
end
and my code for testing
test "should get create post" do
  assert_difference('Post.count') do
    post :create, post: {title: @post.title, content: @post.content}
  end
  assert_redirected_to post_path(assigns{:post})
end
The error that I'm getting is
ArgumentError: comparison of Array with Array failed test/controllers/posts_controller_test.rb:22:in `block in '
if i remove (assigns{:post}) and try the test
i get this error
ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"posts"} missing required keys: [:id] Also how to test the if fails render 'new' part in controller.
Thanks
 
                        
@postis not instantiated anywhere in the test. You need to pass in params like sopost :create, post: {title: 'title', content: 'content'}