1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/csv/helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
837 B
Ruby
Raw Normal View History

require "tempfile"
require "test/unit"
require "csv"
require_relative "../lib/with_different_ofs"
module Helper
def with_chunk_size(chunk_size)
chunk_size_keep = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"]
begin
ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size
yield
ensure
ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size_keep
end
end
def with_verbose(verbose)
original = $VERBOSE
begin
$VERBOSE = verbose
yield
ensure
$VERBOSE = original
end
end
def with_default_internal(encoding)
original = Encoding.default_internal
begin
with_verbose(false) do
Encoding.default_internal = encoding
end
yield
ensure
with_verbose(false) do
Encoding.default_internal = original
end
end
end
end