From c7589559dea75a735ccb74364b06d57f26f1db3d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 9 Dec 2004 15:52:54 +0000 Subject: Tidied up Fixtures for better readability and some error checking [bitsweat] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@100 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/fixtures_test.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'activerecord/test/fixtures_test.rb') diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index 5b4bf9a922..a971b9f6f8 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -5,7 +5,7 @@ require 'fixtures/company' class FixturesTest < Test::Unit::TestCase fixtures :topics, :developers, :accounts - + FIXTURES = %w( accounts companies customers developers developers_projects entrants movies projects subscribers topics ) @@ -49,34 +49,40 @@ class FixturesTest < Test::Unit::TestCase def test_bad_format path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures') Dir.entries(path).each do |file| - next unless File.file?(file) and file !~ %r(^.|.yaml$) + next unless File.file?(file) and file !~ Fixtures::DEFAULT_FILTER_RE assert_raise(Fixture::FormatError) { Fixture.new(bad_fixtures_path, file) } end end + def test_deprecated_yaml_extension + assert_raise(Fixture::FormatError) { + Fixtures.new(nil, 'bad_extension', File.join(File.dirname(__FILE__), 'fixtures')) + } + end + def test_logger_level_invariant level = ActiveRecord::Base.logger.level create_fixtures('topics') assert_equal level, ActiveRecord::Base.logger.level end - + def test_instantiation topics = create_fixtures("topics") assert_kind_of Topic, topics["first"].find end - + def test_complete_instantiation assert_equal 2, @topics.size assert_equal "The First Topic", @first.title end - + def test_fixtures_from_root_yml_with_instantiation # assert_equal 2, @accounts.size assert_equal 50, @unknown.credit_limit end - + def test_erb_in_fixtures assert_equal 10, @developers.size assert_equal "fixture_5", @dev_5.name -- cgit v1.2.3