csv.patch

Marc-Andre Lafortune, 07/22/2011 04:23 AM

Download (1.53 KB)

View differences:

lib/csv.rb
1234 1234
      io.seek(0, IO::SEEK_END)
1235 1235
      args.unshift(io)
1236 1236
    else
1237
      encoding = args.last.is_a?(Hash) ? args.last.delete(:encoding) : nil
1237
      encoding = (args[-1] = args[-1].dup).delete(:encoding) if args.last.is_a?(Hash)
1238 1238
      str      = ""
1239 1239
      str.encode!(encoding) if encoding
1240 1240
      args.unshift(str)
test/csv/test_interface.rb
316 316
    assert_equal(STDOUT, CSV.instance.instance_eval { @io })
317 317
    assert_equal(STDOUT, CSV { |new_csv| new_csv.instance_eval { @io } })
318 318
  end
319

  
320
  def test_options_are_not_modified
321
    opt = {}.freeze
322
    assert_nothing_raised {  CSV.foreach(@path, opt)       }
323
    assert_nothing_raised {  CSV.open(@path, opt){}        }
324
    assert_nothing_raised {  CSV.parse("", opt)            }
325
    assert_nothing_raised {  CSV.parse_line("", opt)       }
326
    assert_nothing_raised {  CSV.read(@path, opt)          }
327
    assert_nothing_raised {  CSV.readlines(@path, opt)     }
328
    assert_nothing_raised {  CSV.table(@path, opt)         }
329
    assert_nothing_raised {  CSV.generate(opt){}           }
330
    assert_nothing_raised {  CSV.generate_line([], opt)    }
331
    assert_nothing_raised {  CSV.filter("", "", opt){}     }
332
    assert_nothing_raised {  CSV.instance("", opt)         }
333
  end
319 334
end