cookbook-openstack-telemetry/spec/spec_helper.rb

53 lines
1.6 KiB
Ruby

# encoding: UTF-8
require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start! { add_filter 'openstack-telemetry' }
require 'chef/application'
LOG_LEVEL = :fatal
REDHAT_OPTS = {
platform: 'redhat',
version: '7.1',
log_level: ::LOG_LEVEL
}
UBUNTU_OPTS = {
platform: 'ubuntu',
version: '14.04',
log_level: ::LOG_LEVEL
}
shared_context 'telemetry-stubs' do
before do
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
.and_return '1.1.1.1:5672,2.2.2.2:5672'
allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers).and_return([])
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('db', 'ceilometer')
.and_return('ceilometer-dbpass')
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('db', 'gnocchi')
.and_return('gnocchi-dbpass')
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('service', 'openstack-telemetry')
.and_return('ceilometer-pass')
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('service', 'openstack-telemetry-metric')
.and_return('gnocchi-pass')
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('user', 'guest')
.and_return('mq-pass')
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('token', 'openstack_identity_bootstrap_token')
.and_return('bootstrap-token')
allow(Chef::Application).to receive(:fatal!)
end
end
shared_examples 'expect-runs-common-recipe' do
it 'runs common recipe' do
expect(chef_run).to include_recipe 'openstack-telemetry::common'
end
end