Skip to content

Commit

Permalink
Improve error message for invalid parser_engine value
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Mar 8, 2024
1 parent 2514755 commit 6e46cdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/ast/processed_source.rb
Expand Up @@ -29,7 +29,7 @@ def self.from_file(path, ruby_version, parser_engine: :parser_whitequark)
def initialize(source, ruby_version, path = nil, parser_engine: :parser_whitequark)
unless PARSER_ENGINES.include?(parser_engine)
raise ArgumentError, 'The keyword argument `parser_engine` accepts ' \
"`parser` or `parser_prism`, but `#{parser_engine}` was passed."
"`:parser_whitequark` or `:parser_prism`, but `#{parser_engine.inspect}` was passed."
end

# Defaults source encoding to UTF-8, regardless of the encoding it has
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/ast/processed_source_spec.rb
Expand Up @@ -33,8 +33,8 @@ def some_method

it 'raises a Errno::ENOENT when the file does not exist' do
expect { processed_source }.to raise_error(ArgumentError) do |e|
expect(e.message).to eq 'The keyword argument `parser_engine` accepts `parser` or ' \
'`parser_prism`, but `unknown_parser_engine` was passed.'
expect(e.message).to eq 'The keyword argument `parser_engine` accepts `:parser_whitequark` or ' \
'`:parser_prism`, but `:unknown_parser_engine` was passed.'
end
end
end
Expand Down

0 comments on commit 6e46cdc

Please sign in to comment.