Skip to content

Commit

Permalink
minimal test case for rodjek/rspec-puppet#785 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
faxm0dem committed Feb 19, 2020
1 parent da63178 commit 1d6d988
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 316 deletions.
147 changes: 0 additions & 147 deletions spec/classes/config_spec.rb

This file was deleted.

39 changes: 0 additions & 39 deletions spec/classes/cpan_spec.rb

This file was deleted.

52 changes: 0 additions & 52 deletions spec/classes/install_spec.rb

This file was deleted.

65 changes: 3 additions & 62 deletions spec/types/cpan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,12 @@
describe 'cpan' do
let(:title) { 'baz' }

describe 'valid type' do
it { is_expected.to be_valid_type }
end
describe 'ensure' do
[:present, :absent, :installed, :latest].each do |value|
it "accepts #{value} as a value" do
is_expected.to be_valid_type.with_set_attributes(ensure: value)
end
end
it 'rejects other values' do
expect { described_type.new(name: 'test', ensure: 'foo') }.to raise_error(Puppet::Error)
end
end

describe 'name' do
it 'is the namevar' do
expect(described_type.key_attributes).to eq([:name])
end
end

describe 'local_lib' do
it 'accepts an absolute path' do
is_expected.to be_valid_type.with_set_attributes(local_lib: '/path/to/file')
end
it 'accepts false' do
is_expected.to be_valid_type.with_set_attributes(local_lib: false)
end
end

describe 'force' do
[true, false, 'true', 'false', 'no', 'yes'].each do |value|
it "accepts #{value}" do
is_expected.to be_valid_type.with_set_attributes(force: value)
end
end
it 'rejects other values' do
# for some reason expect { be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error doesn't raise
# expect {be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error(Puppet::ResourceError)
it 'rejects other values (rspec)' do
expect { described_type.new(name: 'test', force: 'nope') }.to raise_error(Puppet::Error)
end
it 'defaults to false' do
expect(described_type.new(name: 'test')[:force]).to eq(false)
end
it 'munges \'false\' to false' do
expect(described_type.new(name: 'test', force: 'false')[:force]).to eq(false)
end
it 'munges \'true\' to true' do
expect(described_type.new(name: 'test', force: 'true')[:force]).to eq(true)
end
end

describe 'umask' do
describe 'valid values' do
['0022', '022', '0027', '027'].each do |value|
it "accepts #{value}" do
is_expected.to be_valid_type.with_set_attributes(umask: value)
end
end
end
describe 'invalid values' do
[true, false, 220, '0', '888', 'invalid'].each do |value|
it "rejects #{value}" do
expect { described_type.new(name: 'test', umask: value) }.to raise_error(Puppet::Error)
end
end
it 'rejects other values (be_valid_type)' do
expect { be_valid_type.with_set_attributes(force: 'nope') }.to raise_error(Puppet::Error)
end
end
end
16 changes: 0 additions & 16 deletions spec/types/cpan_spec_minimal.rb

This file was deleted.

0 comments on commit 1d6d988

Please sign in to comment.