|
25 | 25 | end |
26 | 26 | end |
27 | 27 |
|
| 28 | + describe '#create_symlinks' do |
| 29 | + before(:each) do |
| 30 | + @described_object = described_class.allocate |
| 31 | + end |
| 32 | + |
| 33 | + context 'with --preserve-environmentss' do |
| 34 | + context 'with --create-symlinks' do |
| 35 | + it 'should install environment + custom symlinks' do |
| 36 | + @described_object.instance_variable_set( |
| 37 | + '@options', |
| 38 | + basedir: '/tmp/basedir', |
| 39 | + preserve_environments: true, |
| 40 | + create_symlinks: %w(foo bar) |
| 41 | + ) |
| 42 | + |
| 43 | + expect(@described_object) |
| 44 | + .to receive(:install_directory_symlink) |
| 45 | + .with(nil, '/tmp/basedir/environments', 'environments') |
| 46 | + |
| 47 | + expect(@described_object) |
| 48 | + .to receive(:install_directory_symlink) |
| 49 | + .with(nil, '/tmp/basedir/foo', 'foo') |
| 50 | + |
| 51 | + expect(@described_object) |
| 52 | + .to receive(:install_directory_symlink) |
| 53 | + .with(nil, '/tmp/basedir/bar', 'bar') |
| 54 | + |
| 55 | + expect { @described_object.send(:create_symlinks) }.not_to raise_error |
| 56 | + end |
| 57 | + end |
| 58 | + |
| 59 | + context 'without --create-symlinks' do |
| 60 | + it 'should install environment + default symlinks' do |
| 61 | + @described_object.instance_variable_set( |
| 62 | + '@options', |
| 63 | + basedir: '/tmp/basedir', |
| 64 | + preserve_environments: true |
| 65 | + ) |
| 66 | + |
| 67 | + expect(@described_object) |
| 68 | + .to receive(:install_directory_symlink) |
| 69 | + .with(nil, '/tmp/basedir/environments', 'environments') |
| 70 | + |
| 71 | + expect(@described_object) |
| 72 | + .to receive(:install_directory_symlink) |
| 73 | + .with(nil, '/tmp/basedir/manifests', 'manifests') |
| 74 | + |
| 75 | + expect(@described_object) |
| 76 | + .to receive(:install_directory_symlink) |
| 77 | + .with(nil, '/tmp/basedir/modules', 'modules') |
| 78 | + |
| 79 | + expect { @described_object.send(:create_symlinks) }.not_to raise_error |
| 80 | + end |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + context 'without --preserve-environmentss' do |
| 85 | + context 'with --create-symlinks' do |
| 86 | + context 'with logger' do |
| 87 | + it 'should log a warning message and install default symlink' do |
| 88 | + logger = double('Logger') |
| 89 | + expect(logger).to receive(:warn).with('--create-symlinks is ignored unless --preserve-environments is used') |
| 90 | + |
| 91 | + @described_object.instance_variable_set( |
| 92 | + '@options', |
| 93 | + basedir: '/tmp/basedir', |
| 94 | + create_symlinks: %w(foo bar) |
| 95 | + ) |
| 96 | + |
| 97 | + expect(@described_object) |
| 98 | + .to receive(:install_directory_symlink) |
| 99 | + .with(logger, '/tmp/basedir') |
| 100 | + |
| 101 | + expect { @described_object.send(:create_symlinks, logger) }.not_to raise_error |
| 102 | + end |
| 103 | + end |
| 104 | + |
| 105 | + context 'without logger' do |
| 106 | + it 'should install directory symlink' do |
| 107 | + @described_object.instance_variable_set( |
| 108 | + '@options', |
| 109 | + basedir: '/tmp/basedir', |
| 110 | + create_symlinks: %w(foo bar) |
| 111 | + ) |
| 112 | + |
| 113 | + expect(@described_object) |
| 114 | + .to receive(:install_directory_symlink) |
| 115 | + .with(nil, '/tmp/basedir') |
| 116 | + |
| 117 | + expect { @described_object.send(:create_symlinks) }.not_to raise_error |
| 118 | + end |
| 119 | + end |
| 120 | + end |
| 121 | + |
| 122 | + context 'with --environment' do |
| 123 | + context 'with logger' do |
| 124 | + it 'should log a warning message and install default symlink' do |
| 125 | + logger = double('Logger') |
| 126 | + expect(logger).to receive(:warn).with('--environment is ignored unless --preserve-environments is used') |
| 127 | + |
| 128 | + @described_object.instance_variable_set( |
| 129 | + '@options', |
| 130 | + basedir: '/tmp/basedir', |
| 131 | + environment: 'baz' |
| 132 | + ) |
| 133 | + |
| 134 | + expect(@described_object) |
| 135 | + .to receive(:install_directory_symlink) |
| 136 | + .with(logger, '/tmp/basedir') |
| 137 | + |
| 138 | + expect { @described_object.send(:create_symlinks, logger) }.not_to raise_error |
| 139 | + end |
| 140 | + end |
| 141 | + |
| 142 | + context 'without logger' do |
| 143 | + it 'should install default symlink' do |
| 144 | + @described_object.instance_variable_set( |
| 145 | + '@options', |
| 146 | + basedir: '/tmp/basedir', |
| 147 | + environment: 'baz' |
| 148 | + ) |
| 149 | + |
| 150 | + expect(@described_object) |
| 151 | + .to receive(:install_directory_symlink) |
| 152 | + .with(nil, '/tmp/basedir') |
| 153 | + |
| 154 | + expect { @described_object.send(:create_symlinks) }.not_to raise_error |
| 155 | + end |
| 156 | + end |
| 157 | + end |
| 158 | + |
| 159 | + context 'without --create-symlinks or --environment' do |
| 160 | + it 'should install directory symlink' do |
| 161 | + logger = double('Logger') |
| 162 | + |
| 163 | + @described_object.instance_variable_set( |
| 164 | + '@options', |
| 165 | + basedir: '/tmp/basedir' |
| 166 | + ) |
| 167 | + |
| 168 | + expect(@described_object) |
| 169 | + .to receive(:install_directory_symlink) |
| 170 | + .with(logger, '/tmp/basedir') |
| 171 | + |
| 172 | + expect { @described_object.send(:create_symlinks, logger) }.not_to raise_error |
| 173 | + end |
| 174 | + end |
| 175 | + end |
| 176 | + end |
| 177 | + |
28 | 178 | describe '#install_directory_symlink' do |
29 | 179 | it 'should create properly pointed symlink' do |
30 | 180 | options = { |
|
0 commit comments