File: catalogue_cache_spec.rb

package info (click to toggle)
ruby-rspec-puppet 4.0.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,444 kB
  • sloc: ruby: 6,377; makefile: 6
file content (85 lines) | stat: -rw-r--r-- 1,823 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true

require 'spec_helper'

describe 'test::bare_class' do
  describe 'cache between adjacent examples' do
    catalogue_id = nil

    it 'records the initial catalogue ID' do
      catalogue_id = catalogue.object_id
    end

    it 'contains the same catalogue ID' do
      expect(catalogue.object_id).to eq(catalogue_id)
    end
  end

  describe 'cache multiple catalogues' do
    catalogue_ids = {}

    (1..10).each do |i|
      context "iteration #{i}" do
        let(:facts) do
          { 'iteration' => i }
        end

        it 'records the initial catalogue ID' do
          catalogue_ids[i] = catalogue.object_id
        end
      end
    end

    (1..10).each do |i|
      context "iteration #{i}" do
        let(:facts) do
          { 'iteration' => i }
        end

        it 'contains the same catalogue ID' do
          expect(catalogue.object_id).to eq(catalogue_ids[i])
        end
      end
    end
  end

  describe 'limits number of cached catalogues' do
    catalogue_ids = {}

    (1..20).each do |i|
      context "iteration #{i}" do
        let(:facts) do
          { 'iteration' => i }
        end

        it 'records the initial catalogue ID' do
          catalogue_ids[i] = catalogue.object_id
        end
      end
    end

    (1..4).each do |i|
      context "iteration #{i}" do
        let(:facts) do
          { 'iteration' => i }
        end

        it 'receives a new catalogue ID' do
          expect(catalogue.object_id).not_to eq(catalogue_ids[i])
        end
      end
    end

    (9..20).each do |i|
      context "iteration #{i}" do
        let(:facts) do
          { 'iteration' => i }
        end

        it 'contains the same catalogue ID' do
          expect(catalogue.object_id).to eq(catalogue_ids[i])
        end
      end
    end
  end
end