|
6 | 6 | on_supported_os.each do |os, facts|
|
7 | 7 | next if os == 'gentoo-3-x86_64'
|
8 | 8 |
|
| 9 | + let :title do |
| 10 | + '/opt/env' |
| 11 | + end |
| 12 | + |
9 | 13 | context "on #{os}" do
|
10 |
| - let :facts do |
11 |
| - # python3 is required to use pyvenv |
12 |
| - facts.merge( |
13 |
| - python3_version: '3.5.1' |
14 |
| - ) |
15 |
| - end |
16 |
| - let :title do |
17 |
| - '/opt/env' |
| 14 | + context "with default parameters" do |
| 15 | + let :facts do |
| 16 | + facts |
| 17 | + end |
| 18 | + |
| 19 | + it { is_expected.to compile } |
18 | 20 | end
|
19 | 21 |
|
20 |
| - context 'with default parameters' do |
21 |
| - it { is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') } |
22 |
| - it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') } |
| 22 | + context "with a specific python3 version" do |
| 23 | + let :facts do |
| 24 | + # python3 is required to use pyvenv |
| 25 | + facts.merge( |
| 26 | + python3_version: '3.5.1' |
| 27 | + ) |
| 28 | + end |
| 29 | + context 'with default parameters' do |
| 30 | + it { is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') } |
| 31 | + it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') } |
| 32 | + end |
| 33 | + |
| 34 | + describe 'when ensure' do |
| 35 | + context 'is absent' do |
| 36 | + let :params do |
| 37 | + { |
| 38 | + ensure: 'absent' |
| 39 | + } |
| 40 | + end |
| 41 | + |
| 42 | + it { |
| 43 | + expect(subject).to contain_file('/opt/env').with_ensure('absent').with_purge(true) |
| 44 | + } |
| 45 | + end |
| 46 | + end |
23 | 47 | end
|
24 | 48 |
|
25 |
| - describe 'when ensure' do |
26 |
| - context 'is absent' do |
| 49 | + context "prompt on #{os} with python 3.6" do |
| 50 | + let :facts do |
| 51 | + # python 3.6 is required for venv and prompt |
| 52 | + facts.merge( |
| 53 | + python3_version: '3.6.1' |
| 54 | + ) |
| 55 | + end |
| 56 | + let :title do |
| 57 | + '/opt/env' |
| 58 | + end |
| 59 | + |
| 60 | + context 'with prompt' do |
27 | 61 | let :params do
|
28 | 62 | {
|
29 |
| - ensure: 'absent' |
| 63 | + prompt: 'custom prompt', |
30 | 64 | }
|
31 | 65 | end
|
32 | 66 |
|
33 | 67 | it {
|
34 |
| - expect(subject).to contain_file('/opt/env').with_ensure('absent').with_purge(true) |
| 68 | + is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
| 69 | + is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('python3.6 -m venv --clear --prompt custom\\ prompt /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') |
35 | 70 | }
|
36 | 71 | end
|
37 | 72 | end
|
38 |
| - end |
39 |
| - |
40 |
| - context "prompt on #{os} with python 3.6" do |
41 |
| - let :facts do |
42 |
| - # python 3.6 is required for venv and prompt |
43 |
| - facts.merge( |
44 |
| - python3_version: '3.6.1' |
45 |
| - ) |
46 |
| - end |
47 |
| - let :title do |
48 |
| - '/opt/env' |
49 |
| - end |
50 | 73 |
|
51 |
| - context 'with prompt' do |
52 |
| - let :params do |
53 |
| - { |
54 |
| - prompt: 'custom prompt', |
55 |
| - } |
| 74 | + context "prompt on #{os} with python 3.5" do |
| 75 | + let :facts do |
| 76 | + facts.merge( |
| 77 | + python3_version: '3.5.1' |
| 78 | + ) |
| 79 | + end |
| 80 | + let :title do |
| 81 | + '/opt/env' |
56 | 82 | end
|
57 | 83 |
|
58 |
| - it { |
59 |
| - is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
60 |
| - is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('python3.6 -m venv --clear --prompt custom\\ prompt /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') |
61 |
| - } |
62 |
| - end |
63 |
| - end |
64 |
| - |
65 |
| - context "prompt on #{os} with python 3.5" do |
66 |
| - let :facts do |
67 |
| - facts.merge( |
68 |
| - python3_version: '3.5.1' |
69 |
| - ) |
70 |
| - end |
71 |
| - let :title do |
72 |
| - '/opt/env' |
73 |
| - end |
| 84 | + context 'with prompt' do |
| 85 | + let :params do |
| 86 | + { |
| 87 | + prompt: 'custom prompt', |
| 88 | + } |
| 89 | + end |
74 | 90 |
|
75 |
| - context 'with prompt' do |
76 |
| - let :params do |
77 |
| - { |
78 |
| - prompt: 'custom prompt', |
| 91 | + it { |
| 92 | + is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
| 93 | + is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') |
79 | 94 | }
|
80 | 95 | end
|
81 |
| - |
82 |
| - it { |
83 |
| - is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
84 |
| - is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') |
85 |
| - } |
86 | 96 | end
|
87 | 97 | end
|
88 | 98 | end
|
|
0 commit comments