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
3a71ab52
Commit
3a71ab52
authored
Aug 22, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autocorrect `be_success` to `be_successful`
parent
4f2ac516
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
rubocop/cop/rspec/be_success_matcher.rb
rubocop/cop/rspec/be_success_matcher.rb
+6
-0
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
+10
-0
No files found.
rubocop/cop/rspec/be_success_matcher.rb
View file @
3a71ab52
...
@@ -44,6 +44,12 @@ module RuboCop
...
@@ -44,6 +44,12 @@ module RuboCop
add_offense
(
node
,
location: :expression
,
message:
MESSAGE
)
add_offense
(
node
,
location: :expression
,
message:
MESSAGE
)
end
end
def
autocorrect
(
node
)
lambda
do
|
corrector
|
corrector
.
insert_after
(
node
.
loc
.
expression
,
"ful"
)
end
end
end
end
end
end
end
end
...
...
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
View file @
3a71ab52
...
@@ -27,6 +27,14 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
...
@@ -27,6 +27,14 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
end
end
end
end
shared_examples
'an autocorrected be_success call'
do
|
content
,
autocorrected_content
|
it
"registers an offense for `
#{
content
}
` and autocorrects it to `
#{
autocorrected_content
}
`"
do
autocorrected
=
autocorrect_source
(
content
,
source_file
)
expect
(
autocorrected
).
to
eql
(
autocorrected_content
)
end
end
context
'in a controller spec file'
do
context
'in a controller spec file'
do
before
do
before
do
allow
(
cop
).
to
receive
(
:in_controller_spec?
).
and_return
(
true
)
allow
(
cop
).
to
receive
(
:in_controller_spec?
).
and_return
(
true
)
...
@@ -34,10 +42,12 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
...
@@ -34,10 +42,12 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
context
"using expect(response).to be_success call"
do
context
"using expect(response).to be_success call"
do
it_behaves_like
'an offensive be_success call'
,
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
it_behaves_like
'an offensive be_success call'
,
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
it_behaves_like
'an autocorrected be_success call'
,
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
,
CALL_EXPECT_TO_BE_SUCCESSFUL
end
end
context
"using is_expected.to be_success call"
do
context
"using is_expected.to be_success call"
do
it_behaves_like
'an offensive be_success call'
,
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
it_behaves_like
'an offensive be_success call'
,
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
it_behaves_like
'an autocorrected be_success call'
,
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
,
CALL_IS_EXPECTED_TO_BE_SUCCESSFUL
end
end
context
"using expect(response).to be_successful"
do
context
"using expect(response).to be_successful"
do
...
...
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