Class: RuboCop::Cop::HGOOSTDD::NoTimecopInDomainSpecs
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::HGOOSTDD::NoTimecopInDomainSpecs
- Defined in:
- lib/rubocop/cop/hgoostdd/no_timecop_in_domain_specs.rb
Overview
‘Timecop`, `travel_to`, `travel_back`, and `freeze_time` are acceptable in acceptance specs (which exercise the real Rails stack) but not in inner-loop domain specs — inject a clock fake instead. See HGOOSTDD §6.
Constant Summary collapse
- MSG =
"Use a FakeClock instead of `%{call}` in domain specs (§6)."- TRAVEL_METHODS =
%i[travel_to travel_back freeze_time travel].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rubocop/cop/hgoostdd/no_timecop_in_domain_specs.rb', line 21 def on_send(node) if timecop_send?(node) add_offense(node, message: format(MSG, call: node.source)) elsif travel_call?(node) add_offense(node, message: format(MSG, call: node.method_name)) end end |