yard-spec-plugin icon indicating copy to clipboard operation
yard-spec-plugin copied to clipboard

method_details/html/spec.erb is faulty due to .times not having a block.

Open tlabeeuw opened this issue 15 years ago • 2 comments

The 'templates_custom/default/method_details/html/specs.erb' spec causes an exception as .times expects a block. The line:

<%= spec[:source].split("\n").size.times.to_a.map {|i| spec[:line] + i }.join("\n") %>

should read:

<%= (0..(spec[:source].split("\n").size)).map { |i| _erbout << spec[:line] + i } %>

or alternatively:

<%= spec[:source].count("\n").times { |i| _erbout << spec[:line] + i } %>

Though count may not work if the last line does not end with "\n". The "_erbout" is ugly so a utility function like the capture method in rails could be used.

tlabeeuw avatar Feb 19 '10 07:02 tlabeeuw

What version is this? 1.8.6? #times should return an enumerator from 1.8.7 onwards.

lsegal avatar Feb 19 '10 08:02 lsegal

Indeed. This is on version 1.8.6. Sorry forgot to mention. A lot of people are still on this version.

tlabeeuw avatar Feb 19 '10 08:02 tlabeeuw