FactoryBotSequences
Collection of useful FactoryBot sequences.
Important
This minigem provides only a basic set of standard data. If you need more complex data in your application (e.g. US postal code or address), I recommend Faker.
Installation
Add this line to your application's Gemfile:
gem 'factory_bot_sequences', :group => :test
Or install it yourself as:
$ gem install factory_bot_sequences
Sequences
Name | Aliases | DataType | Example |
---|---|---|---|
integer | checksum, int | Integer | 1 |
string | - | String | string-1 |
date | - | Date | Sat, 20 Oct 2012 |
datetime | - | Time | Sat, 20 Oct 2012 16:38:59 MSK +04:00 |
boolean | - | Boolean | true |
uuid | guid | String | 0a4ea40d-e7ed-4fc1-890c-7af86c9c3a07 |
name | login, username, first_name, last_name | String | name-1 |
password | - | String | password-1 |
- | String | [email protected] | |
port | - | Integer | 1025 |
ip_address | - | String | 192.168.0.1 |
ip_subnet | - | String | 192.168.10.0 |
mac_address | - | String | 01:23:45:67:89:01 |
title | - | String | Title 1 |
body | description, text, content | String | body-1 |
slug | - | String | slug-1 |
url | - | String | http://example1.com |
domain | - | String | example1.com |
subdomain | - | String | blog1 |
color | - | String | 333333 |
timestamp | - | Fixnum | 1374582311 |
token | - | String | JS74sef41ZosXek1ndvY |
seat | - | String | 01A |
Usage
Basic example:
FactoryBot.generate :email
# => "[email protected]"
FactoryBot.generate :email
# => "[email protected]"
Use them as attributes (preferable way):
factory :user do
email
end
Or in lazy attributes:
factory :invite do
invitee { generate(:email) }
end
Check out FactoryBot's GETTING_STARTED for more information.
Spork or TConsole
For whose of you who are using spork or tconsole, consider adding FactoryBotSequences.reload
right after FactoryBot.reload
.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Test your changes by running
bundle exec rake cucumber
command - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Created by Anton Kaliaev
Thank you to all our amazing contributors!
Changelog
4.8.4 / 2020-08-18
- unlock factory_bot version
4.8.3 / 2017-11-01
- migrate to factory_bot
4.8.0 / 2017-01-14
- updated dependencies (
activesupport >= 4.2
)
4.3.1 / 2014-08-08
- added few aliases [Kirill Platonov]
4.3.0 / 2014-07-31
- added uuid sequence [Kirill Platonov]
4.2.0 / 2014-01-09
- added a seat sequence [Hans Lemuet]
4.1.0 / 2013-11-14
- added port and token sequences [Andrew Kulakov]
- aliased body as text / content [Andrew Kulakov]
4.0.0 / 2013-02-22
- updated factory_girl version
- added appraisal
- rewrite tests
- created separate reload method
0.1.1 / 2012-10-27
- Updated README
0.1.0 / 2012-10-24
- Added url sequence
- Fixed slug sequence
- Updated README
0.0.4 / 2012-10-20
- Added travis-ci
- Added extra options for docs
0.0.3 / 2012-10-20
- Pathed FactoryBot.reload to add default sequences
0.0.3 / 2012-10-20
- Updated README
- Added link to the homepage