Skip to content
This repository
Browse code

instantiate our own broken migration rather than relying on the files…

…ystem
  • Loading branch information...
commit a85625dacfe7782148f7566c199d562c8acb71c0 1 parent 452195a
Aaron Patterson authored January 11, 2012
14  activerecord/test/cases/migration_test.rb
@@ -879,16 +879,20 @@ def test_migrator_one_up_with_exception_and_rollback
879 879
       skip "not supported on #{ActiveRecord::Base.connection.class}"
880 880
     end
881 881
 
882  
-    assert !Person.column_methods_hash.include?(:last_name)
  882
+    refute Person.column_methods_hash.include?(:last_name)
883 883
 
884  
-    e = assert_raise(StandardError) do
885  
-      ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100)
886  
-    end
  884
+    migration = Struct.new(:name, :version) {
  885
+      def migrate(x); raise 'Something broke'; end
  886
+    }.new('zomg', 100)
  887
+
  888
+    migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
  889
+
  890
+    e = assert_raise(StandardError) { migrator.migrate }
887 891
 
888 892
     assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message
889 893
 
890 894
     Person.reset_column_information
891  
-    assert !Person.column_methods_hash.include?(:last_name)
  895
+    refute Person.column_methods_hash.include?(:last_name)
892 896
   end
893 897
 
894 898
   def test_finds_migrations
10  activerecord/test/migrations/broken/100_migration_that_raises_exception.rb
... ...
@@ -1,10 +0,0 @@
1  
-class MigrationThatRaisesException < ActiveRecord::Migration
2  
-  def self.up
3  
-    add_column "people", "last_name", :string
4  
-    raise 'Something broke'
5  
-  end
6  
-
7  
-  def self.down
8  
-    remove_column "people", "last_name"
9  
-  end
10  
-end

0 notes on commit a85625d

Please sign in to comment.
Something went wrong with that request. Please try again.