1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
Commit graph

17 commits

Author SHA1 Message Date
Daniel Colson
5f1a1de114 Run standardrb
This commit applies the changes from running `standardrb --fix`
2020-06-10 17:11:39 -04:00
Oliver Peate
7722017bc7 Adjust use_parent_strategy safely in specs
Uses a block-based helper so we can remove a global around hook.
2019-08-12 18:54:53 +01:00
Daniel Colson
3e1a941347 Do not reset use_parent_strategy on reload
Before this PR, `use_parent_strategy` was set on the configuration
instance. Since `FactoryBot.reload` wipes out the configuration, it also
ends up resetting `use_parent_strategy` back to `nil`.

This can cause problems when using factory_bot_rails with Spring, since
it calls `FactoryBot.reload` each time Spring forks. If
`use_parent_strategy` is set in a file that Spring preloads, like in an
initializer, then the value will get wiped out.

With this PR, we set `use_parent_strategy` directly on FactoryBot,
rather than on the configuration instance, and so reloading no longer
has any effect.
2019-01-04 15:47:32 -05:00
Susan Wright
c22c9ab052 Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
Oli Peate
01d81f54b5 Remove unnecessary spec_helper requires
https://github.com/rspec/rspec/wiki#rspec
2018-05-21 18:03:28 +01: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
Ryan Ringler
69b72e66de Add use_parent_strategy option for building associations (#961)
This change means that:

1. The option is turned on, and
2. A Post has a User (for example), and
3. We build an association
4. Then the User is built too.

With the flag off, the User would be created, which matches current
behaviour.

See: https://github.com/thoughtbot/factory_girl/pull/749
2016-12-16 05:28:09 -05:00
Joshua Clayton
b095f24598 Convert to expect syntax 2013-01-18 13:58:36 -05:00
Joshua Clayton
6c29b11477 Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
Joshua Clayton
791591bd58 Deprecate :method in favor of :strategy 2012-02-17 14:23:17 -05:00
Simone Carletti
4b6ada72cf Ensure the yielded value is returned when block is given.
In the following example, `FactoryGirl.create(:order)` returns 0 because the last expression returns 0.
`:order` is set to 0 causing an unexpected behavior.

    let(:order) {
      FactoryGirl.create(:order) do |order|
        order.save!
        order.total_cents = 0
      end
    }

    order
    # => 0
2011-12-30 01:20:47 -05:00
Justin Ko
f32651d9b2 Calling the syntax methods with a block yields the return object. Closes #210 2011-10-14 09:39:39 -04:00
Jim Kingdon
90374818a7 Now able to specify :method => :build in a factory's association.
See issue #64.
2011-08-25 15:11:01 -04:00
Joshua Clayton
0b2c4da0a4 Move DefineConstant code into macro 2011-08-19 17:21:54 -04:00
Joshua Clayton
4d8d419375 Don't require a block to be passed when defining a factory 2011-06-29 14:43:20 -04:00
Joe Ferris
6c2322a11d New default syntax for using defined factories 2011-01-26 20:44:24 -05:00
Joe Ferris
2d1c77984b Split up the acceptance spec; removed the acceptance model fixtures in favor of fresh definitions in each spec 2010-11-12 14:58:25 -06:00