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

Spec refactor #49

Merged
merged 6 commits into from
Apr 23, 2014
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem "puppet-lint"
gem "rspec-puppet", '~> 1.0.0'
gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git'
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
end
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: https://github.com/rodjek/rspec-puppet.git
revision: 03e94422fb9bbdd950d5a0bec6ead5d76e06616b
specs:
rspec-puppet (1.0.1)
rspec

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -32,8 +39,6 @@ GEM
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-puppet (1.0.1)
rspec

PLATFORMS
ruby
Expand All @@ -44,4 +49,4 @@ DEPENDENCIES
puppet-syntax
puppetlabs_spec_helper
rake
rspec-puppet (~> 1.0.0)
rspec-puppet!
1 change: 1 addition & 0 deletions spec/classes/coverage_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
at_exit { RSpec::Puppet::Coverage.report! }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. We are really stepping it up :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in love with the coverage feature!

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

describe 'dns::server::config', :type => :class do

context "on an unknown OS" do
let :facts do { :concat_basedir => '/dne', } end
it { expect { subject }.to raise_error() }
context "on an unsupported OS" do
let :facts do { :osfamily => 'Solaris', :concat_basedir => '/dne', } end
it { should raise_error(/dns::server is incompatible with this osfamily/) }
end

context "on a Debian OS" do
Expand All @@ -15,6 +15,7 @@
:concat_basedir => '/dne',
}
end

it { should contain_file('/etc/bind/').with_owner('bind') }
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'spec_helper'

describe 'dns::server::install', :type => :class do
context "on an unknown OS" do
it { expect { subject }.to raise_error() }
context "on an unsupported OS" do
it{ should raise_error(/dns::server is incompatible with this osfamily/) }
end

context "on a Debian OS" do
Expand All @@ -12,6 +12,7 @@
:operatingsystemrelease => '6',
}
end
it { should contain_class('dns::server::params') }
it { should contain_package("bind9") }
end

Expand Down
17 changes: 17 additions & 0 deletions spec/classes/dns__server__service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'dns::server::service' do
let(:facts) {{ :concat_basedir => '/mock_dir' }}
context 'on a supported OS' do
let(:facts) {{ :osfamily => 'Debian' }}

it { should contain_service('bind9').with_require('Class[Dns::Server::Config]') }
end

context 'on an unsupported OS' do
let(:facts) {{ :osfamily => 'Solaris' }}

it { should raise_error(/dns::server is incompatible with this osfamily: Solaris/) }
end

end
9 changes: 9 additions & 0 deletions spec/classes/dns__server_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'spec_helper'

describe 'dns::server' do
let(:facts) {{ :osfamily => 'Debian', :concat_basedir => '/dne' }}

it { should contain_class('dns::server::install') }
it { should contain_class('dns::server::config') }
it { should contain_class('dns::server::service') }
end
9 changes: 2 additions & 7 deletions spec/defines/dns__acl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

describe 'dns::acl' do
let(:title) { 'trusted' }

let(:facts) { { :concat_basedir => '/tmp' } }

context 'passing a string to data' do
let :params do
{ :data => '192.168.0.0/24' }
end

it 'should fail input validation' do
expect { subject }.to raise_error(Puppet::Error, /is not an Array/)
end
it { should raise_error(Puppet::Error, /is not an Array/) }
end

context 'passing an array to data' do
let :params do
{ :data => [ '192.168.0.0/24' ] }
end

it 'should pass input validation' do
expect { subject }.to_not raise_error
end
it { should_not raise_error }

it {
should contain_concat__fragment('named.conf.local.acl.trusted.include').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
{ :forwarders => '8.8.8.8' }
end

it 'should fail input validation' do
expect { subject }.to raise_error(Puppet::Error, /is not an Array/)
end
it { should raise_error(Puppet::Error, /is not an Array/) }

end

end
Expand Down
10 changes: 3 additions & 7 deletions spec/defines/dns_zone_spec.rb → spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
let :facts do { :osfamily => 'Debian', :concat_basedir => '/dne' } end
let :params do { :allow_transfer => '127.0.0.1' } end

it 'should fail input validation' do
expect { subject }.to raise_error(Puppet::Error, /is not an Array/)
end
it { should raise_error(Puppet::Error, /is not an Array/) }
end

context 'passing an array to data' do
Expand All @@ -22,9 +20,7 @@
}
end

it 'should pass input validation' do
expect { subject }.to_not raise_error
end
it { should_not raise_error }

it {
should contain_concat__fragment('named.conf.local.test.com.include').
Expand Down Expand Up @@ -56,7 +52,7 @@
with_content(/2001:db8::\/32/)
}

it {
it {
should contain_concat('/etc/bind/zones/db.test.com.stage')
}

Expand Down