Commit 3a71ab52 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Autocorrect `be_success` to `be_successful`

parent 4f2ac516
......@@ -44,6 +44,12 @@ module RuboCop
add_offense(node, location: :expression, message: MESSAGE)
end
def autocorrect(node)
lambda do |corrector|
corrector.insert_after(node.loc.expression, "ful")
end
end
end
end
end
......
......@@ -27,6 +27,14 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher do
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
before do
allow(cop).to receive(:in_controller_spec?).and_return(true)
......@@ -34,10 +42,12 @@ describe RuboCop::Cop::RSpec::BeSuccessMatcher 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 autocorrected be_success call', OFFENSE_CALL_EXPECT_TO_BE_SUCCESS, CALL_EXPECT_TO_BE_SUCCESSFUL
end
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment