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
17385f4d
Commit
17385f4d
authored
Aug 26, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor BeSuccessMatcher specs for readability
parent
99b27e69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
34 deletions
+34
-34
.rubocop.yml
.rubocop.yml
+1
-0
rubocop/cop/rspec/be_success_matcher.rb
rubocop/cop/rspec/be_success_matcher.rb
+1
-1
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
+32
-33
No files found.
.rubocop.yml
View file @
17385f4d
...
...
@@ -273,3 +273,4 @@ RSpec/BeSuccessMatcher:
-
'
spec/support/shared_examples/controllers/**/*'
-
'
ee/spec/support/shared_examples/controllers/**/*'
-
'
spec/support/controllers/**/*'
-
'
ee/spec/support/controllers/**/*'
rubocop/cop/rspec/be_success_matcher.rb
View file @
17385f4d
...
...
@@ -26,7 +26,7 @@ module RuboCop
class
BeSuccessMatcher
<
RuboCop
::
Cop
::
Cop
include
SpecHelpers
MESSAGE
=
'Do not use deprecated `success?` method, use `successful?` instead.'
.
freeze
MESSAGE
=
'Do not use deprecated `success?` method, use `successful?` instead.'
def_node_search
:expect_to_be_success?
,
<<~
PATTERN
(send (send nil? :expect (send nil? ...)) {:to :not_to :to_not} (send nil? :be_success))
...
...
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
View file @
17385f4d
...
...
@@ -10,33 +10,6 @@ require_relative '../../../../rubocop/cop/rspec/be_success_matcher'
describe
RuboCop
::
Cop
::
RSpec
::
BeSuccessMatcher
do
include
CopHelper
CODE_EXAMPLES
=
[
{
bad:
%(expect(response).to be_success)
.
freeze
,
good:
%(expect(response).to be_successful)
.
freeze
},
{
bad:
%(expect(response).to_not be_success)
.
freeze
,
good:
%(expect(response).to_not be_successful)
.
freeze
},
{
bad:
%(expect(response).not_to be_success)
.
freeze
,
good:
%(expect(response).not_to be_successful)
.
freeze
},
{
bad:
%(is_expected.to be_success)
.
freeze
,
good:
%(is_expected.to be_successful)
.
freeze
},
{
bad:
%(is_expected.to_not be_success)
.
freeze
,
good:
%(is_expected.to_not be_successful)
.
freeze
},
{
bad:
%(is_expected.not_to be_success)
.
freeze
,
good:
%(is_expected.not_to be_successful)
.
freeze
}
].
freeze
let
(
:source_file
)
{
'spec/foo_spec.rb'
}
subject
(
:cop
)
{
described_class
.
new
}
...
...
@@ -59,18 +32,44 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
end
end
CODE_EXAMPLES
.
each
do
|
code_example
|
context
"using
#{
code_example
[
:bad
]
}
call"
do
it_behaves_like
'an offensive be_success call'
,
code_example
[
:bad
]
it_behaves_like
'an autocorrected be_success call'
,
code_example
[
:bad
],
code_example
[
:good
]
shared_examples
'cop'
do
|
good
:,
bad
:
|
context
"using
#{
bad
}
call"
do
it_behaves_like
'an offensive be_success call'
,
bad
it_behaves_like
'an autocorrected be_success call'
,
bad
,
good
end
context
"using
#{
code_example
[
:good
]
}
call"
do
context
"using
#{
good
}
call"
do
it
'does not register an offense'
do
inspect_source
(
code_example
[
:good
]
)
inspect_source
(
good
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
end
end
end
describe
'using different code examples'
do
it_behaves_like
'cop'
,
bad:
'expect(response).to be_success'
,
good:
'expect(response).to be_successful'
it_behaves_like
'cop'
,
bad:
'expect(response).to_not be_success'
,
good:
'expect(response).to_not be_successful'
it_behaves_like
'cop'
,
bad:
'expect(response).not_to be_success'
,
good:
'expect(response).not_to be_successful'
it_behaves_like
'cop'
,
bad:
'is_expected.to be_success'
,
good:
'is_expected.to be_successful'
it_behaves_like
'cop'
,
bad:
'is_expected.to_not be_success'
,
good:
'is_expected.to_not be_successful'
it_behaves_like
'cop'
,
bad:
'is_expected.not_to be_success'
,
good:
'is_expected.not_to be_successful'
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