Skip to content

Commit

Permalink
made the tests pass in both ruby 1.8 and 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
lsylvester authored and kbrock committed Dec 31, 2009
1 parent 6214f81 commit 945c36e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rails-footnotes/notes/controller_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def controller_line_number
def lines_from_index(string, index)
return nil if string.blank? || index.blank?

lines = string.to_a
lines = [] #string.respond_to?(:to_a) ? string.to_a : string.lines.to_a
running_length = 0
lines.each_with_index do |line, i|
running_length += line.length
Expand Down
6 changes: 4 additions & 2 deletions test/footnotes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ def test_insert_footnotes_inside_holder
def test_insert_text
@footnotes.send(:insert_text, :after, /<head>/, "Graffiti")
after = " <head>Graffiti\n"
assert_equal after, @controller.response.body.to_a[2]
response_lines = @controller.response.body.respond_to?(:to_a) ? @controller.response.body.to_a : @controller.response.body.lines.to_a
assert_equal after, response_lines[2]

@footnotes.send(:insert_text, :before, /<\/body>/, "Notes")
after = " Notes</body>\n"
assert_equal after, @controller.response.body.to_a[12]
response_lines = @controller.response.body.respond_to?(:to_a) ? @controller.response.body.to_a : @controller.response.body.lines.to_a
assert_equal after, response_lines[12]
end

protected
Expand Down

0 comments on commit 945c36e

Please sign in to comment.