1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Replace inject with slightly more legible select

This commit is contained in:
Adam Spiers 2010-11-08 10:18:43 +00:00 committed by Adam Spiers
parent f46df7791f
commit 721d6ef33f

View file

@ -26,10 +26,9 @@ module Capybara
def rewrite_css_and_image_references(response_html) # :nodoc:
return response_html unless Capybara.asset_root
directories = Dir.new(Capybara.asset_root).entries.inject([]) do |list, name|
list << name if File.directory?(name) and not name.to_s =~ /^\./
list
end
directories = Dir.new(Capybara.asset_root).entries.select { |name|
File.directory?(name) and not name.to_s =~ /^\./
}
response_html.gsub(/=("|')\/(#{directories.join('|')})/, '=\1' + Capybara.asset_root.to_s + '/\2')
end
end