diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-01 07:08:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-01 07:08:19 +0000 |
commit | 2d89896461cdea858bb3f6037e0357bf95c5330f (patch) | |
tree | 4f6577426e2a184b180f79c0a6cf0644fde7a911 /test/csv/test_features.rb | |
parent | 0b8233ab07a9bfc2c100f395031adfef23c8b491 (diff) | |
download | ruby-2d89896461cdea858bb3f6037e0357bf95c5330f.tar.gz |
* test/csv/test_data_converters.rb: use descriptive assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/test_features.rb')
-rwxr-xr-x | test/csv/test_features.rb | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb index 9324af7096..a83fff84d8 100755 --- a/test/csv/test_features.rb +++ b/test/csv/test_features.rb @@ -134,10 +134,9 @@ class TestCSV::Features < TestCSV def test_csv_behavior_readers %w[ unconverted_fields return_headers write_headers skip_blanks force_quotes ].each do |behavior| - assert( !CSV.new("abc,def").send("#{behavior}?"), - "Behavior defaulted to on." ) + assert_not_predicate(CSV.new("abc,def"), "#{behavior}?", "Behavior defaulted to on.") csv = CSV.new("abc,def", behavior.to_sym => true) - assert(csv.send("#{behavior}?"), "Behavior change now registered.") + assert_predicate(csv, "#{behavior}?", "Behavior change now registered.") end end @@ -184,9 +183,9 @@ class TestCSV::Features < TestCSV # reported by Chris Roos def test_failing_to_reset_headers_in_rewind_bug_fix csv = CSV.new("forename,surname", headers: true, return_headers: true) - csv.each { |row| assert row.header_row? } + csv.each {|row| assert_predicate row, :header_row?} csv.rewind - csv.each { |row| assert row.header_row? } + csv.each {|row| assert_predicate row, :header_row?} end # reported by Dave Burt @@ -223,25 +222,24 @@ class TestCSV::Features < TestCSV zipped << [1, 2, 3] zipped.close - assert( Zlib::GzipReader.open(file) { |f| f.read }. - include?($INPUT_RECORD_SEPARATOR), - "@row_sep did not default" ) + assert_include(Zlib::GzipReader.open(file) {|f| f.read}, + $INPUT_RECORD_SEPARATOR, "@row_sep did not default") } end if defined?(Zlib::GzipWriter) def test_inspect_is_smart_about_io_types str = CSV.new("string,data").inspect - assert(str.include?("io_type:StringIO"), "IO type not detected.") + assert_include(str, "io_type:StringIO", "IO type not detected.") str = CSV.new($stderr).inspect - assert(str.include?("io_type:$stderr"), "IO type not detected.") + assert_include(str, "io_type:$stderr", "IO type not detected.") Tempfile.create(%w"temp .csv") {|tempfile| tempfile.close path = tempfile.path File.open(path, "w") { |csv| csv << "one,two,three\n1,2,3\n" } str = CSV.open(path) { |csv| csv.inspect } - assert(str.include?("io_type:File"), "IO type not detected.") + assert_include(str, "io_type:File", "IO type not detected.") } end @@ -254,7 +252,7 @@ class TestCSV::Features < TestCSV def test_inspect_shows_headers_when_available CSV.new("one,two,three\n1,2,3\n", headers: true) do |csv| - assert(csv.inspect.include?("headers:true"), "Header hint not shown.") + assert_include(csv.inspect, "headers:true", "Header hint not shown.") csv.shift # load headers assert_match(/headers:\[[^\]]+\]/, csv.inspect) end @@ -262,16 +260,16 @@ class TestCSV::Features < TestCSV def test_inspect_encoding_is_ascii_compatible CSV.new("one,two,three\n1,2,3\n".encode("UTF-16BE")) do |csv| - assert( Encoding.compatible?( Encoding.find("US-ASCII"), - csv.inspect.encoding ), - "inspect() was not ASCII compatible." ) + assert_send([Encoding, :compatible?, + Encoding.find("US-ASCII"), csv.inspect.encoding], + "inspect() was not ASCII compatible.") end end def test_version assert_not_nil(CSV::VERSION) assert_instance_of(String, CSV::VERSION) - assert(CSV::VERSION.frozen?) + assert_predicate(CSV::VERSION, :frozen?) assert_match(/\A\d\.\d\.\d\Z/, CSV::VERSION) end |