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
5e2b317f
Commit
5e2b317f
authored
Oct 31, 2019
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplication between replacement methods
parent
6f9ec100
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
12 deletions
+5
-12
rubocop/cop/rspec/any_instance_of.rb
rubocop/cop/rspec/any_instance_of.rb
+5
-12
No files found.
rubocop/cop/rspec/any_instance_of.rb
View file @
5e2b317f
...
@@ -49,9 +49,9 @@ module RuboCop
...
@@ -49,9 +49,9 @@ module RuboCop
def
autocorrect
(
node
)
def
autocorrect
(
node
)
if
expect_any_instance_of?
(
node
)
if
expect_any_instance_of?
(
node
)
replacement
=
replacement_
expect_any_instance_of
(
node
)
replacement
=
replacement_
any_instance_of
(
node
,
'expect'
)
elsif
allow_any_instance_of?
(
node
)
elsif
allow_any_instance_of?
(
node
)
replacement
=
replacement_a
llow_any_instance_of
(
node
)
replacement
=
replacement_a
ny_instance_of
(
node
,
'allow'
)
end
end
lambda
do
|
corrector
|
lambda
do
|
corrector
|
...
@@ -61,17 +61,10 @@ module RuboCop
...
@@ -61,17 +61,10 @@ module RuboCop
private
private
def
replacement_
expect_any_instance_of
(
node
)
def
replacement_
any_instance_of
(
node
,
rspec_prefix
)
replacement
=
node
.
receiver
.
source
.
sub
(
'expect_any_instance_of'
,
'expect_next_instance_of'
)
replacement
=
node
.
receiver
.
source
.
sub
(
"
#{
rspec_prefix
}
_any_instance_of"
,
"
#{
rspec_prefix
}
_next_instance_of"
)
replacement
<<
" do |instance|
\n
"
replacement
<<
" do |instance|
\n
"
replacement
<<
" expect(instance).
#{
node
.
method_name
}
#{
node
.
children
.
last
.
source
}
\n
"
replacement
<<
"
#{
rspec_prefix
}
(instance).
#{
node
.
method_name
}
#{
node
.
children
.
last
.
source
}
\n
"
replacement
<<
'end'
end
def
replacement_allow_any_instance_of
(
node
)
replacement
=
node
.
receiver
.
source
.
sub
(
'allow_any_instance_of'
,
'allow_next_instance_of'
)
replacement
<<
" do |instance|
\n
"
replacement
<<
" allow(instance).
#{
node
.
method_name
}
#{
node
.
children
.
last
.
source
}
\n
"
replacement
<<
'end'
replacement
<<
'end'
end
end
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