summaryrefslogtreecommitdiff
path: root/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb
blob: 8add32b88f9c048850cd02d701cca71c2297bc82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

require_relative "compact_index"

Artifice.deactivate

class CompactIndexWrongGemChecksum < CompactIndexAPI
  get "/info/:name" do
    etag_response do
      name = params[:name]
      gem = gems.find {|g| g.name == name }
      checksum = ENV.fetch("BUNDLER_SPEC_#{name.upcase}_CHECKSUM") { "ab" * 22 }
      versions = gem ? gem.versions : []
      versions.each {|v| v.checksum = checksum }
      CompactIndex.info(versions)
    end
  end
end

Artifice.activate_with(CompactIndexWrongGemChecksum)