Project

fixture_me

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
If you want to generate fixtures from development database for a Ruby on Rails application here is a helper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

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