Skip to content

Commit

Permalink
Fix RSpec/UnspecifiedException RuboCop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Sep 13, 2024
1 parent 50311e9 commit a342577
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit a342577

Please # to comment.