* lib/csv.rb (CSV.foreach): 'rb' mode is defaulted in open.

* lib/csv.rb (CSV#init_separators): cannonicalize encoding options
  as Encoding objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-12-25 09:04:33 +00:00
parent 9ff4e23741
commit 08d99ac9e3
3 changed files with 36 additions and 7 deletions

View file

@ -260,6 +260,23 @@ class TestCSV::Encodings < TestCSV
end unless encoding == __ENCODING__
rescue Encoding::ConverterNotFoundError
end
options[:encoding] = encoding.name
CSV.open(@temp_csv_path, options) do |csv|
csv.each_with_index do |row, i|
assert_equal(fields[i], row)
end
end
options.delete(:encoding)
options[:external_encoding] = encoding.name
options[:internal_encoding] = __ENCODING__.name
begin
CSV.open(@temp_csv_path, options) do |csv|
csv.each_with_index do |row, i|
assert_equal(orig_fields[i], row)
end
end unless encoding == __ENCODING__
rescue Encoding::ConverterNotFoundError
end
end
def encode_ary(ary, encoding)