1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00
Commit graph

12 commits

Author SHA1 Message Date
Daniel Colson
870bf2a2f4 Run standard on CI
To ensure we run standard before merging any PR, this commit adds
standard to Travis CI
2020-06-10 17:13:56 -04:00
Daniel Colson
ce8bfb409b Run standardrb
This commit applies the changes from running `standardrb --fix`
2020-06-10 17:13:56 -04:00
Daniel Colson
ba7f5ef327 Update Appraisals
Get rid of the deprecated appraisal rake tasks in favor of running
appraisal directly. To run the whole suite, we can run
`bundle exec appraisal rake`.

I also went ahead and updated all the gemfiles.
2018-10-31 16:22:15 -04:00
Alex
77d707d2c7 Address todos generated by rubocop for files in Rakefile and Appraisals. (#298)
This partially addresses #293. Since rubocop generated quite a few todos, the commits addressing them are split up into a few different PRs that cover different files.
2018-09-28 14:10:19 -04:00
Daniel Colson
02a0f58487 Allow reloading of factory definitions
Closes #236

This commit uses ActiveSupport's FileUpdateChecker to allow reloading
FactoryBot of definitions whenever a file in
`FactoryBot.definition_file_paths` gets updated.
This is similar to reloading for
[I18n](ced104d579/activesupport/lib/active_support/i18n_railtie.rb (L60-L70))
and [react rails](83b6175460/lib/react/rails/railtie.rb (L35-L41))

This allows us to get rid of any Spring-specific logic in the railtie,
since [Spring hooks into the application
reloader](0c711ff10b/lib/spring/application.rb (L161)).

This partly solves #211, since we no longer call `FactoryBot.reload` at
all in `after_initialize`. Instead, we will only call it when one of the
files in `definition_file_paths` gets updated. I say it partly
solves #211 because once a definition file gets updated, reloading
would still give warnings about redefining any constants in the
definition files. I wonder how common it is to define constants in the
same file as factory definitions. It's probably better to keep constants
in the autoload path, allowing Rails to handle unloading and reloading
them in development. I would want to see some specific examples before
worrying too much about it.

I would also like to offer a better way to configure the definition file
paths (see #165 and #166) and possibly an option to opt out of loading
definitions at all (could help with issues like #192).

A couple of quirks here:
* the to_prepare block could potentially get
[called multiple times](https://github.com/rails/rails/issues/28108).
It shouldn't matter, since `execute_if_updated` is a no-op if no
updates have been made.

* I noticed that the first time I call `reload!` in the console the
factory definitions get reloaded even when I made no updates to the
definition files. I think it is related to
[this](f7c5a8ce26/activesupport/lib/active_support/evented_file_update_checker.rb (L18)). After the first call
`reload!` works as expected, only reloading the factory definitions
if the definition files were updated.

* Rails uses execute rather than execute_if_updated for the
[route
reloader](https://github.com/rails/rails/blob/master/railties/lib/rails/application/finisher.rb#L133)
and for the [watchable file
reloader](https://github.com/rails/rails/blob/master/railties/lib/rails/application/finisher.rb#L173).
This means that changes to factory definitions will cause reloading of
the whole application. I think this is fine.
2018-09-08 02:21:47 +00:00
Avielle Wolfe
c5d11518d7 Rename all girl -> bot
* Rename files and code
* Change factory_girl dependency to factory_bot

This change will bring _rails name in line with factory_bot
c716ce01b4
2017-10-20 18:21:52 -04:00
Joshua Clayton
402e6ed84c Use Appraisal
This allows us to test factory_girl_rails against each minor release of
Rails 3. To run the full suite, run

    $ bundle exec rake

To view all the rake tasks Appraisal provides, run

    $ bundle exec rake -T appraisal
2012-11-02 16:35:09 -04:00
Gabe Berke-Williams
797a98533f bundler/setup is important. 2011-11-18 18:29:41 -05:00
Gabe Berke-Williams
9cee2e5baa bundler/gem_tasks is easier. 2011-11-12 17:06:57 -05:00
Gabe Berke-Williams
eb7d9c1126 Use Bundler gem conventions. 2011-11-12 09:43:52 -05:00
Joe Ferris
3c691f2717 Use bundler for dependencies (based on patches from Mike Gehard) 2010-11-11 11:44:49 -05:00
Joe Ferris
dd737af03e Added Rails 3 integration 2010-06-09 11:42:48 -04:00