https://github.com/sixarm/sixarm_ruby_active_record_migration_mock
SixArm.com » Ruby » ActiveRecord migration mock object for testing Rails
https://github.com/sixarm/sixarm_ruby_active_record_migration_mock
activerecord gem migration mock rails ruby
Last synced: 2 months ago
JSON representation
SixArm.com » Ruby » ActiveRecord migration mock object for testing Rails
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_active_record_migration_mock
- Owner: SixArm
- License: other
- Created: 2010-05-23T23:20:45.000Z (about 16 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T19:27:36.000Z (almost 3 years ago)
- Last Synced: 2025-02-06T00:26:22.185Z (over 1 year ago)
- Topics: activerecord, gem, migration, mock, rails, ruby
- Language: Ruby
- Homepage: http://sixarm.com
- Size: 343 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com → Ruby →
ActiveRecord migration mock object for testing Rails
[](http://badge.fury.io/rb/sixarm_ruby_active_record_migration_mock)
[](https://travis-ci.org/SixArm/sixarm_ruby_active_record_migration_mock)
[](https://codeclimate.com/github/SixArm/sixarm_ruby_active_record_migration_mock/maintainability)
* Git:
* Doc:
* Gem:
* Contact: Joel Parker Henderson,
* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).
## Introduction
For docs go to
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'