summaryrefslogtreecommitdiff
path: root/spec/hosts/with_lens_spec.rb
blob: 10437c95a50cf55dc46513b4e68474d6dfb208aa (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
57
58
59
60
61
62
63
64
65
66
require 'spec_helper'

describe 'with_lens' do
  let (:facts) { {
    :osfamily => 'RedHat',
    :path                => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  } }

  context 'when lens_source is passed' do
    let (:facts) { {
      :osfamily           => 'RedHat',
      :augeas_lens_source => '/tmp/foo.aug',
      :augeas_stock_since => :undef,
      :augeas_test_source => :undef,
      :path               => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    } }

    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',
      :augeas_stock_since => :undef,
      :path               => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    } }

    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',
      :augeas_test_source => :undef,
      :path               => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    } }

    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',
      :augeas_test_source => :undef,
      :path               => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    } }

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