Class: RuboCop::Cop::RSpec::ImplicitExpect
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/implicit_expect.rb
Overview
Check that a consistent implicit expectation style is used.
This cop can be configured using the ‘EnforcedStyle` option and supports the `–auto-gen-config` flag.
Constant Summary collapse
- MSG =
'Prefer `%<good>s` over `%<bad>s`.'.freeze
- ENFORCED_REPLACEMENTS =
alternatives.merge(alternatives.invert).freeze
Constants inherited from Cop
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#autocorrect(node) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/rubocop/cop/rspec/implicit_expect.rb', line 61 def autocorrect(node) lambda do |corrector| offense = offending_expect(node) replacement = replacement_source(offense.source) corrector.replace(offense, replacement) end end |
#on_send(node) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/rspec/implicit_expect.rb', line 47 def on_send(node) return unless (source_range = offending_expect(node)) expectation_source = source_range.source if expectation_source.start_with?(style.to_s) correct_style_detected else opposite_style_detected add_offense(node, source_range, (expectation_source)) end end |