1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_bot
Daniel Colson 1d6170af2b Add option for verbose linting
This has come up a few times, and I can see why it might be helpful to
have access to full backtraces when debugging a factory error uncovered
by `FactoryBot.lint`. But since most of the time I don't want the extra
noise from the backtrace, I added this as a verbose option.

The default message is still:

```
The following factories are invalid:
* user - undefined method `save!' for #<User:0x00007ff0cbc89100>
* admin - undefined method `save!' for #<User:0x00007ff0cbc73e40>
```

And with the verbose option (usually with more lines of backtrace):

```
The following factories are invalid:
* user - undefined method `save!' for #<User:0x00007ff0cbc89100>
  /Users/.../thoughtbot/factory_bot/lib/factory_bot/evaluation.rb:18:in `create'
  /Users/.../factory_bot/lib/factory_bot/strategy/create.rb:12:in `block in result'

* admin - undefined method `save!' for #<User:0x00007ff0cbc73e40>
  /Users/.../thoughtbot/factory_bot/lib/factory_bot/evaluation.rb:18:in `create'
  /Users/.../factory_bot/lib/factory_bot/strategy/create.rb:12:in `block in result'
```

I moved the linting option defaults out of the FactoryBot.lint method
and into keyword argument defaults in Linter#initialize. This seems a
bit cleaner, and now we will get an error if we pass an option we don't
understand (before 6e511597 we had a test that passed in a bogus
option)

Closes #710
Closes #1124

I am opening a new PR since the original PR is years old and it seemed
unkind to request changes after so long. Instead I will list the authors
as co-authors.

Co-authored-by: Jack Kinsella <jack.kinsella@gmail.com>
Co-authored-by: Jasper Woudenberg <mail@jasperwoudenberg.com>
2018-11-27 12:04:38 -05:00
..
attribute Remove static attributes 2018-09-14 19:27:13 +00:00
declaration Raise more meaningful error for unregistered trait 2018-10-31 12:50:39 -04:00
decorator Inline disabling Style/MethodMissing Cop 2018-11-12 15:01:23 -08:00
strategy Set timestamps before clearing changes 2018-11-12 17:35:05 -05:00
syntax [Rubocop] Lint Cop Offenses (#1207) 2018-10-05 14:54:08 -04:00
aliases.rb [Rubocop] Style Cop Offenses (#1208) 2018-10-07 18:02:54 -04:00
attribute.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
attribute_assigner.rb Avoid recursive call to AttributeHash#attributes 2018-10-26 10:51:05 -04:00
attribute_list.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
callback.rb Fix assorted RuboCop spacing volations (#1203) 2018-09-27 21:35:05 -04:00
callbacks_observer.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
configuration.rb Remove deprecated factory lookup by class (#1212) 2018-10-12 16:59:02 -04:00
declaration.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
declaration_list.rb [Rubocop] Style Cop Offenses (#1208) 2018-10-07 18:02:54 -04:00
decorator.rb Inline disabling Style/MethodMissing Cop 2018-11-12 15:01:23 -08:00
definition.rb Fix assorted RuboCop spacing volations (#1203) 2018-09-27 21:35:05 -04:00
definition_hierarchy.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
definition_proxy.rb Improve documentation around implicit attributes 2018-11-25 22:16:22 -05:00
errors.rb Raise helpful error block given to association 2018-10-28 19:12:34 -04:00
evaluation.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
evaluator.rb Inline disabling Style/MethodMissing Cop 2018-11-12 15:01:23 -08:00
evaluator_class_definer.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
factory.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
factory_runner.rb Fixed problem when name of the trait was not a symbol 2018-11-25 17:28:12 -05:00
find_definitions.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
linter.rb Add option for verbose linting 2018-11-27 12:04:38 -05:00
null_factory.rb Fix assorted RuboCop spacing volations (#1203) 2018-09-27 21:35:05 -04:00
null_object.rb [Rubocop] Lint Cop Offenses (#1207) 2018-10-05 14:54:08 -04:00
registry.rb Remove deprecated factory lookup by class (#1212) 2018-10-12 16:59:02 -04:00
reload.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
sequence.rb Fix assorted RuboCop spacing volations (#1203) 2018-09-27 21:35:05 -04:00
strategy_calculator.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
strategy_syntax_method_registrar.rb [Rubocop] Performance Cop Offenses (#1209) 2018-10-04 21:07:56 -04:00
syntax.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
syntax_runner.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
trait.rb Fixed problem when name of the trait was not a symbol 2018-11-25 17:28:12 -05:00
version.rb Bump version to 4.11.1 [ci skip] 2018-09-07 15:58:10 -04:00