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

6 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
Sweta
5ccc564923
Fix self referencing trait error (#1294)
If a new trait is defined with attributes,  check if attributes matches the name of
the trait. Raise an error if so, to avoid a recursive call to the
trait.

Co-authored-by: Daniel Colsen <daniel.j.colson@thoughtbot.com>
Co-authored-by: Paras Sanghavi <sanghaviparas@gmail.com>
2019-09-10 16:24:20 -07: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
pacop
f4ad4f0c87
Fixed problem when name of the trait was not a symbol 2018-11-25 17:28:12 -05:00
Colin Ross
a56b68bc9c Fix assorted RuboCop spacing volations (#1203)
* Alphabetize gem listing in various Gemfiles [Rubocop Bundler/OrderedGems]

* Fix alignment of if/else/end statement [Rubocop Layout/ElseAlignment]

* Method definitions should have a empty line between them [Rubocop Layout/EmptyLineBetweenDefs]

* Modules, Classes, and blocks should have an empty line around them [Rubocop]

Cops:
Layout/EmptyLinesAroundBlockBody
Layout/EmptyLinesAroundModuleBody
Layout/EmptyLinesAroundClassBody
Layout/EmptyLinesAroundAccessModifier

* Keep a blank line before and after access modifiers [Rubocop Layout/EmptyLinesAroundAccessModifier]

* Remove misc extra whitespace [Rubocop Layout/ExtraSpacing]

* Indent the first line of the right-hand-side of a multi-line assignment [Rubocop Layout/IndentAssignment]

* Remove extraneous whitespace [Rubocop]

Cops:
  Layout/IndentationWidth
  Layout/LeadingCommentSpace
  Layout/SpaceAroundEqualsInParameterDefault
  Layout/SpaceInsideArrayLiteralBrackets
  Layout/SpaceInsideBlockBraces
  Layout/SpaceInsideParens
  Layout/TrailingBlankLines

* Revert rubocop changes to gemfiles; exclude files from rubocop checks

The files in gemfiles/ are generated by Appraisal, so we shouldn't edit them. Instead, let's tell RuboCop to exclude this directory.
2018-09-27 21:35:05 -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
Renamed from lib/factory_girl/trait.rb (Browse further)