Skip to content

Commit 6682e03

Browse files
Add test as well.
Signed-off-by: Gavin Didrichsen <[email protected]>
1 parent 6cdccbc commit 6682e03

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

spec/support/puppetcore_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
require 'bundler'
5+
6+
RSpec.describe 'Gemfile.lock verification' do
7+
let(:parser) { Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)) }
8+
let(:private_source) { 'https://rubygems-puppetcore.puppet.com/' }
9+
10+
# Helper method to get source remotes for a specific gem
11+
def get_gem_source_remotes(gem_name)
12+
spec = parser.specs.find { |s| s.name == gem_name }
13+
return [] unless spec
14+
15+
source = spec.source
16+
return [] unless source.is_a?(Bundler::Source::Rubygems)
17+
18+
source.remotes.map(&:to_s)
19+
end
20+
21+
context 'when the environment is configured with a valid PUPPET_FORGE_TOKEN' do
22+
it 'returns puppet from puppetcore' do
23+
remotes = get_gem_source_remotes('puppet')
24+
expect(remotes).to eq([private_source]),
25+
"Expected puppet to come from puppetcore, got: #{remotes.join(', ')}"
26+
end
27+
28+
it 'returns facter from puppetcore' do
29+
remotes = get_gem_source_remotes('facter')
30+
expect(remotes).to eq([private_source]),
31+
"Expected facter to come from puppetcore, got: #{remotes.join(', ')}"
32+
end
33+
34+
it 'has PUPPET_FORGE_TOKEN set' do
35+
expect(ENV.fetch('PUPPET_FORGE_TOKEN', nil)).not_to be_nil,
36+
'Expected PUPPET_FORGE_TOKEN to be set'
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)