Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RSpec/UnspecifiedException RuboCop offenses #1790

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions spec/reek/examiner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
it 'explains the origin of the error' do
origin = 'string'
expect { examiner.smells }.
to raise_error.with_message("Source #{origin} cannot be processed by Reek.")
to raise_error(Reek::Errors::IncomprehensibleSourceError).
with_message("Source #{origin} cannot be processed by Reek.")
end

it 'explains what to do' do
Expand Down Expand Up @@ -214,7 +215,7 @@

it 'explains the origin of the error' do
message = "Source 'string' cannot be processed by Reek due to a syntax error in the source file."
expect { examiner.smells }.to raise_error.with_message(/#{message}/)
expect { examiner.smells }.to raise_error(Reek::Errors::SyntaxError).with_message(/#{message}/)
end

it 'shows the original exception class' do
Expand Down Expand Up @@ -242,7 +243,7 @@

it 'explains the origin of the error' do
message = "Source 'string' cannot be processed by Reek due to an encoding error in the source file."
expect { examiner.smells }.to raise_error.with_message(/#{message}/)
expect { examiner.smells }.to raise_error(Reek::Errors::EncodingError).with_message(/#{message}/)
end

it 'shows the original exception class' do
Expand All @@ -269,14 +270,16 @@ def alfa; end
it 'explains the reason for the error' do
message = "You are trying to configure an unknown smell detector 'DoesNotExist'"

expect { examiner.smells }.to raise_error.with_message(/#{message}/)
expect { examiner.smells }.
to raise_error(Reek::Errors::BadDetectorInCommentError).with_message(/#{message}/)
end

it 'explains the origin of the error' do
details = "The source is 'string' and the comment belongs " \
'to the expression starting in line 2.'

expect { examiner.smells }.to raise_error.with_message(/#{details}/)
expect { examiner.smells }.
to raise_error(Reek::Errors::BadDetectorInCommentError).with_message(/#{details}/)
end
end

Expand All @@ -295,14 +298,18 @@ def alfa; end
it 'explains the reason for the error' do
message = "Error: You are trying to configure the smell detector 'UncommunicativeMethodName'"

expect { examiner.smells }.to raise_error.with_message(/#{message}/)
expect { examiner.smells }.
to raise_error(Reek::Errors::GarbageDetectorConfigurationInCommentError).
with_message(/#{message}/)
end

it 'explains the origin of the error' do
details = "The source is 'string' and the comment belongs " \
'to the expression starting in line 2.'

expect { examiner.smells }.to raise_error.with_message(/#{details}/)
expect { examiner.smells }.
to raise_error(Reek::Errors::GarbageDetectorConfigurationInCommentError).
with_message(/#{details}/)
end
end
end
Expand Down