|
4 | 4 |
|
5 | 5 | RSpec.describe GemUpdater do
|
6 | 6 | let(:updater) { GemUpdater::Updater.new }
|
| 7 | + let(:acceptance_dir) { File.expand_path('spec/acceptance', "#{__dir__}/../..") } |
| 8 | + let(:initial_lock_content) { File.read(File.join(acceptance_dir, 'Gemfile.lock.initial')) } |
| 9 | + let(:updated_lock_content) { File.read(File.join(acceptance_dir, 'Gemfile.lock.updated')) } |
| 10 | + |
| 11 | + before do |
| 12 | + setup_test_files |
| 13 | + mock_gemfile_operations |
| 14 | + end |
7 | 15 |
|
8 | 16 | after { `git restore spec/acceptance/Gemfile.lock` }
|
9 | 17 |
|
|
38 | 46 | [changelog](https://github.com/ammar/regexp_parser/blob/master/CHANGELOG.md#2100---2024-12-25---janosch-müller)
|
39 | 47 |
|
40 | 48 | * rubocop 1.38.0 → 1.75.6
|
41 |
| - [changelog](https://github.com/rubocop/rubocop/releases/tag/v1.75.6) |
| 49 | + [changelog](https://github.com/rubocop/rubocop/releases/tag/v1.77.0) |
42 | 50 |
|
43 | 51 | * rubocop-ast 1.29.0 → 1.44.1
|
44 | 52 | [changelog](https://github.com/rubocop/rubocop-ast/blob/master/CHANGELOG.md#1441-2025-04-11)
|
|
50 | 58 | end
|
51 | 59 |
|
52 | 60 | it 'outputs changelogs',
|
53 |
| - vcr: { cassette_name: 'acceptance', record: :new_episodes } do |
54 |
| - updater.update!(['--gemfile=spec/acceptance/Gemfile']) |
| 61 | + vcr: { cassette_name: 'acceptance', record: :none } do |
| 62 | + Dir.chdir('spec/acceptance') do |
| 63 | + updater.update!(['--gemfile=Gemfile']) |
| 64 | + end |
55 | 65 | expect { updater.output_diff }.to output(diff).to_stdout
|
56 | 66 | end
|
| 67 | + |
| 68 | + private |
| 69 | + |
| 70 | + def setup_test_files |
| 71 | + FileUtils.cp('spec/acceptance/Gemfile.initial', 'spec/acceptance/Gemfile') |
| 72 | + File.write('spec/acceptance/Gemfile.lock', initial_lock_content) |
| 73 | + end |
| 74 | + |
| 75 | + def mock_gemfile_operations |
| 76 | + allow(GemUpdater::Gemfile).to receive(:new).and_wrap_original do |method| |
| 77 | + gemfile_instance = method.call |
| 78 | + |
| 79 | + allow(gemfile_instance).to receive(:update!) { Bundler.ui.warn 'Updating gems...' } |
| 80 | + allow(gemfile_instance).to receive(:spec_sets_diff!) { |
| 81 | + simulate_bundle_update(gemfile_instance) |
| 82 | + } |
| 83 | + |
| 84 | + gemfile_instance |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + def parse_lock_file(filename) |
| 89 | + lock_content = File.read(filename) |
| 90 | + definition = Bundler::LockfileParser.new(lock_content) |
| 91 | + definition.specs |
| 92 | + end |
| 93 | + |
| 94 | + def simulate_bundle_update(gemfile_instance) |
| 95 | + # Capture old specs, write updated lock, capture new specs |
| 96 | + old_specs = parse_lock_file('Gemfile.lock') |
| 97 | + File.write('Gemfile.lock', updated_lock_content) |
| 98 | + new_specs = parse_lock_file('Gemfile.lock') |
| 99 | + |
| 100 | + gemfile_instance.instance_variable_set(:@old_spec_set, old_specs) |
| 101 | + gemfile_instance.instance_variable_set(:@new_spec_set, new_specs) |
| 102 | + end |
57 | 103 | end
|
0 commit comments