ruby - Parsing a heredoc with Nokogiri -


i have ruby method uses nokogiri parse heredoc. looks , passes specs:

def html_headers   nokogiri::xml::documentfragment.parse(<<-html)   ....   html end 

however, when change following, fails specs. i'm new ruby, i'm not sure how might change result. tests in console suggest shouldn't change anything, str should contain equivalent string previous version of method.

def html_headers   str = <<-html   ...   html   nokogiri::xml::documentfragment.parse(str) end 

rather deleting question, i'll leave record of shame. original code actually

def html_headers   nokogiri::xml::documentfragment.parse(<<-html) <div>...</div>   html end 

and code failing was

def html_headers   str = <<-html   <div>...</div>   html   nokogiri::xml::documentfragment.parse(str) end 

i thought indenting heredoc bring inline rest of method wouldn't have effect. silly me.


Popular posts from this blog