From a3425771423cd8b114db0aef11359aa0c966690d Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 13 Sep 2024 17:29:19 +0200 Subject: [PATCH] Fix RSpec/UnspecifiedException RuboCop offenses --- spec/reek/examiner_spec.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/reek/examiner_spec.rb b/spec/reek/examiner_spec.rb index 68941c38c..d59523556 100644 --- a/spec/reek/examiner_spec.rb +++ b/spec/reek/examiner_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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