Skip to content

Commit

Permalink
rubocop fixes and regen to do
Browse files Browse the repository at this point in the history
  • Loading branch information
peaky76 committed Jan 15, 2024
1 parent 8028d5b commit 46f1120
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-09-26 09:04:51 UTC using RuboCop version 1.56.3.
# on 2024-01-15 19:01:58 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -15,3 +15,9 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 17

# Offense count: 6
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/lib/utils/bump_spec.rb'
1 change: 0 additions & 1 deletion lib/utils/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Bump
VERSION_KEY = /(?:^|\.|\s|"|')(?:base|version)["']*/
VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze


def initialize(config, level)
@config = config
@level = level
Expand Down
57 changes: 44 additions & 13 deletions spec/lib/utils/bump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@
let(:commit) { double('commit') }

before do
allow(config).to receive(:payload).and_return(payload)
allow(config).to receive(:client).and_return(client)
allow(config).to receive(:version_file_path).and_return(version_file_path)
allow(config).to receive(:other_version_file_paths).and_return(other_version_file_paths)
allow(Content).to receive(:new).with(config: config, ref: 'base_branch', path: version_file_path).and_return(content)
allow(Content).to receive(:new).with(config: config, ref: 'head_branch', path: version_file_path).and_return(content)
allow(config).to receive_messages(
payload: payload, client: client, version_file_path: version_file_path,
other_version_file_paths: other_version_file_paths
)
allow(Content).to receive(:new).with(
config: config, ref: 'base_branch',
path: version_file_path
).and_return(content)
allow(Content).to receive(:new).with(
config: config, ref: 'head_branch',
path: version_file_path
).and_return(content)
allow(content).to receive(:content).and_return('version: 1.0.0')
allow(content).to receive(:content=)
allow(client).to receive(:pull_request).with('owner/repo', 123).and_return({ 'head' => { 'ref' => 'head_branch' }, 'base' => { 'ref' => 'base_branch' } })
allow(client).to receive(:pull_request).with(
'owner/repo',
123
).and_return({
'head' => { 'ref' => 'head_branch' },
'base' => { 'ref' => 'base_branch' }
})
allow(Semantic::Version).to receive(:new).and_return(double('version'))
allow(double('version')).to receive(:increment!)
allow(Commit).to receive(:new).with(config).and_return(commit)
Expand All @@ -30,21 +42,40 @@
describe '#bump_everything' do
it 'bumps the version and commits the changes' do
bump = Bump.new(config, level)
expect(Content).to receive(:new).with(config: config, ref: 'base_branch', path: version_file_path).and_return(content).ordered
expect(Content).to receive(:new).with(config: config, ref: 'head_branch', path: version_file_path).and_return(content).ordered
expect(Content).to receive(:new).with(
config: config, ref: 'base_branch',
path: version_file_path
).and_return(content).ordered
expect(Content).to receive(:new).with(
config: config, ref: 'head_branch',
path: version_file_path
).and_return(content).ordered
expect(content).to receive(:content).and_return('version: 1.0.0').ordered
expect(content).to receive(:content=).with('version: 1.0.1').ordered
expect(commit).to receive(:multiple_files).with([{ path: version_file_path, mode: '100644', type: 'blob', content: 'version: 1.0.1' }], 'Bump patch version')
expect(commit).to receive(:multiple_files).with(
[{ path: version_file_path, mode: '100644', type: 'blob', content: 'version: 1.0.1' }], 'Bump patch version'
)
bump.bump_everything
end

it 'skips updating if the desired version bump is already present' do
bump = Bump.new(config, level)
expect(Content).to receive(:new).with(config: config, ref: 'base_branch', path: version_file_path).and_return(content).ordered
expect(Content).to receive(:new).with(config: config, ref: 'head_branch', path: version_file_path).and_return(content).ordered
expect(Content).to receive(:new).with(
config: config, ref: 'base_branch',
path: version_file_path
).and_return(content).ordered
expect(Content).to receive(:new).with(
config: config, ref: 'head_branch',
path: version_file_path
).and_return(content).ordered
expect(content).to receive(:content).and_return('version: 1.0.1').ordered
expect(commit).not_to receive(:multiple_files)
expect { bump.bump_everything }.to output("::notice title=Nothing to update::The desired version bump is already present for: path/to/version/file\n").to_stdout
expect do
bump.bump_everything
end.to output(
"::notice title=Nothing to update::The desired version bump is already present for:" \
"path/to/version/file\n"
).to_stdout
end
end
end

0 comments on commit 46f1120

Please sign in to comment.