summaryrefslogtreecommitdiff
path: root/spec/hosts/with_lens_spec.rb
blob: d7a5249129a79d9ebe51fdfc3db9718aa6b30cc8 (plain)
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
require 'spec_helper'

describe 'with_lens' do
  let (:facts) { {
    :osfamily => 'RedHat',
  } }

  context 'when lens_source is passed' do
    let (:facts) { {
      :osfamily           => 'RedHat',
      :augeas_lens_source => '/tmp/foo.aug',
    } }

    it { should contain_file('/usr/share/augeas/lenses/foo.aug') }
    it { should contain_exec('Typecheck lens foo') }
    it { should_not contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') }
    it { should_not contain_exec('Test lens foo') }
  end

  context 'when lens_source and test_source are passed' do
    let (:facts) { {
      :osfamily           => 'RedHat',
      :augeas_lens_source => '/tmp/foo.aug',
      :augeas_test_source => '/tmp/test_foo.aug',
    } }

    it { should contain_file('/usr/share/augeas/lenses/foo.aug') }
    it { should contain_exec('Typecheck lens foo') }
    it { should contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') }
    it { should contain_exec('Test lens foo') }
  end

  context 'when stock_since is passed and augeas is older' do
    let (:facts) { {
      :osfamily           => 'RedHat',
      :augeas_lens_source => '/tmp/foo.aug',
      :augeas_stock_since => '1.2.3',
      :augeasversion      => '1.0.0',
    } }

    it { should contain_file('/usr/share/augeas/lenses/foo.aug') }
    it { should contain_exec('Typecheck lens foo') }
  end

  context 'when stock_since is passed and augeas is newer' do
    let (:facts) { {
      :osfamily           => 'RedHat',
      :augeas_lens_source => '/tmp/foo.aug',
      :augeas_stock_since => '1.2.3',
      :augeasversion      => '1.5.0',
    } }

    it { should_not contain_file('/usr/share/augeas/lenses/foo.aug') }
    it { should_not contain_exec('Typecheck lens foo') }
  end
end