diff options
author | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-10 15:32:29 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-10 15:35:12 -0700 |
commit | fdba1a791bb32bc890a50a3655d7369f80377caa (patch) | |
tree | 35076542057dead87d2c8b42d9472c8c71d05a1d | |
parent | 2c76793f087e212ff4c6d835656a9a95c8bfeaa5 (diff) | |
download | rails-fdba1a791bb32bc890a50a3655d7369f80377caa.tar.gz rails-fdba1a791bb32bc890a50a3655d7369f80377caa.tar.bz2 rails-fdba1a791bb32bc890a50a3655d7369f80377caa.zip |
Speed up schema dumper tests
Dump the standard schema once instead of redoing it per test
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 72fb296825..d7ee56374d 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -10,12 +10,11 @@ class SchemaDumperTest < ActiveRecord::TestCase end def standard_dump - @stream = StringIO.new - old_ignore_tables, ActiveRecord::SchemaDumper.ignore_tables = ActiveRecord::SchemaDumper.ignore_tables, [] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream) - @stream.string - ensure - ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables + @@standard_dump ||= perform_schema_dump + end + + def perform_schema_dump + dump_all_table_schema [] end def test_dump_schema_information_outputs_lexically_ordered_versions @@ -31,8 +30,7 @@ class SchemaDumperTest < ActiveRecord::TestCase end def test_magic_comment - output = standard_dump - assert_match "# encoding: #{@stream.external_encoding.name}", output + assert_match "# encoding: #{Encoding.default_external.name}", standard_dump end def test_schema_dump @@ -255,12 +253,12 @@ class SchemaDumperTest < ActiveRecord::TestCase connection = ActiveRecord::Base.connection connection.stubs(:extensions).returns(['hstore']) - output = standard_dump + output = perform_schema_dump assert_match "# These are extensions that must be enabled", output assert_match %r{enable_extension "hstore"}, output connection.stubs(:extensions).returns([]) - output = standard_dump + output = perform_schema_dump assert_no_match "# These are extensions that must be enabled", output assert_no_match %r{enable_extension}, output end @@ -401,7 +399,7 @@ class SchemaDumperTest < ActiveRecord::TestCase migration = CreateDogMigration.new migration.migrate(:up) - output = standard_dump + output = perform_schema_dump assert_no_match %r{create_table "foo_.+_bar"}, output assert_no_match %r{add_index "foo_.+_bar"}, output assert_no_match %r{create_table "schema_migrations"}, output |