From 081b36c6ce799f2e4c755bdaf2fa978c9e494567 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 10 May 2011 10:42:03 -0700 Subject: fixture file will validate fixture format --- activerecord/test/cases/fixtures/file_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/fixtures/file_test.rb b/activerecord/test/cases/fixtures/file_test.rb index 38494a7857..174f41f412 100644 --- a/activerecord/test/cases/fixtures/file_test.rb +++ b/activerecord/test/cases/fixtures/file_test.rb @@ -48,6 +48,24 @@ module ActiveRecord end end + # A valid YAML file is not necessarily a value Fixture file. Make sure + # an exception is raised if the format is not valid Fixture format. + def test_wrong_fixture_format_string + tmp_yaml ['empty', 'yml'], 'qwerty' do |t| + assert_raises(ActiveRecord::Fixture::FormatError) do + File.open(t.path) { |fh| fh.to_a } + end + end + end + + def test_wrong_fixture_format_nested + tmp_yaml ['empty', 'yml'], 'one: two' do |t| + assert_raises(ActiveRecord::Fixture::FormatError) do + File.open(t.path) { |fh| fh.to_a } + end + end + end + private def tmp_yaml(name, contents) t = Tempfile.new name -- cgit v1.2.3