Daddy's Girl
Daddy's Girl is a Ruby gem to provide object_daddy-like syntax for factory_girl
Installation
Add this line to your application's Gemfile:
gem 'daddys_girl'
And then execute:
$ bundle
Or install it yourself as:
$ gem install daddys_girl
Usage
First, you must add a class definition to the Factory Girl factories file (normally spec/factories.rb)
Methods:
-
ClassName.factory_spawn(params)
: creates an object, but does not save it -
ClassName.generate(params)
: creates an object and attempts to save it -
ClassName.generate!(params)
: creates an object, and throws an error if it can not save it
Daddy's Girl also works with associations. For example:
object.has_many_association.generate!(params)
will generate the associated object, and bind it to the calling object.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request