-
Notifications
You must be signed in to change notification settings - Fork 1
/
provider_spotify_app_debian_spec.rb
64 lines (56 loc) · 2.02 KB
/
provider_spotify_app_debian_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Encoding: UTF-8
require_relative '../spec_helper'
require_relative '../../libraries/provider_spotify_app_debian'
describe Chef::Provider::SpotifyApp::Debian do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::SpotifyApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }
describe '.provides?' do
let(:platform) { nil }
let(:node) { ChefSpec::Macros.stub_node('node.example', platform) }
let(:res) { described_class.provides?(node, new_resource) }
{
'Debian' => { platform: 'debian', version: '7.6' },
'Ubuntu' => { platform: 'ubuntu', version: '14.04' }
}.each do |k, v|
context k do
let(:platform) { v }
it 'returns true' do
expect(res).to eq(true)
end
end
end
end
describe '#install!' do
it 'configures the Spotify APT repo and installs the package' do
p = provider
expect(p).to receive(:add_repo)
expect(p).to receive(:package).with('spotify-client').and_yield
expect(p).to receive(:action).with(:install)
p.send(:install!)
end
end
describe '#remove!' do
it 'uses a package and apt_repository to delete Spotify' do
p = provider
expect(p).to receive(:package).with('spotify-client').and_yield
expect(p).to receive(:action).with(:remove)
expect(p).to receive(:apt_repository).with('spotify').and_yield
expect(p).to receive(:action).with(:remove)
p.send(:remove!)
end
end
describe '#add_repo' do
it 'configures the Spotify APT repository' do
p = provider
expect(p).to receive(:include_recipe).with('apt')
expect(p).to receive(:apt_repository).with('spotify').and_yield
expect(p).to receive(:uri).with('http://repository.spotify.com')
expect(p).to receive(:components).with(%w(stable non-free))
expect(p).to receive(:key).with('D2C19886')
expect(p).to receive(:keyserver).with('keyserver.ubuntu.com')
expect(p).to receive(:action).with(:add)
p.send(:add_repo)
end
end
end