Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
Fix the chefspec/berkshelf unit testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bellone committed Jan 29, 2016
1 parent 93f11a3 commit 5770bb7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Metrics/AbcSize:
Enabled: false
PerceivedComplexity:
Enabled: false
Style/SingleSpaceBeforeFirstArg:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/FileName:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ group :lint do
end

group :unit do
gem 'berkshelf'
gem 'chefspec'
end

Expand Down
3 changes: 2 additions & 1 deletion recipes/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
end

if node['kubernetes']['secure']['enabled'] == 'true'
file "#{node['kubernetes']['secure']['directory']}/client.ca.crt" do
file 'kubernetes::master[client.ca.crt]' do
path "#{node['kubernetes']['secure']['directory']}/client.ca.crt"
content node['kubernetes']['etcd']['client']['ca']
owner 'root'
group 'kube-services'
Expand Down
14 changes: 7 additions & 7 deletions test/spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'

describe_recipe 'blp-containers::default' do
context 'default' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |_node|
Chef::Config[:client_key] = '/etc/chef/client.pem'
end.converge(described_recipe)
end
describe_recipe 'kubernetes-cluster::default' do
context 'with default node attributes' do
let(:chef_run) { ChefSpec::ServerRunner.new.converge(described_recipe) }

it { expect(chef_run).to disable_service('firewalld') }
it { expect(chef_run).to stop_service('firewalld') }
it { expect(chef_run).to install_yum_package('flannel >= 0.2.0') }
end
end
15 changes: 0 additions & 15 deletions test/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
require 'chefspec'
require 'chefspec/berkshelf'
require 'chefspec/cacher'
require 'chef/sugar'
require 'chef-vault'

RSpec.configure do |config|
# Set default platform family and version for ChefSpec.
config.platform = 'redhat'
config.version = '7.1'

Expand All @@ -26,15 +23,3 @@
mocks.verify_partial_doubles = true
end
end

def chef_vault_mock(bag, item, value)
allow(ChefVault::Item).to receive(:load).with(bag, item).and_return(value)
end

def chef_vault_mock_for_environment(bag, item, environment, value)
chef_vault_mock(bag, item, environment, environment => value)
end

RSpec.shared_context 'recipe tests', type: :recipe do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
end

0 comments on commit 5770bb7

Please sign in to comment.