Commit Graph

9 Commits

Author SHA1 Message Date
Daniel Colson 0f4b404569 Deprecate remaining undocumented internal methods
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).
2020-04-23 19:35:39 -04:00
Alejandro Dustet f82e40c8c5 Deprecate/Move strategies and callback methods
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.
2019-06-04 20:09:14 -04:00
Alejandro Dustet 4d1cb6219b Deprecate and move to Internal factories methods
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
2019-06-04 19:39:04 -04:00
Alejandro Dustet 5947e10578 Deprecate and move to Internal sequence methods
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)
2019-06-04 19:02:51 -04:00
Alejandro Dustet 99ac02400f Move and deprecate trait methods from FactoryBot
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)
2019-04-26 16:03:22 -04:00
Daniel Colson d2a30d6fd2 Introduce FactoryBot::Internal module
The `FactoryBot` module has a mixture of methods that are meant for use
by people using the library, and methods that are meant only for
internal use. The methods meant for internal use are cluttering the
documentation, and may be confusing to users.

This change was prompted by [#1258]. Rather than introduce yet another
public method on `FactoryBot` meant only for internal use,
we can introduce a `FactoryBot::Internal` module,
and avoid generating documentation for that module.

The `FactoryBot::Internal.register_inline_sequence` method in [#1258]
will need access to the configuration instance, so this PR moves that
into `FactoryBot::Internal`. Eventually I plan to deprecate
`FactoryBot.configuration` and `FactoryBot.reset_configuration`, and to
move more of the `FactoryBot` methods into `FactoryBot::Internal`, but I
would rather hold off on all that until the dust settles on the 5.0
release.

[#1258]: https://github.com/thoughtbot/factory_bot/pull/1258
2019-02-13 11:31:49 -05:00
Henry J. Wylde 917af38246 Add documentation and YARD method directives (#1249)
FactoryBot::Syntax::Methods was missing some documentation on
the *_pair methods. This adds in the documentation and
corresponding method directives.

Further, add the missing &block parameter to the existing *_list directives.

We decided not to included documentation for the `null` strategy,
since this strategy is used internally, and only returns `nil`. There isn't
much point in documenting it and making it available.
2019-01-11 10:32:36 -05:00
Hunter Braun 6a25e989b6 [Rubocop] Lint Cop Offenses (#1207) 2018-10-05 14:54:08 -04:00
Avielle c716ce01b4 Replace 'girl' with 'bot' everywhere (#1051)
Also: add a deprecation warning to factory_girl, asking users to switch to
factory_bot

https://github.com/thoughtbot/factory_girl/issues/921
2017-10-20 15:20:28 -04:00