class RuboCop::Cop::RSpec::EmptyLineAfterHook
it { does_something }
after { do_something }
around { |test| test.run }
# good
it { does_something }
after { do_something }
around { |test| test.run }
# bad
# AllowConsecutiveOneLiners: false
# RSpec/EmptyLineAfterHook:
# rubocop.yml
@example with AllowConsecutiveOneLiners configuration
it { does_something }
after { do_something }
around { |test| test.run }
# fair - it’s ok to have non-separated one-liners hooks
it { does_something }
after { do_something }
# good
it { does_something }
around { |test| test.run }
# bad
it { does_something }
after { do_something }
# bad
it { does_something }
before { do_something }
# bad
@example
one-line definitions are considered an offense.
‘AllowConsecutiveOneLiners` configures whether adjacent
Checks if there is an empty line after hook blocks.
def chained_single_line_hooks?(node)
def chained_single_line_hooks?(node) next_node = node.right_sibling hook?(next_node) && node.single_line? && next_node.single_line? end
def on_block(node)
def on_block(node) return unless hook?(node) return if cop_config['AllowConsecutiveOneLiners'] && chained_single_line_hooks?(node) missing_separating_line_offense(node) do |method| format(MSG, hook: method) end end