Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.
/ fixture_me Public archive

Generate fixtures from development database for a Ruby on Rails application

License

Notifications You must be signed in to change notification settings

goodanthony/fixture_me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FixtureMe

Generate fixtures and fixture files for testing

If you want to generate fixtures from development database for a Ruby on Rails application here is a helper.

Installation

Add this line to your application's Gemfile:

gem 'fixture_me'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fixture_me

Usage

 rails console

Once your are inside Rails console

To generate fixtures for all models.

A new directory called fixtures would be created inside tmp directory (this is to make sure that this fixture generation would not override existing fixtures)

 fixme = FixtureMe::AddFixtures.new
 fixme.create_all_fixtures

to exclude created_at and updated_at columns

 fixme = FixtureMe::AddFixtures.new
 fixme.create_all_fixtures_no_timestamps

To generate fixtures one by one

a mymodel.yml file would be generated inside that file does not exist in the test/fixtures directory

'add_fixture' method would add the new record after the existing fixtures.

require "fixture_me"
obj = Mymodel.find(42)
obj.add_fixture

To exclude timestamps and ID

require "fixture_me"
obj = Mymodel.find(42)
obj.add_fixture_no_id_timestamps

On a last note please try to give some tender love to fixtures. There is nothing wrong with them. No doubt Factories are good. But why would you need that when there are fixtures bundled right there with Rails and they work like a charm with Rails. I'll have a dig at Rspec as well. Why on earth would one use Rspec when there is minitest.

Contributing

  1. Fork it ( https://github.com/iamfree-com/fixture_me/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Generate fixtures from development database for a Ruby on Rails application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages