chefspec

Mock Chef::ReservedNames::Win32::Version.new in Chef unit/rspec test?

不羁岁月 提交于 2019-12-12 02:41:49
问题 I found Fauxhai works for mocking the information in "node" but it doesn't mock Chef::ReservedNames::Win32::Version.new. Is there anyway to mock this? 回答1: Standard RSpec applies so allow(Chef::ReservedNames::Win32::Version).to receive(:new).and_return(double('fake version')) or similar. 来源: https://stackoverflow.com/questions/34931987/mock-chefreservednameswin32version-new-in-chef-unit-rspec-test

“Cookbook apache_wrapper not found” when running chefspec in apache_wrapper cookbook

时光毁灭记忆、已成空白 提交于 2019-12-11 10:05:32
问题 I'm new in chef spec and try to figure out how to use unit testing in my cookbooks. I have installed chefdk(v2 and v3 on different ubuntu instances) and knife spec plugin. After "apache_wrapper" cookbook creation I have changed next files: spec/spec_helper.rb require 'chefspec' require 'chefspec/berkshelf' RSpec.configure do |config| config.log_level = :debug config.platform = 'ubuntu' config.version = '12.04' end spec/recipes/default_spec.rb require_relative '../spec_helper' describe 'apache

Mock Chef::ReservedNames::Win32::Version.new in Chef unit/rspec test? [continued]

心不动则不痛 提交于 2019-12-11 05:57:55
问题 Assuming, I have the following recipe: install_iis: require 'chef/win32/version' windows_version = Chef::ReservedNames::Win32::Version.new node.set['iis']['components'] = [ 'IIS-HttpErrors', 'IIS-HttpRedirect', 'IIS-HttpLogging', 'IIS-LoggingLibraries', 'IIS-RequestMonitor', 'WAS-WindowsActivationService', 'WAS-ProcessModel', 'IIS-StaticContent', 'IIS-DefaultDocument', 'IIS-DirectoryBrowsing' ] include_recipe 'iis::default' include_recipe 'iis::mod_aspnet' include_recipe 'iis::mod_auth_basic'

How can I test my LWRP with ChefSpec?

匆匆过客 提交于 2019-12-07 04:39:23
问题 I created my custom LWRP, but when I run the ChefSpec units test. It doesn't know my LWRP actions. Here is my resource : actions :install, :uninstall default_action :install attribute :version, :kind_of => String attribute :options, :kind_of => String Here is my provider : def whyrun_supported? true end action :install do version = @new_resource.version options = @new_resource.options e = execute "sudo apt-get install postgresql-#{version} #{options}" @new_resource.updated_by_last_action(e

How can I test my LWRP with ChefSpec?

大兔子大兔子 提交于 2019-12-05 07:21:29
I created my custom LWRP, but when I run the ChefSpec units test. It doesn't know my LWRP actions. Here is my resource : actions :install, :uninstall default_action :install attribute :version, :kind_of => String attribute :options, :kind_of => String Here is my provider : def whyrun_supported? true end action :install do version = @new_resource.version options = @new_resource.options e = execute "sudo apt-get install postgresql-#{version} #{options}" @new_resource.updated_by_last_action(e.updated_by_last_action?) end And here is my ChefSpec unit test: require_relative '../spec_helper'