Class: RuboCop::Cop::HGOOSTDD::NoMocksInAcceptance
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::HGOOSTDD::NoMocksInAcceptance
- Defined in:
- lib/rubocop/cop/hgoostdd/no_mocks_in_acceptance.rb
Overview
Acceptance specs exercise the real Rails stack with fakes only at the adapter seam. They must not mock or stub. Inner-loop unit specs can use mocks; acceptance specs cannot. See HGOOSTDD §2.
Constant Summary collapse
- MSG =
"Acceptance specs must not use `%{call}`; swap fakes via the adapter registry instead (§2)."- MOCK_BUILDERS =
%i[instance_double class_double object_double].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/hgoostdd/no_mocks_in_acceptance.rb', line 24 def on_send(node) if (m = mock_builder?(node)) add_offense(node, message: format(MSG, call: m)) elsif allow_call?(node) add_offense(node, message: format(MSG, call: :allow)) elsif receive_chain?(node) add_offense(node, message: format(MSG, call: "expect(...).to receive")) end end |