Skip to content

Instantly share code, notes, and snippets.

@glarizza
Last active December 30, 2015 10:29
Show Gist options
  • Save glarizza/7816611 to your computer and use it in GitHub Desktop.
Save glarizza/7816611 to your computer and use it in GitHub Desktop.
# <modulepath>/rcsrpo/spec/unit/puppet/type/rcsrepo_spec.rb
require 'puppet'
require 'puppet/type/rcsrepo'
describe Puppet::Type.type(:rcsrepo) do
subject { Puppet::Type.type(:rcsrepo).new(:path => '/foo') }
it 'should accept ensure' do
subject[:ensure] = :present
subject[:ensure].should == :present
end
it 'should not accept invalid ensure values' do
expect { subject[:ensure] = :bad }.to raise_error Puppet::ResourceError, /Parameter ensure failed on/
end
it 'should require that path be absolute' do
expect { subject[:path] = 'badpath' }.to raise_error Puppet::Error, /Path must be an absolute path/
end
it 'should accept a valid path' do
subject[:path] = '/path/to/file'
subject[:path].should == '/path/to/file'
end
it 'should not accept whitespace in a revision' do
expect { subject[:revision] = 'some revision' }.to raise_error Puppet::Error, /Invalid value "some revision"/
end
it 'should accept a valid revision' do
subject[:revision] = 'revision'
subject[:revision].should == 'revision'
end
it 'should accept a valid source URI' do
subject[:source] = 'http://www.something.com'
subject[:source].should == 'http://www.something.com'
end
it 'should not accept an invalid source URI' do
expect { subject[:source] = 'foo' }.to raise_error Puppet::Error, /Value must be a valid URI, not foo/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment