Skip to content

Commit

Permalink
fix conversion issue with html entities in ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
asceth authored and Nerian committed Jan 29, 2011
1 parent 8e6c870 commit 1a5e59e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/akephalos/capybara.rb
Expand Up @@ -186,8 +186,19 @@ def source
end

# @return [String] the page's modified source
# page.modified_source will return a string with
# html entities converted into the unicode equivalent
# but the string will be marked as ASCII-8BIT
# which causes conversion issues so we force the encoding
# to UTF-8 (ruby 1.9 only)
def body
page.modified_source
body_source = page.modified_source

if body_source.respond_to?(:force_encoding)
body_source.force_encoding("UTF-8")
else
body_source
end
end

# @return [Hash{String => String}] the page's response headers
Expand Down

0 comments on commit 1a5e59e

Please sign in to comment.