Sha256: 081d122fe2eda81a442c94654d7b87c272ddb4cecd4c5b4675f83b2a5012e374
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true require 'rubocop-rspec' module Gitlab module Styles module Rubocop module Cop module RSpec # Checks if there is an empty line after shared example blocks. # # @example # # bad # RSpec.describe Foo do # it_behaves_like 'do this first' # it_behaves_like 'does this' do # end # it_behaves_like 'does that' do # end # it_behaves_like 'do some more' # end # # # good # RSpec.describe Foo do # it_behaves_like 'do this first' # it_behaves_like 'does this' do # end # # it_behaves_like 'does that' do # end # # it_behaves_like 'do some more' # end # # # fair - it's ok to have non-separated without blocks # RSpec.describe Foo do # it_behaves_like 'do this first' # it_behaves_like 'does this' # end # class EmptyLineAfterSharedExample < RuboCop::Cop::RSpec::Cop include RuboCop::RSpec::BlankLineSeparation MSG = 'Add an empty line after `%<example>s` block.' def_node_matcher :shared_examples, (SharedGroups::ALL + Includes::ALL).block_pattern def on_block(node) shared_examples(node) do break if last_child?(node) missing_separating_line(node) do |location| add_offense(node, location: location, message: format(MSG, example: node.method_name)) end end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitlab-styles-4.3.0 | lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb |
gitlab-styles-4.2.0 | lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb |