Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
51ce7617
Commit
51ce7617
authored
Jun 01, 2020
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove local defined version of Cop
- in favor of upstreamed gitlab-styles version
parent
6d3f5100
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
150 deletions
+0
-150
rubocop/cop/rspec/empty_line_after_shared_example.rb
rubocop/cop/rspec/empty_line_after_shared_example.rb
+0
-64
spec/rubocop/cop/rspec/empty_line_after_shared_example_spec.rb
...rubocop/cop/rspec/empty_line_after_shared_example_spec.rb
+0
-86
No files found.
rubocop/cop/rspec/empty_line_after_shared_example.rb
deleted
100644 → 0
View file @
6d3f5100
# frozen_string_literal: true
require
'rubocop/rspec/final_end_location'
require
'rubocop/rspec/blank_line_separation'
require
'rubocop/rspec/language'
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
::
Cop
include
RuboCop
::
RSpec
::
BlankLineSeparation
include
RuboCop
::
RSpec
::
Language
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
spec/rubocop/cop/rspec/empty_line_after_shared_example_spec.rb
deleted
100644 → 0
View file @
6d3f5100
# frozen_string_literal: true
require
'spec_helper'
require_relative
'../../../../rubocop/cop/rspec/empty_line_after_shared_example'
describe
RuboCop
::
Cop
::
RSpec
::
EmptyLineAfterSharedExample
do
subject
(
:cop
)
{
described_class
.
new
}
it
'flags a missing empty line after `it_behaves_like` block'
do
expect_offense
(
<<-
RUBY
)
RSpec.describe Foo do
it_behaves_like 'does this' do
end
^^^ Add an empty line after `it_behaves_like` block.
it_behaves_like 'does that' do
end
end
RUBY
expect_correction
(
<<-
RUBY
)
RSpec.describe Foo do
it_behaves_like 'does this' do
end
it_behaves_like 'does that' do
end
end
RUBY
end
it
'ignores one-line shared examples before shared example blocks'
do
expect_no_offenses
(
<<-
RUBY
)
RSpec.describe Foo do
it_behaves_like 'does this'
it_behaves_like 'does that' do
end
end
RUBY
end
it
'flags a missing empty line after `shared_examples`'
do
expect_offense
(
<<-
RUBY
)
RSpec.context 'foo' do
shared_examples do
end
^^^ Add an empty line after `shared_examples` block.
shared_examples 'something gets done' do
end
end
RUBY
expect_correction
(
<<-
RUBY
)
RSpec.context 'foo' do
shared_examples do
end
shared_examples 'something gets done' do
end
end
RUBY
end
it
'ignores consecutive one-liners'
do
expect_no_offenses
(
<<-
RUBY
)
RSpec.describe Foo do
it_behaves_like 'do this'
it_behaves_like 'do that'
end
RUBY
end
it
'flags mixed one-line and multi-line shared examples'
do
expect_offense
(
<<-
RUBY
)
RSpec.context 'foo' do
it_behaves_like 'do this'
it_behaves_like 'do that'
it_behaves_like 'does this' do
end
^^^ Add an empty line after `it_behaves_like` block.
it_behaves_like 'do this'
it_behaves_like 'do that'
end
RUBY
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment