Skip to content

Commit

Permalink
Have rubocop -V output rubocop-ast's version
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed May 13, 2020
1 parent ee0c2c9 commit eefaa52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rubocop/version.rb
Expand Up @@ -5,12 +5,14 @@ module RuboCop
module Version
STRING = '0.83.0'

MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
'%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'
MSG = '%<version>s (using Parser %<parser_version>s, '\
'rubocop-ast %<rubocop_ast_version>s, ' \
'running on %<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'

def self.version(debug = false)
if debug
format(MSG, version: STRING, parser_version: Parser::VERSION,
rubocop_ast_version: RuboCop::AST::Version::STRING,
ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
ruby_platform: RUBY_PLATFORM)
else
Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/cli/cli_options_spec.rb
Expand Up @@ -148,6 +148,15 @@
end
end

describe '-V' do
it 'exits cleanly' do
expect(cli.run(['-V'])).to eq(0)
expect($stdout.string).to include(RuboCop::Version::STRING)
expect($stdout.string).to match(/Parser \d\.\d\.\d/)
expect($stdout.string).to match(/rubocop-ast \d\.\d\.\d/)
end
end

describe '--only' do
context 'when one cop is given' do
it 'runs just one cop' do
Expand Down

0 comments on commit eefaa52

Please sign in to comment.