Sha256: 319e2297800a2f8562c3c22d1ea2f0cfc7c2cdbba14821f53660f0a32b17bce9

Contents?: true

Size: 675 Bytes

Versions: 28

Compression:

Stored size: 675 Bytes

Contents

module DatabaseMacros
  # Run migrations in the test database
  def run_migration(&block)
    # Create a new migration class
    klass = Class.new(ActiveRecord::Migration)

    # Create a new `up` that executes the argument
    klass.send(:define_method, :up) { self.instance_exec(&block) }

    # Create a new instance of it and execute its `up` method
    klass.new.up
  end

  def setup_database(opts = {})
    adapter = "#{opts[:adapter].capitalize}Adapter".constantize.new(database: opts[:database])
    adapter.establish_connection!
    adapter.reset_database!

    # Silence everything
    ActiveRecord::Base.logger = ActiveRecord::Migration.verbose = false
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
emojimmy-0.3 spec/support/macros/database_macros.rb
activerecord_json_validator-0.3 spec/support/macros/database_macros.rb
microscope-0.6.1 spec/support/macros/database_macros.rb
microscope-0.6 spec/support/macros/database_macros.rb
microscope-0.5.10 spec/support/macros/database_macros.rb
microscope-0.5.9 spec/support/macros/database_macros.rb
microscope-0.5.8 spec/support/macros/database_macros.rb
microscope-0.5.7 spec/support/macros/database_macros.rb
activerecord_json_validator-0.2 spec/support/macros/database_macros.rb
microscope-0.5.6.1 spec/support/macros/database_macros.rb
microscope-0.5.6 spec/support/macros/database_macros.rb
microscope-0.5.5 spec/support/macros/database_macros.rb
microscope-0.5.4 spec/support/macros/database_macros.rb
microscope-0.5.3 spec/support/macros/database_macros.rb
microscope-0.5.2 spec/support/macros/database_macros.rb
activerecord_json_validator-0.1.3 spec/support/macros/database_macros.rb
emojimmy-0.2.2 spec/support/macros/database_macros.rb
activerecord_json_validator-0.1.2 spec/support/macros/database_macros.rb
emojimmy-0.2.1 spec/support/macros/database_macros.rb
activerecord_json_validator-0.1.1 spec/support/macros/database_macros.rb