Skip to content

Commit 1d6d988

Browse files
committed
minimal test case for rodjek/rspec-puppet#785 (comment)
1 parent da63178 commit 1d6d988

File tree

5 files changed

+3
-316
lines changed

5 files changed

+3
-316
lines changed

spec/classes/config_spec.rb

Lines changed: 0 additions & 147 deletions
This file was deleted.

spec/classes/cpan_spec.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

spec/classes/install_spec.rb

Lines changed: 0 additions & 52 deletions
This file was deleted.

spec/types/cpan_spec.rb

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,12 @@
55
describe 'cpan' do
66
let(:title) { 'baz' }
77

8-
describe 'valid type' do
9-
it { is_expected.to be_valid_type }
10-
end
11-
describe 'ensure' do
12-
[:present, :absent, :installed, :latest].each do |value|
13-
it "accepts #{value} as a value" do
14-
is_expected.to be_valid_type.with_set_attributes(ensure: value)
15-
end
16-
end
17-
it 'rejects other values' do
18-
expect { described_type.new(name: 'test', ensure: 'foo') }.to raise_error(Puppet::Error)
19-
end
20-
end
21-
22-
describe 'name' do
23-
it 'is the namevar' do
24-
expect(described_type.key_attributes).to eq([:name])
25-
end
26-
end
27-
28-
describe 'local_lib' do
29-
it 'accepts an absolute path' do
30-
is_expected.to be_valid_type.with_set_attributes(local_lib: '/path/to/file')
31-
end
32-
it 'accepts false' do
33-
is_expected.to be_valid_type.with_set_attributes(local_lib: false)
34-
end
35-
end
36-
378
describe 'force' do
38-
[true, false, 'true', 'false', 'no', 'yes'].each do |value|
39-
it "accepts #{value}" do
40-
is_expected.to be_valid_type.with_set_attributes(force: value)
41-
end
42-
end
43-
it 'rejects other values' do
44-
# for some reason expect { be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error doesn't raise
45-
# expect {be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error(Puppet::ResourceError)
9+
it 'rejects other values (rspec)' do
4610
expect { described_type.new(name: 'test', force: 'nope') }.to raise_error(Puppet::Error)
4711
end
48-
it 'defaults to false' do
49-
expect(described_type.new(name: 'test')[:force]).to eq(false)
50-
end
51-
it 'munges \'false\' to false' do
52-
expect(described_type.new(name: 'test', force: 'false')[:force]).to eq(false)
53-
end
54-
it 'munges \'true\' to true' do
55-
expect(described_type.new(name: 'test', force: 'true')[:force]).to eq(true)
56-
end
57-
end
58-
59-
describe 'umask' do
60-
describe 'valid values' do
61-
['0022', '022', '0027', '027'].each do |value|
62-
it "accepts #{value}" do
63-
is_expected.to be_valid_type.with_set_attributes(umask: value)
64-
end
65-
end
66-
end
67-
describe 'invalid values' do
68-
[true, false, 220, '0', '888', 'invalid'].each do |value|
69-
it "rejects #{value}" do
70-
expect { described_type.new(name: 'test', umask: value) }.to raise_error(Puppet::Error)
71-
end
72-
end
12+
it 'rejects other values (be_valid_type)' do
13+
expect { be_valid_type.with_set_attributes(force: 'nope') }.to raise_error(Puppet::Error)
7314
end
7415
end
7516
end

spec/types/cpan_spec_minimal.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)