Skip to content

Commit

Permalink
Merge pull request #7897 from tejasbubane/generator-version-added
Browse files Browse the repository at this point in the history
Allow Generator to take version_added parameter
  • Loading branch information
koic committed May 9, 2020
2 parents 75542a8 + 9459cb6 commit bea4bf1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rubocop/cop/generator.rb
Expand Up @@ -132,11 +132,12 @@ def inject_require(root_file_path: 'lib/rubocop.rb')
).inject
end

def inject_config(config_file_path: 'config/default.yml')
def inject_config(config_file_path: 'config/default.yml',
version_added: bump_minor_version)
injector =
ConfigurationInjector.new(configuration_file_path: config_file_path,
badge: badge,
version_added: bump_minor_version)
version_added: version_added)

injector.inject do
output.puts(format(CONFIGURATION_ADDED_MESSAGE,
Expand Down
22 changes: 22 additions & 0 deletions spec/rubocop/cop/generator_spec.rb
Expand Up @@ -280,6 +280,28 @@ def on_send(node)
"#{path}.\n")
end
end

context 'with version provided' do
it 'uses the provided version' do
expect(File).to receive(:write).with(path, <<~YAML)
Style/Alias:
Enabled: true
Style/FakeCop:
Description: 'TODO: Write a description of the cop.'
Enabled: pending
VersionAdded: '1.52'
Style/Lambda:
Enabled: true
Style/SpecialGlobalVars:
Enabled: true
YAML

generator.inject_config(config_file_path: path, version_added: '1.52')
end
end
end

describe '#snake_case' do
Expand Down

0 comments on commit bea4bf1

Please sign in to comment.