|
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 | + |
| 30 | + context 'with default parameters' do |
| 31 | + it { is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') } |
| 32 | + 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') } |
| 33 | + end |
| 34 | + |
| 35 | + describe 'when ensure' do |
| 36 | + context 'is absent' do |
| 37 | + let :params do |
| 38 | + { |
| 39 | + ensure: 'absent' |
| 40 | + } |
| 41 | + end |
| 42 | + |
| 43 | + it { |
| 44 | + expect(subject).to contain_file('/opt/env').with_ensure('absent').with_purge(true) |
| 45 | + } |
| 46 | + end |
| 47 | + end |
23 | 48 | end |
24 | 49 |
|
25 | | - describe 'when ensure' do |
26 | | - context 'is absent' do |
| 50 | + context "prompt on #{os} with python 3.6" do |
| 51 | + let :facts do |
| 52 | + # python 3.6 is required for venv and prompt |
| 53 | + facts.merge( |
| 54 | + python3_version: '3.6.1' |
| 55 | + ) |
| 56 | + end |
| 57 | + let :title do |
| 58 | + '/opt/env' |
| 59 | + end |
| 60 | + |
| 61 | + context 'with prompt' do |
27 | 62 | let :params do |
28 | 63 | { |
29 | | - ensure: 'absent' |
| 64 | + prompt: 'custom prompt', |
30 | 65 | } |
31 | 66 | end |
32 | 67 |
|
33 | 68 | it { |
34 | | - expect(subject).to contain_file('/opt/env').with_ensure('absent').with_purge(true) |
| 69 | + is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
| 70 | + 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 | 71 | } |
36 | 72 | end |
37 | 73 | end |
38 | | - end |
39 | 74 |
|
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 | | - |
51 | | - context 'with prompt' do |
52 | | - let :params do |
53 | | - { |
54 | | - prompt: 'custom prompt', |
55 | | - } |
| 75 | + context "prompt on #{os} with python 3.5" do |
| 76 | + let :facts do |
| 77 | + facts.merge( |
| 78 | + python3_version: '3.5.1' |
| 79 | + ) |
| 80 | + end |
| 81 | + let :title do |
| 82 | + '/opt/env' |
56 | 83 | end |
57 | 84 |
|
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 |
| 85 | + context 'with prompt' do |
| 86 | + let :params do |
| 87 | + { |
| 88 | + prompt: 'custom prompt', |
| 89 | + } |
| 90 | + end |
74 | 91 |
|
75 | | - context 'with prompt' do |
76 | | - let :params do |
77 | | - { |
78 | | - prompt: 'custom prompt', |
| 92 | + it { |
| 93 | + is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') |
| 94 | + 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 | 95 | } |
80 | 96 | 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 | 97 | end |
87 | 98 | end |
88 | 99 | end |
|
0 commit comments