Code Review
/
puppet-modules
/
puppetlabs-apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix syntax error
[puppet-modules/puppetlabs-apt.git]
/
spec
/
defines
/
key_spec.rb
diff --git
a/spec/defines/key_spec.rb
b/spec/defines/key_spec.rb
index 31248cc78a5f1bd94b485fbf3ce8fa0b7d55d088..14a3efbc5aadbfeb8527c48b858ca4b39b6f3848 100644
(file)
--- a/
spec/defines/key_spec.rb
+++ b/
spec/defines/key_spec.rb
@@
-1,7
+1,12
@@
require 'spec_helper'
describe 'apt::key' do
require 'spec_helper'
describe 'apt::key' do
- let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+
+ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
+
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
let :title do
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
let :title do
@@
-15,7
+20,7
@@
describe 'apt::key' do
:id => title,
:ensure => 'present',
:source => nil,
:id => title,
:ensure => 'present',
:source => nil,
- :server =>
nil
,
+ :server =>
'keyserver.ubuntu.com'
,
:content => nil,
:options => nil,
})
:content => nil,
:options => nil,
})
@@
-39,7
+44,7
@@
describe 'apt::key' do
:id => GPG_KEY_ID,
:ensure => 'present',
:source => nil,
:id => GPG_KEY_ID,
:ensure => 'present',
:source => nil,
- :server =>
nil
,
+ :server =>
'keyserver.ubuntu.com'
,
:content => nil,
:options => nil,
})
:content => nil,
:options => nil,
})
@@
-59,7
+64,7
@@
describe 'apt::key' do
:id => title,
:ensure => 'absent',
:source => nil,
:id => title,
:ensure => 'absent',
:source => nil,
- :server =>
nil
,
+ :server =>
'keyserver.ubuntu.com'
,
:content => nil,
:keyserver => nil,
})
:content => nil,
:keyserver => nil,
})
@@
-138,7
+143,7
@@
describe 'apt::key' do
:server => '-pgp.mit.edu',
} end
it 'fails' do
:server => '-pgp.mit.edu',
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject
.call
} .to raise_error(/does not match/)
end
end
end
end
@@
-147,7
+152,7
@@
describe 'apt::key' do
:server => '.pgp.mit.edu',
} end
it 'fails' do
:server => '.pgp.mit.edu',
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject
.call
} .to raise_error(/does not match/)
end
end
end
end
@@
-156,7
+161,7
@@
describe 'apt::key' do
:server => "pgp.mit.edu.",
} end
it 'fails' do
:server => "pgp.mit.edu.",
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject
.call
} .to raise_error(/does not match/)
end
end
context "exceed character url" do
end
end
context "exceed character url" do
@@
-166,7
+171,7
@@
describe 'apt::key' do
}
end
it 'fails' do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context "incorrect port number url" do
end
end
context "incorrect port number url" do
@@
-176,7
+181,7
@@
describe 'apt::key' do
}
end
it 'fails' do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context "incorrect protocol for url" do
end
end
context "incorrect protocol for url" do
@@
-186,7
+191,7
@@
describe 'apt::key' do
}
end
it 'fails' do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context "missing port number url" do
end
end
context "missing port number url" do
@@
-196,7
+201,7
@@
describe 'apt::key' do
}
end
it 'fails' do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context "url ending with a dot" do
end
end
context "url ending with a dot" do
@@
-206,7
+211,7
@@
describe 'apt::key' do
}
end
it 'fails' do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context "url begin with a dash" do
end
end
context "url begin with a dash" do
@@
-214,7
+219,7
@@
describe 'apt::key' do
:server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
:server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
context 'invalid key' do
end
end
context 'invalid key' do
@@
-222,7
+227,7
@@
describe 'apt::key' do
'Out of rum. Why? Why are we out of rum?'
end
it 'fails' do
'Out of rum. Why? Why are we out of rum?'
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
end
end
@@
-231,7
+236,7
@@
describe 'apt::key' do
:source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
:source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
end
end
@@
-240,7
+245,7
@@
describe 'apt::key' do
:content => [],
} end
it 'fails' do
:content => [],
} end
it 'fails' do
- expect { subject }.to raise_error(/is not a string/)
+ expect { subject
.call
}.to raise_error(/is not a string/)
end
end
end
end
@@
-249,7
+254,7
@@
describe 'apt::key' do
:server => 'two bottles of rum',
} end
it 'fails' do
:server => 'two bottles of rum',
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject
.call
}.to raise_error(/does not match/)
end
end
end
end
@@
-258,25
+263,28
@@
describe 'apt::key' do
:options => {},
} end
it 'fails' do
:options => {},
} end
it 'fails' do
- expect { subject }.to raise_error(/is not a string/)
+ expect { subject
.call
}.to raise_error(/is not a string/)
end
end
context 'invalid ensure' do
end
end
context 'invalid ensure' do
- let :params do
- {
- :ensure => 'foo',
- }
- end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ %w(foo aabsent absenta apresent presenta).each do |param|
+ let :params do
+ {
+ :ensure => param,
+ }
+ end
+ it 'fails' do
+ expect { subject.call }.to raise_error(/does not match/)
+ end
end
end
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
end
end
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
- "apt::key { 'duplicate': id => '#{title}', }"
+ "class { 'apt': }
+ apt::key { 'duplicate': id => '#{title}', }"
end
it 'contains two apt::key resources' do
end
it 'contains two apt::key resources' do
@@
-295,7
+303,7
@@
describe 'apt::key' do
:id => title,
:ensure => 'present',
:source => nil,
:id => title,
:ensure => 'present',
:source => nil,
- :server =>
nil
,
+ :server =>
'keyserver.ubuntu.com'
,
:content => nil,
:options => nil,
})
:content => nil,
:options => nil,
})
@@
-305,10
+313,11
@@
describe 'apt::key' do
context 'two apt::key resources, different ensure' do
let :pre_condition do
context 'two apt::key resources, different ensure' do
let :pre_condition do
- "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
+ "class { 'apt': }
+ apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
end
it 'informs the user of the impossibility' do
- expect { subject }.to raise_error(/already ensured as absent/)
+ expect { subject
.call
}.to raise_error(/already ensured as absent/)
end
end
end
end
end
end