Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Rspec puppet issue 785 #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"operatingsystemrelease": [
"5",
"6",
"7"
"7",
"8"
]
},
{
Expand Down
141 changes: 0 additions & 141 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