diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-10 10:42:03 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-23 15:06:12 -0700 |
commit | 081b36c6ce799f2e4c755bdaf2fa978c9e494567 (patch) | |
tree | 5b8c74ae96d10764e7b5f24bdaf4dcfc36be92b6 /activerecord/test/cases | |
parent | 5278af3d8efbe348864baca0c40a532e8b137ce1 (diff) | |
download | rails-081b36c6ce799f2e4c755bdaf2fa978c9e494567.tar.gz rails-081b36c6ce799f2e4c755bdaf2fa978c9e494567.tar.bz2 rails-081b36c6ce799f2e4c755bdaf2fa978c9e494567.zip |
fixture file will validate fixture format
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/fixtures/file_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
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 |