test/unit/migration_tests.rb in ardb-0.28.3 vs test/unit/migration_tests.rb in ardb-0.29.0

- old
+ new

@@ -1,21 +1,19 @@ -require 'assert' -require 'ardb/migration' +require "assert" +require "ardb/migration" -# This is needed to call `classify` on a string; if this isn't manually required -# these tests can fail if activesupport hasn't been loaded by activerecord; the +# This is needed to call `classify` on a string; if this isn"t manually required +# these tests can fail if activesupport hasn"t been loaded by activerecord; the # `Migration` class will error saying `classify` is not a method on `String` -require 'active_support/core_ext/string/inflections' +require "active_support/core_ext/string/inflections" class Ardb::Migration - class UnitTests < Assert::Context desc "Ardb::Migration" setup do @migration_class = Ardb::Migration end - end class InitTests < UnitTests desc "when init" setup do @@ -53,33 +51,32 @@ assert_equal exp, subject.file_name exp = File.join(subject.migrations_path, "#{subject.file_name}.rb") assert_equal exp, subject.file_path - exp = "require 'ardb/migration_helpers'\n\n" \ - "class #{subject.class_name} < ActiveRecord::Migration\n" \ - " include Ardb::MigrationHelpers\n\n" \ + exp_version = ActiveRecord::Migration.current_version + exp = + "class #{subject.class_name} < ActiveRecord::Migration[#{exp_version}]\n" \ " def change\n" \ - " end\n\n" \ + " end\n" \ "end\n" assert_equal exp, subject.source end should "complain if no identifier is provided" do assert_raises(NoIdentifierError) do - @migration_class.new(@ardb_config, [nil, ''].sample) + @migration_class.new(@ardb_config, [nil, ""].sample) end end should "write the migration source to the migrations path on save" do subject.save! assert_equal [subject.migrations_path], @mkdir_called_with - assert_equal [subject.file_path, 'w'], @file_open_called_with + assert_equal [subject.file_path, "w"], @file_open_called_with assert_equal [subject.source], @file_spy.write_called_with end - end class FileSpy attr_reader :write_called_with @@ -89,7 +86,6 @@ def write(*args) @write_called_with = args end end - end