SixArm.com » Ruby » ActiveRecord migration mock object for testing Rails
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.codeclimate/badges
doc
lib
test
.codeclimate.yml
.coveralls.yml
.document
.gemtest
.gitattributes
.gitignore
.rspec
.travis.yml
CHANGES.md
CODEOWNERS
CONTRIBUTING.md
Gemfile
LICENSE.md
README.md
Rakefile
VERSION
sixarm_ruby_active_record_migration_mock.gemspec

README.md

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'