From 5a9928c18a54c3f82c696d027fc70adcb8f0691d Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Wed, 21 Oct 2015 23:13:42 +0200 Subject: [PATCH] Introduce ParserError exception class --- lib/github_changelog_generator/parser_file.rb | 4 +++- spec/unit/parse_file_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index b8a77e2..df92814 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -1,4 +1,6 @@ module GitHubChangelogGenerator + ParserError = Class.new(StandardError) + class ParserFile def initialize(options) @options = options @@ -22,7 +24,7 @@ module GitHubChangelogGenerator value = false if value =~ (/^(false|f|no|n|0)$/i) @options[key_sym] = value rescue - raise "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" + raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" end # Returns a the setting as a symbol and its string value sans newlines. diff --git a/spec/unit/parse_file_spec.rb b/spec/unit/parse_file_spec.rb index eb8af0c..6c59f78 100644 --- a/spec/unit/parse_file_spec.rb +++ b/spec/unit/parse_file_spec.rb @@ -20,7 +20,7 @@ describe GitHubChangelogGenerator::ParserFile do let(:options) { { params_file: "spec/files/github_changelog_params_incorrect" } } let(:options_before_change) { options.dup } let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) } - it { expect { parse.parse! }.to raise_error } + it { expect { parse.parse! }.to raise_error(GitHubChangelogGenerator::ParserError) } end context "when override default values" do