This commit deprecates several undocumented top-level FactoryBot
methods:
* callbacks
* configuration
* constructor
* initialize_with
* register_sequence
* resent_configuration
* skip_create
* to_create
factory_bot users are not meant to access these methods directly.
Instead they are available for internal use through the new Internal
module introduced in #1262.
---
While addressing the new deprecation warnings, I tried to make the
delegation a bit more consistent, always delegating to
`FactoryBot::Internal`.
This involved requiring "factory_bot/internal" sooner. To avoid having
to fight with the order of requires and potential circular dependencies,
I moved the default strategy and callback registration out of constants
(this is how they used to be before #1297), so it doesn't matter if
those strategies are loaded before the `Internal` module. I also deleted
a pair of tests that were using these constants - these strategies and
callbacks are covered elsewhere in our test suite, and I don't think
these tests were adding much value (they missed #1379, for example).
Why:
These methods are used internally for the functionality of the library
and are subject to change. Therefore shouldn't be part of the public
interface.
This PR:
- Moves the ```register_strategy```, ```register_callback```,
```register_default_factories```, ```register_default_callbacks```
```strategies```, ```callback_names```
and ```strategy_by_name``` methods to the ```FactoryBot::Internal```
class.
- Deprecates the use of ```register_callback``` from the ```FactoryBot```
module.
Why:
These methods are used internally for the functionality of the library
and are subject to change. Therefore shouldn't be part of the public
interface.
This PR:
- Moves the ```register_factory``` and ```factory_by_name``` methods to
the ```FactoryBot::Internal``` class.
- Deprecates the use of ```register_factory``` and ```factory_by_name```
from the ```FactoryBot``` module.
- Improve formatting of the specs
Why:
Another run of internal methods that should not be publicly
available from the base namespace.
This time the sequence involving methods were moved. It's worth noticing
that the ```Internal``` class is getting crowded. Maybe we can start
name-spacing the internal groups into modules under
```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts?
This PR:
- Moves the ```register_sequence```, ```sequence_by_name```,
```sequences``` and ```rewind_sequences``` to the
```FactoryBot::Internal``` module.
- Deprecates uses of ```sequence_by_name```, and ```sequences```
from the ```FactoryBot``` module.
- Refactor rewind sequences test to use spies
This is one of the steps towards fixing [this
issue](https://github.com/thoughtbot/factory_bot/pull/1285#1281)
Why:
These are essentially internal methods that should not be publicly
available from the base namespace.
One thing worth noticing is that the use of this methods internally was
almost exclusively in the `syntax/default` except for one use on the
`factory_bot/definition`.
Also the deprecation silencing module was referring to the singleton
instance of the ```ActiveRecord::Deprecation``` class and not to the new
deprecation instance that was being used in the ```FactoryBot``` module.
This PR:
- Moves the `trait_by_name` and `register_trait` into the
`FactoryBot::Internal` module
- Deprecates uses of `trait_by_name`, `register_trait` and `traits` from
the `FactoryBot` module.
- Rename DEPRECATOR => Deprecation
This is one of the steps towards fixing [this
issue](https://github.com/thoughtbot/factory_bot/issues/1281)