|
37 | 37 | ) |
38 | 38 | end |
39 | 39 | let(:dependencies) { [dependency] } |
40 | | - let(:dependency_files) { [buildfile] } |
| 40 | + let(:dependency_files) { [buildfile, wrapper_file] } |
41 | 41 | let(:updater) do |
42 | 42 | described_class.new( |
43 | 43 | dependency_files: dependency_files, |
|
51 | 51 | ) |
52 | 52 | end |
53 | 53 |
|
| 54 | + let(:wrapper_file) do |
| 55 | + Dependabot::DependencyFile.new( |
| 56 | + name: "gradle/wrapper/gradle-wrapper.properties", |
| 57 | + content: fixture( |
| 58 | + "wrapper_files", |
| 59 | + "gradle-wrapper-8.14.2-bin.properties" |
| 60 | + ) |
| 61 | + ) |
| 62 | + end |
| 63 | + |
54 | 64 | it_behaves_like "a dependency file updater" |
55 | 65 |
|
56 | 66 | describe "#updated_dependency_files" do |
57 | 67 | subject(:updated_files) { updater.updated_dependency_files } |
58 | 68 |
|
| 69 | + before do |
| 70 | + allow(Dependabot::SharedHelpers).to receive(:run_shell_command) do |command, _| |
| 71 | + raise "Unexpected shell command: #{command}" |
| 72 | + end |
| 73 | + |
| 74 | + Dependabot::Experiments.register(:gradle_wrapper_updater, true) |
| 75 | + Dependabot::Experiments.register(:gradle_lockfile_updater, true) |
| 76 | + end |
| 77 | + |
| 78 | + after do |
| 79 | + Dependabot::Experiments.reset! |
| 80 | + end |
| 81 | + |
59 | 82 | it "returns DependencyFile objects" do |
60 | 83 | updated_files.each { |f| expect(f).to be_a(Dependabot::DependencyFile) } |
61 | 84 | end |
|
634 | 657 | end |
635 | 658 |
|
636 | 659 | let(:buildfile) do |
| 660 | + wrapper_file |
| 661 | + end |
| 662 | + |
| 663 | + let(:wrapper_file) do |
637 | 664 | Dependabot::DependencyFile.new( |
638 | 665 | name: "gradle/wrapper/gradle-wrapper.properties", |
639 | 666 | content: fixture( |
|
684 | 711 | ) |
685 | 712 | end |
686 | 713 |
|
| 714 | + before do |
| 715 | + allow(Dependabot::SharedHelpers).to receive(:run_shell_command) |
| 716 | + end |
| 717 | + |
687 | 718 | its(:content) do |
| 719 | + expected_command = "gradle --no-daemon --stacktrace wrapper --no-validate-url --gradle-version 9.0.0" |
| 720 | + |
688 | 721 | is_expected.to include( |
689 | 722 | "distributionUrl=https\\://services.gradle.org/distributions/gradle-9.0.0-#{type}.zip" |
690 | 723 | ) |
691 | 724 |
|
692 | 725 | if checksum |
| 726 | + expected_command += " --gradle-distribution-sha256-sum #{updated_checksum}" |
693 | 727 | is_expected.to include("distributionSha256Sum=#{updated_checksum}") |
694 | 728 | else |
695 | 729 | is_expected.not_to include("distributionSha256Sum=") |
696 | 730 | end |
| 731 | + |
| 732 | + expect(Dependabot::SharedHelpers).to have_received(:run_shell_command).with(expected_command, cwd: anything) |
697 | 733 | end |
698 | 734 | end |
699 | 735 |
|
|
0 commit comments