-
Notifications
You must be signed in to change notification settings - Fork 88
/
package_maintainer_spec.rb
83 lines (67 loc) · 2.24 KB
/
package_maintainer_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'spec_helper'
require 'fpm/cookery/package/maintainer'
require 'ostruct'
describe 'Maintainer' do
let(:klass) { FPM::Cookery::Package::Maintainer }
let(:recipe) { OpenStruct.new }
let(:config) { {} }
let(:maintainer) { klass.new(recipe, config) }
def with_env_stub(env)
old_env = ENV.to_hash
env.each do |key, value|
ENV[key] = value
end
yield
ensure
ENV.replace(old_env)
end
before do
allow(FPM::Cookery::Shellout).to receive(:git_config_get).with('user.name').and_return('John Doe')
allow(FPM::Cookery::Shellout).to receive(:git_config_get).with('user.email').and_return('[email protected]')
end
describe '#to_s' do
context 'with maintainer set in recipe' do
it 'returns the recipe maintainer' do
end
end
context 'with maintainer set in config' do
it 'returns the config maintainer' do
end
end
context 'with maintainer in config and recipe' do
it 'returns the config maintainer' do
end
end
context 'without any maintainer set' do
it 'returns the maintainer from git' do
end
end
context 'without valid git data' do
before do
allow(FPM::Cookery::Shellout).to receive(:git_config_get).and_raise(
FPM::Cookery::Shellout::CommandFailed, 'whoops!'
)
allow(Socket).to receive(:gethostname).and_return('hostname')
end
it 'returns a default maintainer' do
with_env_stub('USER' => 'john') do
expect(maintainer.to_s).to eq('<john@hostname>')
end
end
end
end
describe '#to_str' do
it 'converts the maintainer object to a string' do
end
end
end