|
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)
|
|
49 | 57 | OUTPUT
|
50 | 58 | end
|
51 | 59 |
|
52 |
| - it 'outputs changelogs', |
53 |
| - vcr: { cassette_name: 'acceptance', record: :new_episodes } do |
54 |
| - updater.update!(['--gemfile=spec/acceptance/Gemfile']) |
| 60 | + it 'outputs changelogs', vcr: { cassette_name: 'acceptance' } do |
| 61 | + Dir.chdir('spec/acceptance') do |
| 62 | + updater.update!(['--gemfile=Gemfile']) |
| 63 | + end |
55 | 64 | expect { updater.output_diff }.to output(diff).to_stdout
|
56 | 65 | end
|
| 66 | + |
| 67 | + private |
| 68 | + |
| 69 | + def setup_test_files |
| 70 | + FileUtils.cp('spec/acceptance/Gemfile.initial', 'spec/acceptance/Gemfile') |
| 71 | + File.write('spec/acceptance/Gemfile.lock', initial_lock_content) |
| 72 | + end |
| 73 | + |
| 74 | + def mock_gemfile_operations |
| 75 | + allow(GemUpdater::Gemfile).to receive(:new).and_wrap_original do |method| |
| 76 | + gemfile_instance = method.call |
| 77 | + |
| 78 | + allow(gemfile_instance).to receive(:update!) { Bundler.ui.warn 'Updating gems...' } |
| 79 | + allow(gemfile_instance).to receive(:spec_sets_diff!) { |
| 80 | + simulate_bundle_update(gemfile_instance) |
| 81 | + } |
| 82 | + |
| 83 | + gemfile_instance |
| 84 | + end |
| 85 | + end |
| 86 | + |
| 87 | + def parse_lock_file(filename) |
| 88 | + lock_content = File.read(filename) |
| 89 | + definition = Bundler::LockfileParser.new(lock_content) |
| 90 | + definition.specs |
| 91 | + end |
| 92 | + |
| 93 | + def simulate_bundle_update(gemfile_instance) |
| 94 | + old_specs = parse_lock_file('Gemfile.lock') |
| 95 | + File.write('Gemfile.lock', updated_lock_content) |
| 96 | + new_specs = parse_lock_file('Gemfile.lock') |
| 97 | + |
| 98 | + gemfile_instance.instance_variable_set(:@old_spec_set, old_specs) |
| 99 | + gemfile_instance.instance_variable_set(:@new_spec_set, new_specs) |
| 100 | + end |
57 | 101 | end
|
0 commit comments