Skip to content

Commit a0999a4

Browse files
authored
FIX acceptance tests (#246)
Acceptance tests were failing as soon as a new gem version was released.
1 parent f422925 commit a0999a4

File tree

9 files changed

+653
-143705
lines changed

9 files changed

+653
-143705
lines changed

.github/workflows/ruby.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Ruby
1+
name: 💎 Ruby
22

33
on: push
44

@@ -17,9 +17,7 @@ jobs:
1717
ruby-version: ${{ matrix.ruby }}
1818
bundler-cache: true # 'bundle install' and cache gems
1919
- name: Run tests
20-
# Exclude acceptance specs as github action fails due to:
21-
# It is a security vulnerability to allow your home directory to be world-writable, and bundler cannot continue.
22-
run: bundle exec rspec --exclude-pattern "spec/acceptance/**/*_spec.rb"
20+
run: bundle exec rspec --format progress
2321

2422
- name: Report coverage
2523
uses: codacy/codacy-coverage-reporter-action@v1

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# master (unreleased)
22

3+
Fix:
4+
5+
* acceptance tests
6+
37
# v8.0.0 (June 21, 2025)
48

59
Deprecated:

spec/acceptance/Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source 'https://rubygems.org'
44

5-
gem 'activesupport'
6-
gem 'regexp_parser'
7-
gem 'rubocop'
5+
gem 'activesupport', '7.0.0'
6+
gem 'regexp_parser', '2.6.1'
7+
gem 'rubocop', '1.38.0'
File renamed without changes.

spec/acceptance/Gemfile.lock.initial

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (7.0.0)
5+
concurrent-ruby (~> 1.0, >= 1.0.2)
6+
i18n (>= 1.6, < 2)
7+
minitest (>= 5.1)
8+
tzinfo (~> 2.0)
9+
ast (2.4.2)
10+
concurrent-ruby (1.2.2)
11+
i18n (1.14.1)
12+
concurrent-ruby (~> 1.0)
13+
json (2.6.3)
14+
minitest (5.20.0)
15+
parallel (1.23.0)
16+
parser (3.2.2.3)
17+
ast (~> 2.4.1)
18+
racc
19+
racc (1.7.1)
20+
rainbow (3.1.1)
21+
regexp_parser (2.6.1)
22+
rexml (3.2.6)
23+
rubocop (1.38.0)
24+
json (~> 2.3)
25+
parallel (~> 1.10)
26+
parser (>= 3.1.2.1)
27+
rainbow (>= 2.2.2, < 4.0)
28+
regexp_parser (>= 1.8, < 3.0)
29+
rexml (>= 3.2.5, < 4.0)
30+
rubocop-ast (>= 1.23.0, < 2.0)
31+
ruby-progressbar (~> 1.7)
32+
unicode-display_width (>= 1.4.0, < 3.0)
33+
rubocop-ast (1.29.0)
34+
parser (>= 3.2.1.0)
35+
ruby-progressbar (1.13.0)
36+
tzinfo (2.0.6)
37+
concurrent-ruby (~> 1.0)
38+
unicode-display_width (2.4.2)
39+
40+
PLATFORMS
41+
x86_64-linux
42+
43+
DEPENDENCIES
44+
activesupport (= 7.0.0)
45+
regexp_parser (= 2.6.1)
46+
rubocop (= 1.38.0)
47+
48+
BUNDLED WITH
49+
2.4.19

spec/acceptance/Gemfile.lock.updated

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (8.0.2)
5+
concurrent-ruby (~> 1.0, >= 1.0.2)
6+
i18n (>= 1.6, < 2)
7+
minitest (>= 5.1)
8+
tzinfo (~> 2.0)
9+
ast (2.4.3)
10+
concurrent-ruby (1.3.5)
11+
i18n (1.14.7)
12+
concurrent-ruby (~> 1.0)
13+
json (2.12.0)
14+
minitest (5.25.5)
15+
parallel (1.27.0)
16+
parser (3.3.8.0)
17+
ast (~> 2.4.1)
18+
racc
19+
racc (1.8.1)
20+
rainbow (3.1.1)
21+
regexp_parser (2.10.0)
22+
rexml (3.2.6)
23+
rubocop (1.75.6)
24+
json (~> 2.3)
25+
parallel (~> 1.10)
26+
parser (>= 3.1.2.1)
27+
rainbow (>= 2.2.2, < 4.0)
28+
regexp_parser (>= 1.8, < 3.0)
29+
rexml (>= 3.2.5, < 4.0)
30+
rubocop-ast (>= 1.23.0, < 2.0)
31+
ruby-progressbar (~> 1.7)
32+
unicode-display_width (>= 1.4.0, < 3.0)
33+
rubocop-ast (1.44.1)
34+
parser (>= 3.2.1.0)
35+
ruby-progressbar (1.13.0)
36+
tzinfo (2.0.6)
37+
concurrent-ruby (~> 1.0)
38+
unicode-display_width (3.1.4)
39+
40+
PLATFORMS
41+
x86_64-linux
42+
43+
DEPENDENCIES
44+
activesupport (= 7.0.0)
45+
regexp_parser (= 2.6.1)
46+
rubocop (= 1.38.0)
47+
48+
BUNDLED WITH
49+
2.4.19

spec/acceptance/gem_update_spec.rb

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
RSpec.describe GemUpdater do
66
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
715

816
after { `git restore spec/acceptance/Gemfile.lock` }
917

@@ -38,7 +46,7 @@
3846
[changelog](https://github.com/ammar/regexp_parser/blob/master/CHANGELOG.md#2100---2024-12-25---janosch-müller)
3947
4048
* 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)
4250
4351
* rubocop-ast 1.29.0 → 1.44.1
4452
[changelog](https://github.com/rubocop/rubocop-ast/blob/master/CHANGELOG.md#1441-2025-04-11)
@@ -49,9 +57,45 @@
4957
OUTPUT
5058
end
5159

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
5564
expect { updater.output_diff }.to output(diff).to_stdout
5665
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
57101
end

0 commit comments

Comments
 (0)