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
23da356d
Commit
23da356d
authored
Aug 23, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor BeSuccessMatcher specs
parent
e1b8b932
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
36 deletions
+25
-36
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
+25
-36
No files found.
spec/rubocop/cop/rspec/be_success_matcher_spec.rb
View file @
23da356d
...
@@ -10,10 +10,16 @@ require_relative '../../../../rubocop/cop/rspec/be_success_matcher'
...
@@ -10,10 +10,16 @@ require_relative '../../../../rubocop/cop/rspec/be_success_matcher'
describe
RuboCop
::
Cop
::
RSpec
::
BeSuccessMatcher
do
describe
RuboCop
::
Cop
::
RSpec
::
BeSuccessMatcher
do
include
CopHelper
include
CopHelper
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
=
%(expect(response).to be_success)
.
freeze
CODE_EXAMPLES
=
[
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
=
%(is_expected.to be_success)
.
freeze
{
CALL_EXPECT_TO_BE_SUCCESSFUL
=
%(expect(response).to be_successful)
.
freeze
bad:
%(expect(response).to be_success)
.
freeze
,
CALL_IS_EXPECTED_TO_BE_SUCCESSFUL
=
%(is_expected.to be_successful)
.
freeze
good:
%(expect(response).to be_successful)
.
freeze
},
{
bad:
%(is_expected.to be_success)
.
freeze
,
good:
%(is_expected.to be_successful)
.
freeze
}
]
let
(
:source_file
)
{
'spec/foo_spec.rb'
}
let
(
:source_file
)
{
'spec/foo_spec.rb'
}
...
@@ -42,47 +48,30 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
...
@@ -42,47 +48,30 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
allow
(
cop
).
to
receive
(
:in_controller_spec?
).
and_return
(
true
)
allow
(
cop
).
to
receive
(
:in_controller_spec?
).
and_return
(
true
)
end
end
context
'using expect(response).to be_success call'
do
CODE_EXAMPLES
.
each
do
|
code_example
|
it_behaves_like
'an offensive be_success call'
,
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
context
"using
#{
code_example
[
:bad
]
}
call"
do
it_behaves_like
'an autocorrected be_success call'
,
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
,
CALL_EXPECT_TO_BE_SUCCESSFUL
it_behaves_like
'an offensive be_success call'
,
code_example
[
:bad
]
end
it_behaves_like
'an autocorrected be_success call'
,
code_example
[
:bad
],
code_example
[
:good
]
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 autocorrected be_success call'
,
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
,
CALL_IS_EXPECTED_TO_BE_SUCCESSFUL
end
context
'using expect(response).to be_successful'
do
it
"does not register an offense"
do
inspect_source
(
CALL_EXPECT_TO_BE_SUCCESSFUL
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
end
end
end
context
'using is_expected.to be_successful'
do
context
"using
#{
code_example
[
:good
]
}
call"
do
it
'does not register an offense'
do
it
"does not register an offense"
do
inspect_source
(
CALL_IS_EXPECTED_TO_BE_SUCCESSFUL
)
inspect_source
(
code_example
[
:good
]
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
end
end
end
end
end
end
end
context
'outside of a controller spec file'
do
context
'outside of a controller spec file'
do
context
'using expect(response).to be_success call'
do
CODE_EXAMPLES
.
each
do
|
code_example
|
it
'does not register an offense'
do
context
"using
#{
code_example
[
:bad
]
}
call"
do
inspect_source
(
OFFENSE_CALL_EXPECT_TO_BE_SUCCESS
)
it
'does not register an offense'
do
inspect_source
(
code_example
[
:bad
])
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
end
end
context
'using is_expected.to be_success call'
do
it
'does not register an offense'
do
inspect_source
(
OFFENSE_CALL_IS_EXPECTED_TO_BE_SUCCESS
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
0
)
end
end
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