Skip to content

SixArm/sixarm_ruby_active_record_migration_mock

Repository files navigation

SixArm.com → Ruby →
ActiveRecord migration mock object for testing Rails

Gem Version Build Status Code Climate

Introduction

For docs go to http://sixarm.com/sixarm_ruby_active_record_migration_mock/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_active_record_migration_mock

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_active_record_migration_mock'

Require

To require the gem in your code:

require 'sixarm_ruby_active_record_migration_mock'

Example Migration

class CreateFoosMigration < ActiveRecordMigrationMock

  def self.up
    create_table 'foos', :force => true do |t|
      t.column :abc,  :integer
      t.column :def,  :string
    end
    add_index 'foos', 'abc'
  end

  def self.down
    drop_table 'foos'
  end

end

Example Usage

CreateFoosMigration.up

ActiveRecordMigration.has_table?('foos') => true
ActiveRecordMigration.has_table?('bars') => false

tables = ActiveRecordMigration.tables

table = ActiveRecordMigration.tables['foo']

table.has_column?('abc') => true
table.has_column?('xyz') => false

table.has_index?('abc') => true
table.has_index?('def') => false

columns = table.columns

column = table.columns['abc']
column.type => :integer

column = table.columns['def']
column.type => :string

indexes = table.indexes
index = table.indexes['abc']

index.table_name => 'foos'
index.column_name => 'abc'

About

SixArm.com » Ruby » ActiveRecord migration mock object for testing Rails

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages