Possible test error

I implemented line_item delete which used button_to method. This will result in a test error called ActionView::Template::Error: Missing host to link to! Please provide :host parameter or set default_url_options[:host] I have a “if not @cart.nil?” at the end of button_to to prevent this error