Skip to content

Commit

Permalink
Merge pull request #28 from bcs-de/chefspec-3.1
Browse files Browse the repository at this point in the history
Chefspec 3.1
  • Loading branch information
jesseadams committed Feb 1, 2014
2 parents 2ff316e + 53f402a commit 563394b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 2.0'
gem 'chefspec', '~> 3.1'
gem 'foodcritic', '~> 3.0'
gem 'rubocop', '~> 0.12'

Expand Down
6 changes: 1 addition & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
require 'berkshelf'
require 'chefspec'

Berkshelf.ui.mute do
Berkshelf::Berksfile.from_file('Berksfile').install(path: 'vendor/cookbooks')
end
require 'chefspec/berkshelf'
14 changes: 8 additions & 6 deletions spec/unit/recipes/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
require 'spec_helper'

describe 'munin::client' do
let(:chef_run) { ChefSpec::ChefRunner.new.converge(described_recipe) }
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }

it 'installs the munin-node package' do
expect(chef_run).to install_package('munin-node')
end

it 'writes the munin-node.conf' do
expect(chef_run).to create_template('/etc/munin/munin-node.conf').with(
source: 'munin-node.conf.erb',
mode: '0644'
)

template = chef_run.template('/etc/munin/munin-node.conf')
expect(template).to be
expect(template.source).to eq('munin-node.conf.erb')
expect(template.mode).to eq('0644')
expect(template).to notify('service[munin-node]', :restart)
expect(template).to notify('service[munin-node]').to(:restart)
end

it 'starts and enables the service' do
expect(chef_run).to start_service('munin-node')
expect(chef_run).to set_service_to_start_on_boot('munin-node')
expect(chef_run).to enable_service('munin-node')
end
end
19 changes: 18 additions & 1 deletion spec/unit/recipes/server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'spec_helper'

describe 'munin::server' do
let(:chef_run) { ChefSpec::ChefRunner.new.converge(described_recipe) }
let(:chef_run) do
ChefSpec::Runner.new do |node|
node.set['munin']['server_auth_method'] = 'htpasswd'
end.converge(described_recipe)
end

before do
Chef::Recipe.any_instance.stub(:data_bag).with('users').and_return(%w[seth nathen])
Expand Down Expand Up @@ -34,4 +38,17 @@
pending 'This recipe is pretty much untestable'
end
end

context 'server-parts' do
it 'creates a server config' do
expect(chef_run).to render_file('/etc/munin/munin.conf').with_content(
/generated by Chef/
)
end
it 'finds itself as munin-node as fallback' do
expect(chef_run).to render_file('/etc/munin/munin.conf').with_content(
/chefspec.local/
)
end
end
end

0 comments on commit 563394b

Please sign in to comment.