OSDN Git Service

2b1bc9c725991e0779e3c8c14c089f5c4fc4f689
[metasearch/grid-chef-repo.git] / cookbooks / apt_utils / spec / recipes / source_spec.rb
1 #
2 # Cookbook Name:: apt_utils
3 # Recipe Spec:: source_spec
4 #
5 # Copyright 2015, whitestar
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 require_relative '../spec_helper'
21
22 describe 'apt_utils::source' do
23   let(:chef_run_on_non_debian) {
24     ChefSpec::SoloRunner
25       .new(platform: 'centos', version: '7.0')
26       .converge(described_recipe)
27   }
28
29   it 'does nothing on non debian family.' do
30     expect(chef_run_on_non_debian).to_not render_file('/etc/apt/sources.list')
31   end
32
33   let(:chef_run_on_debian) {
34     ChefSpec::SoloRunner.new(platform: 'debian', version: '8.1') {|node|
35       node.set['apt_utils']['source']['apt_lines'] = [
36         'deb http://cdn.debian.net/debian jessie main contrib non-free',
37         'deb http://cdn.debian.net/debian jessie-updates main contrib',
38       ]
39     }.converge(described_recipe)
40   }
41
42   it 'renders /etc/apt/sources.list on debian family.' do
43     expected = expect(chef_run_on_debian)
44     expected.to render_file('/etc/apt/sources.list')
45       .with_content('deb http://cdn.debian.net/debian jessie main contrib non-free')
46     expected.to render_file('/etc/apt/sources.list')
47       .with_content('deb http://cdn.debian.net/debian jessie-updates main contrib')
48   end
49 end