File: version_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (61 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "spec_helper"
require "puppet/version"
require 'pathname'

describe "Puppet.version Public API" do
  before :each do
    @current_ver = Puppet.version
    Puppet.instance_eval do
      if @puppet_version
        @puppet_version = nil
      end
    end
  end

  after :each do
    Puppet.version = @current_ver
  end

  context "without a VERSION file" do
    before :each do
      allow(Puppet).to receive(:read_version_file).and_return(nil)
    end

    it "is Puppet::PUPPETVERSION" do
      expect(Puppet.version).to eq(Puppet::PUPPETVERSION)
    end

    it "respects the version= setter" do
      Puppet.version = '1.2.3'
      expect(Puppet.version).to eq('1.2.3')
      expect(Puppet.minor_version).to eq('1.2')
    end
  end

  context "with a VERSION file" do
    it "is the content of the file" do
      expect(Puppet).to receive(:read_version_file) do |path|
        pathname = Pathname.new(path)
        pathname.basename.to_s == "VERSION"
      end.and_return('3.0.1-260-g9ca4e54')

      expect(Puppet.version).to eq('3.0.1-260-g9ca4e54')
      expect(Puppet.minor_version).to eq('3.0')
    end

    it "respects the version= setter" do
      Puppet.version = '1.2.3'
      expect(Puppet.version).to eq('1.2.3')
      expect(Puppet.minor_version).to eq('1.2')
    end
  end

  context "Using version setter" do
    it "does not read VERSION file if using set version" do
      expect(Puppet).not_to receive(:read_version_file)
      Puppet.version = '1.2.3'
      expect(Puppet.version).to eq('1.2.3')
      expect(Puppet.minor_version).to eq('1.2')
    end
  end
end