Commit Graph

6 Commits

Author SHA1 Message Date
Richie Thomas a40b555cb0
Refactory registry_spec.rb to conform to Let's Not style (#1349) 2019-10-23 14:15:53 -07:00
Daniel Colson 3a4d6f489c
Remove problematic did_you_mean spec
I had thought did_you_mean for KeyErrors was available in Ruby 2.3 and
higher, but this spec seems to be failing for Ruby 2.3 and 2.4.
Since we have OK coverage of the custom KeyError message behavior
elsewhere, I don't think this test is essential.
2018-12-16 22:48:06 -05:00
Christian Bruckmayer b86ec136b6
Raise KeyError instead of ArgumentError in Registry
to make use of did_you_mean gem.

The did_you_mean gem only supports NameError, NoMethodError
and KeyError. However, for NameError the message does also need
to match a certain format and we can not use a custom message
like 'Factory not registered ...'. Therefore using KeyError
is to only logical conclusion.

The did_you_mean gem makes use of the receiver attributes, but
in Ruby > 2.5 it is not possible to set the receiver and key attributes
on a KeyError (they are only set when the KeyError is raised in C).
We explored monkey patching KeyError for earlier versions of Ruby, but
it was a problematic solution.

Instead we can rescue the original KeyError, take the message from it,
which will already include the did_you_mean message, then customize
the message and re-raise a new KeyError with that customized message.
Starting in Ruby 2.6 this will not be necessary anymore
https://bugs.ruby-lang.org/issues/14313, so maybe we can get rid of it
for FactoryBot 6 or 7.

Fixes #992

Co-authored-by: Daniel Colson <danieljamescolson@gmail.com>
2018-12-16 22:25:04 -05:00
Daniel Colson 7925c47653 Remove remaining RuboCop TODOs
Closes #1202

We have fixed the bulk of the RuboCop TODOs. The main TODO remaining
(line length) involves a large number of files,
and I don't think it is worth trying to update them all at once. I did
fix a few of the worst offenders so we could bring the max down a bit.
We can gradually bring this number down as we fix more of the
violations.
2018-10-21 12:15:32 -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