diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-10 10:31:52 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-23 15:06:12 -0700 |
commit | 5278af3d8efbe348864baca0c40a532e8b137ce1 (patch) | |
tree | 8c81aecb755492b011b461e2dd7fa721c5cd7e34 /activerecord/test/cases/fixtures/file_test.rb | |
parent | 74c5f65bfb7813cecb3a1e78b522de4586e76ac9 (diff) | |
download | rails-5278af3d8efbe348864baca0c40a532e8b137ce1.tar.gz rails-5278af3d8efbe348864baca0c40a532e8b137ce1.tar.bz2 rails-5278af3d8efbe348864baca0c40a532e8b137ce1.zip |
return an empty array for empty yaml files
Diffstat (limited to 'activerecord/test/cases/fixtures/file_test.rb')
-rw-r--r-- | activerecord/test/cases/fixtures/file_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures/file_test.rb b/activerecord/test/cases/fixtures/file_test.rb index af7a2e5a4e..38494a7857 100644 --- a/activerecord/test/cases/fixtures/file_test.rb +++ b/activerecord/test/cases/fixtures/file_test.rb @@ -41,6 +41,23 @@ module ActiveRecord assert_equal [], devs - fh.to_a.map(&:first) end end + + def test_empty_file + tmp_yaml ['empty', 'yml'], '' do |t| + assert_equal [], File.open(t.path) { |fh| fh.to_a } + end + end + + private + def tmp_yaml(name, contents) + t = Tempfile.new name + t.binmode + t.write contents + t.close + yield t + ensure + t.close true + end end end end |