Skip to content

Commit 0bee95a

Browse files
authored
Add cap tests (#127)
Add cap tests
2 parents 8e79944 + f3fd3f4 commit 0bee95a

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

spec/defines/cap_spec.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
require 'spec_helper'
2+
3+
describe 'Wp::Cap' do
4+
let(:environment) { 'development' }
5+
let(:title) { 'wp cap' }
6+
let(:params) do {
7+
'role' => 'editor',
8+
'cap' => 'edit_posts',
9+
'location' => '/vagrant',
10+
}
11+
end
12+
it { is_expected.to compile }
13+
14+
# Test a cap removal.
15+
context 'cap removal' do
16+
let(:params) do
17+
super().merge({ 'ensure' => 'absent' })
18+
end
19+
it { is_expected.to compile }
20+
end
21+
22+
# Test a custom location.
23+
context 'with location => /chassis' do
24+
let(:params) do
25+
super().merge({ 'location' => '/chassis' })
26+
end
27+
it { is_expected.to compile }
28+
end
29+
30+
# Test without role.
31+
context 'without role' do
32+
let(:params) do
33+
super().merge({ 'role' => '' })
34+
end
35+
it { is_expected.to compile }
36+
end
37+
38+
# Test without cap.
39+
context 'without cap' do
40+
let(:params) do
41+
super().merge({ 'cap' => '' })
42+
end
43+
it { is_expected.to compile }
44+
end
45+
46+
# Test without ensure.
47+
context 'without ensure' do
48+
let(:params) do
49+
super().merge({ 'ensure' => '' })
50+
end
51+
it { is_expected.not_to compile }
52+
end
53+
54+
# Test with grant false.
55+
context 'grant false' do
56+
let(:params) do
57+
super().merge({ 'grant' => false })
58+
end
59+
it { is_expected.to compile }
60+
end
61+
62+
# Test with a different user.
63+
context 'cap with different user' do
64+
let(:params) do
65+
super().merge({ 'user' => 'vagrant' })
66+
end
67+
it { is_expected.to compile }
68+
end
69+
70+
# Test without onlyif.
71+
context 'without onlyif' do
72+
let(:params) do
73+
super().merge({ 'onlyif' => '' })
74+
end
75+
it { is_expected.not_to compile }
76+
end
77+
end

0 commit comments

Comments
 (0)