|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 | 3 | describe 'gocd::server' do
|
4 |
| - describe 'debian' do |
5 |
| - let(:chef_run) do |
6 |
| - run = ChefSpec::SoloRunner.new do |node| |
7 |
| - node.automatic['lsb']['id'] = 'Debian' |
8 |
| - node.automatic['platform_family'] = 'debian' |
9 |
| - node.automatic['platform'] = 'debian' |
10 |
| - node.automatic['os'] = 'linux' |
11 |
| - node.normal['java']['jdk_version'] = '7' |
12 |
| - end |
13 |
| - run.converge(described_recipe) |
14 |
| - end |
15 |
| - |
16 |
| - it 'includes apt recipe' do |
17 |
| - expect(chef_run).to include_recipe('apt::default') |
18 |
| - end |
| 4 | + shared_examples_for :server_recipe do |
19 | 5 | it 'includes java recipe' do
|
20 | 6 | expect(chef_run).to include_recipe('java::default')
|
21 | 7 | end
|
22 |
| - it 'adds thoughtworks apt repository' do |
23 |
| - expect(chef_run).to add_apt_repository('gocd') |
24 |
| - end |
25 |
| - it 'installs go-server apt package' do |
| 8 | + it 'installs go-server package' do |
26 | 9 | expect(chef_run).to install_package('go-server')
|
27 | 10 | end
|
28 |
| - |
29 | 11 | it 'creates go server configuration in /etc/default/go-server' do
|
30 | 12 | expect(chef_run).to render_file('/etc/default/go-server').with_content { |content|
|
31 |
| - expect(content).to_not include('java-6-openjdk') |
| 13 | + expect(content).to_not include('java-6') |
32 | 14 | }
|
33 | 15 | end
|
| 16 | + it 'configures go-server service' do |
| 17 | + expect(chef_run).to enable_service('go-server') |
| 18 | + expect(chef_run).to start_service('go-server') |
| 19 | + end |
| 20 | + end |
34 | 21 |
|
| 22 | + context 'When all attributes are default and platform is debian' do |
| 23 | + let(:chef_run) do |
| 24 | + run = ChefSpec::SoloRunner.new do |node| |
| 25 | + node.automatic['lsb']['id'] = 'Debian' |
| 26 | + node.automatic['platform_family'] = 'debian' |
| 27 | + node.automatic['platform'] = 'debian' |
| 28 | + node.automatic['os'] = 'linux' |
| 29 | + end |
| 30 | + run.converge(described_recipe) |
| 31 | + end |
| 32 | + it_behaves_like :server_recipe |
| 33 | + it_behaves_like :apt_repository_recipe |
| 34 | + end |
| 35 | + context 'When all attributes are default and platform is centos' do |
| 36 | + let(:chef_run) do |
| 37 | + run = ChefSpec::SoloRunner.new do |node| |
| 38 | + node.automatic['platform_family'] = 'rhel' |
| 39 | + node.automatic['platform'] = 'centos' |
| 40 | + node.automatic['os'] = 'linux' |
| 41 | + end |
| 42 | + run.converge(described_recipe) |
| 43 | + end |
| 44 | + it_behaves_like :server_recipe |
| 45 | + it_behaves_like :yum_repository_recipe |
35 | 46 | end
|
| 47 | + #TODO: server on windows |
36 | 48 | end
|
0 commit comments