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
eb6bccb3e3 Avoid time travel in tests
By being a little bit less strict in our assertions, we can still
prove the behaviour is correct, without having to freeze / travel time.
2019-08-01 11:21:06 +01:00
Daniel Colson
6078d8c486 Improve error message for resolving invalid traits
Fixes [#1259]
Fixes [#1267]

In [#1156] we added support for looking up local traits with either a
symbol or string. This matches the lookup for factories and for global
traits.

We were calling `to_sym` on the trait arguments passed in when
building an object, assuming that those arguments would always respond
to `to_sym`. This leads to a confusing error message when passing an
object that doesn't respond to that method.

This PR replaces the confusing "NoMethodError: undefined method `to_sym`
for ..." with a more helpful "KeyError: Trait not registered: ...". It
ensures that all trait resolution is done using strings instead of
symbols, all objects should have a `to_s` method.

Co-authored-by: Sean Doyle <sean.p.doyle24@gmail.com>

[#1259]: https://github.com/thoughtbot/factory_bot/issues/1259
[#1267]: https://github.com/thoughtbot/factory_bot/issues/1267
[#1156]: https://github.com/thoughtbot/factory_bot/pull/1156
2019-02-22 16:08:38 -05:00
Susan Wright
c22c9ab052 Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
Hunter Braun
89ee4a4524 [Rubocop] Style Cop Offenses (#1208) 2018-10-07 18:02:54 -04:00
Daniel Colson
0473865b93 Remove static attributes
Co-authored-by: George Wambold <georgewambold@gmail.com>
2018-09-14 19:27:13 +00: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
Andrew Mason
95188e2e78 Switches mocking library to rspec 2017-07-14 17:25:47 +01:00
Cédric Boutillier
4a4a0b90f2 Upgrade RSpec and other testing gems 2016-02-07 00:14:25 -05:00
Potapov Sergey
664c426bd0 Fix memory leak: do not add trait duplications to @defined_traits
Closes #588
2013-12-13 15:12:48 -05:00
Joshua Clayton
330eed801b Update dependency on RSpec 2012-08-02 09:54:48 -04:00
Joshua Clayton
dcae83724a Use newer matcher API to get suite green 2012-04-06 21:03:17 -04:00
Gabe Berke-Williams
b63e3896fc Remove unnecessary call to #should. 2012-02-07 23:06:59 -05:00
Joshua Clayton
3114dcd935 Wrap up DeclarationList
DeclarationList knows how to generate an attribute
list, which never really made sense outside of being generated from
declarations. Now, the declaration list builds a list of attributes
which is combined in Factory#attributes with attributes from traits and
its parents.
2011-10-31 19:05:34 -04:00
Joshua Clayton
41bc3ac5ff Add FactoryGirl::Definition
Both Factory and Trait have similar methods and interact with a
DefinitionProxy. The idea here is to move the interface DefinitionProxy
expects to a separate class and both Factory and Trait can delegate to
an instance of Definition.
2011-10-30 23:17:03 -04:00
Joshua Clayton
6e9baa767f Maintain abstraction consistency within definition_proxy 2011-10-14 22:50:37 -04:00
Joshua Clayton
180eb8bec7 Refactor definition_proxy_spec
This introduces a couple of things: firstly, there's now a MockFactory
that allows for introspection instead of spying all over the place. This
should make tests a lot less brittle. Secondly, a couple of handy
matchers have been made available to perform assertions against the
mock.
2011-10-14 17:21:29 -04:00