chefspec 6.0.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +23 -5
- data/chefspec.gemspec +1 -1
- data/examples/batch/recipes/run.rb +0 -4
- data/examples/batch/spec/run_spec.rb +0 -4
- data/examples/bff_package/spec/install_spec.rb +1 -1
- data/examples/bff_package/spec/purge_spec.rb +1 -1
- data/examples/bff_package/spec/remove_spec.rb +1 -1
- data/examples/bff_package/spec/upgrade_spec.rb +1 -1
- data/examples/freebsd_package/spec/install_spec.rb +1 -1
- data/examples/freebsd_package/spec/remove_spec.rb +1 -1
- data/examples/homebrew_package/spec/install_spec.rb +1 -1
- data/examples/homebrew_package/spec/purge_spec.rb +1 -1
- data/examples/homebrew_package/spec/remove_spec.rb +1 -1
- data/examples/homebrew_package/spec/upgrade_spec.rb +1 -1
- data/examples/launchd/spec/create_if_missing_spec.rb +1 -1
- data/examples/launchd/spec/create_spec.rb +1 -1
- data/examples/launchd/spec/delete_spec.rb +1 -1
- data/examples/launchd/spec/disable_spec.rb +1 -1
- data/examples/launchd/spec/enable_spec.rb +1 -1
- data/examples/macports_package/spec/install_spec.rb +1 -1
- data/examples/macports_package/spec/purge_spec.rb +1 -1
- data/examples/macports_package/spec/remove_spec.rb +1 -1
- data/examples/macports_package/spec/upgrade_spec.rb +1 -1
- data/examples/openbsd_package/spec/install_spec.rb +1 -1
- data/examples/openbsd_package/spec/purge_spec.rb +1 -1
- data/examples/openbsd_package/spec/remove_spec.rb +1 -1
- data/examples/openbsd_package/spec/upgrade_spec.rb +1 -1
- data/examples/osx_profile/spec/install_spec.rb +1 -1
- data/examples/osx_profile/spec/remove_spec.rb +1 -1
- data/examples/pacman_package/spec/install_spec.rb +1 -1
- data/examples/pacman_package/spec/purge_spec.rb +1 -1
- data/examples/pacman_package/spec/remove_spec.rb +1 -1
- data/examples/pacman_package/spec/upgrade_spec.rb +1 -1
- data/examples/paludis_package/spec/install_spec.rb +1 -1
- data/examples/paludis_package/spec/purge_spec.rb +1 -1
- data/examples/paludis_package/spec/remove_spec.rb +1 -1
- data/examples/paludis_package/spec/upgrade_spec.rb +1 -1
- data/examples/powershell_script/recipes/run.rb +0 -4
- data/examples/powershell_script/spec/run_spec.rb +0 -4
- data/examples/roles/spec/default_spec.rb +1 -1
- data/examples/rpm_package/spec/install_spec.rb +1 -1
- data/examples/rpm_package/spec/remove_spec.rb +1 -1
- data/examples/rpm_package/spec/upgrade_spec.rb +1 -1
- data/examples/ruby_block/spec/create_spec.rb +1 -1
- data/examples/ruby_block/spec/run_spec.rb +1 -1
- data/examples/script/recipes/run_bash.rb +0 -4
- data/examples/script/recipes/run_csh.rb +0 -4
- data/examples/script/recipes/run_ksh.rb +0 -4
- data/examples/script/recipes/run_perl.rb +0 -4
- data/examples/script/recipes/run_python.rb +0 -4
- data/examples/script/recipes/run_ruby.rb +0 -4
- data/examples/script/recipes/run_script.rb +0 -4
- data/examples/script/spec/run_bash_spec.rb +0 -4
- data/examples/script/spec/run_csh_spec.rb +0 -4
- data/examples/script/spec/run_ksh_spec.rb +1 -5
- data/examples/script/spec/run_perl_spec.rb +0 -4
- data/examples/script/spec/run_python_spec.rb +0 -4
- data/examples/script/spec/run_ruby_spec.rb +0 -4
- data/examples/script/spec/run_script_spec.rb +0 -4
- data/examples/server/spec/data_bag_spec.rb +8 -8
- data/examples/server/spec/exotic_port_spec.rb +17 -0
- data/examples/server/spec/node_spec.rb +1 -1
- data/examples/solaris_package/spec/upgrade_spec.rb +4 -1
- data/examples/stub_data_bag/spec/default_spec.rb +1 -1
- data/examples/stub_data_bag_item/spec/default_spec.rb +1 -1
- data/examples/stub_search/recipes/block.rb +3 -0
- data/examples/stub_search/recipes/default.rb +2 -5
- data/examples/stub_search/spec/block_spec.rb +27 -0
- data/examples/stub_search/spec/default_spec.rb +1 -1
- data/examples/yum_package/spec/install_spec.rb +1 -1
- data/examples/yum_package/spec/purge_spec.rb +1 -1
- data/examples/yum_package/spec/remove_spec.rb +1 -1
- data/examples/yum_package/spec/upgrade_spec.rb +1 -1
- data/examples/yum_repository/spec/add_spec.rb +1 -1
- data/examples/yum_repository/spec/create_spec.rb +1 -1
- data/examples/yum_repository/spec/delete_spec.rb +1 -1
- data/examples/yum_repository/spec/makecache_spec.rb +1 -1
- data/examples/yum_repository/spec/remove_spec.rb +1 -1
- data/examples/zypper_package/spec/install_spec.rb +1 -1
- data/examples/zypper_package/spec/purge_spec.rb +1 -1
- data/examples/zypper_package/spec/remove_spec.rb +1 -1
- data/examples/zypper_package/spec/upgrade_spec.rb +1 -1
- data/features/exotic_zero_port.feature +7 -0
- data/features/stub_search.feature +1 -1
- data/features/support/exotic_zero_port.rb +3 -0
- data/lib/chefspec/coverage.rb +25 -7
- data/lib/chefspec/extensions/chef/data_query.rb +6 -1
- data/lib/chefspec/macros.rb +1 -1
- data/lib/chefspec/rspec.rb +1 -0
- data/lib/chefspec/server_methods.rb +1 -1
- data/lib/chefspec/solo_runner.rb +2 -1
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +1 -0
- data/spec/unit/macros_spec.rb +2 -2
- data/spec/unit/solo_runner_spec.rb +3 -2
- metadata +18 -5
|
@@ -16,8 +16,4 @@ describe 'script::run_csh' do
|
|
|
16
16
|
expect(chef_run).to run_csh('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_csh('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a csh script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_csh('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'script::run_ksh' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
it 'runs a ksh script with the default action' do
|
|
7
7
|
expect(chef_run).to run_ksh('default_action')
|
|
@@ -16,8 +16,4 @@ describe 'script::run_ksh' do
|
|
|
16
16
|
expect(chef_run).to run_ksh('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_ksh('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a ksh script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_ksh('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -16,8 +16,4 @@ describe 'script::run_perl' do
|
|
|
16
16
|
expect(chef_run).to run_perl('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_perl('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a perl script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_perl('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -16,8 +16,4 @@ describe 'script::run_python' do
|
|
|
16
16
|
expect(chef_run).to run_python('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_python('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a python script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_python('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -16,8 +16,4 @@ describe 'script::run_ruby' do
|
|
|
16
16
|
expect(chef_run).to run_ruby('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_ruby('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a ruby script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_ruby('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -16,8 +16,4 @@ describe 'script::run_script' do
|
|
|
16
16
|
expect(chef_run).to run_script('with_attributes').with(creates: 'creates')
|
|
17
17
|
expect(chef_run).to_not run_script('with_attributes').with(creates: 'bacon')
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
it 'runs a script when specifying the identity attribute' do
|
|
21
|
-
expect(chef_run).to run_script('identity_attribute')
|
|
22
|
-
end
|
|
23
19
|
end
|
|
@@ -3,14 +3,14 @@ require 'chefspec'
|
|
|
3
3
|
describe 'server::data_bag' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |_node, server|
|
|
6
|
-
server.create_data_bag('accounts',
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
server.create_data_bag('accounts', 'github' => {
|
|
7
|
+
'username' => 'sethvargo',
|
|
8
|
+
'password' => 'p@ssW0rd!',
|
|
9
|
+
},
|
|
10
|
+
'twitter' => {
|
|
11
|
+
'username' => 'sethvargo',
|
|
12
|
+
'password' => '0th3r',
|
|
13
|
+
})
|
|
14
14
|
end.converge(described_recipe)
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
describe 'server::port' do
|
|
4
|
+
let(:chef_run) do
|
|
5
|
+
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'does not raise an exception' do
|
|
9
|
+
expect { chef_run }.to_not raise_error
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'creates a chef-zero listening on the right port' do
|
|
13
|
+
expect(ChefSpec::ZeroServer.server).to be_running?
|
|
14
|
+
expect(ChefSpec::ZeroServer.server.port).to be_a(Integer)
|
|
15
|
+
expect(8900..9010).to include(ChefSpec::ZeroServer.server.port)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -27,7 +27,7 @@ describe 'server::node' do
|
|
|
27
27
|
|
|
28
28
|
node = chef_run.get_node('chefspec')
|
|
29
29
|
expect(node['kernel']['name']).to eq('Linux')
|
|
30
|
-
expect(node['kernel']['release']).to
|
|
30
|
+
expect(node['kernel']['release']).to match(/4.4.0-.*-generic/) # avoid failing when fauxhai data changes
|
|
31
31
|
expect(node['kernel']['machine']).to eq('x86_64')
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'solaris_package::upgrade' do
|
|
4
|
-
let(:chef_run)
|
|
4
|
+
let(:chef_run) do
|
|
5
|
+
ChefSpec::ServerRunner.new(platform: 'solaris2', version: '5.11')
|
|
6
|
+
.converge(described_recipe)
|
|
7
|
+
end
|
|
5
8
|
|
|
6
9
|
it 'upgrades a solaris_package with an explicit action' do
|
|
7
10
|
expect(chef_run).to upgrade_solaris_package('explicit_action')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'stub_data_bag::default' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
context 'when the data_bag is not stubbed' do
|
|
7
7
|
it 'raises an exception' do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'stub_data_bag_item::default' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
context 'when the data_bag_item is not stubbed' do
|
|
7
7
|
it 'raises an exception' do
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
describe 'stub_search::block' do
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
|
|
5
|
+
|
|
6
|
+
context 'when the search is not stubbed' do
|
|
7
|
+
it 'raises an exception' do
|
|
8
|
+
expect do
|
|
9
|
+
chef_run
|
|
10
|
+
end.to raise_error(ChefSpec::Error::SearchNotStubbed)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'as a String' do
|
|
15
|
+
it 'does not raise an exception' do
|
|
16
|
+
stub_search(:node, 'roles:web').and_return([{ name: 'example.com' }])
|
|
17
|
+
expect { chef_run }.to_not raise_error
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'as a Regexp' do
|
|
22
|
+
it 'does not raise an exception' do
|
|
23
|
+
stub_search(:node, /roles:(.+)/).and_return([{ name: 'example.com' }])
|
|
24
|
+
expect { chef_run }.to_not raise_error
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'stub_search::default' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
context 'when the search is not stubbed' do
|
|
7
7
|
it 'raises an exception' do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'zypper_package::install' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
it 'installs a zypper_package with the default action' do
|
|
7
7
|
expect(chef_run).to install_zypper_package('default_action')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'zypper_package::purge' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
it 'purges a zypper_package with an explicit action' do
|
|
7
7
|
expect(chef_run).to purge_zypper_package('explicit_action')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'zypper_package::remove' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
it 'removes a zypper_package with an explicit action' do
|
|
7
7
|
expect(chef_run).to remove_zypper_package('explicit_action')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'zypper_package::upgrade' do
|
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
|
|
5
5
|
|
|
6
6
|
it 'upgrades a zypper_package with an explicit action' do
|
|
7
7
|
expect(chef_run).to upgrade_zypper_package('explicit_action')
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Feature: The ChefSpec server with exotic port
|
|
2
|
+
Background:
|
|
3
|
+
* I am using the "server" cookbook
|
|
4
|
+
|
|
5
|
+
Scenario Outline: Running specs
|
|
6
|
+
* I successfully run `rspec spec/exotic_port_spec.rb --require ../../../features/support/exotic_zero_port.rb`
|
|
7
|
+
* the output should contain "0 failures"
|
data/lib/chefspec/coverage.rb
CHANGED
|
@@ -28,6 +28,15 @@ module ChefSpec
|
|
|
28
28
|
def initialize
|
|
29
29
|
@collection = {}
|
|
30
30
|
@filters = {}
|
|
31
|
+
@outputs = []
|
|
32
|
+
add_output do |report|
|
|
33
|
+
begin
|
|
34
|
+
erb = Erubis::Eruby.new(File.read(@template))
|
|
35
|
+
puts erb.evaluate(report)
|
|
36
|
+
rescue NameError => e
|
|
37
|
+
raise Error::ErbTemplateParseError.new(original_error: e.message)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
31
40
|
@template = ChefSpec.root.join('templates', 'coverage', 'human.erb')
|
|
32
41
|
end
|
|
33
42
|
|
|
@@ -41,7 +50,7 @@ module ChefSpec
|
|
|
41
50
|
end
|
|
42
51
|
|
|
43
52
|
#
|
|
44
|
-
# Add a filter to the
|
|
53
|
+
# Add a filter to the coverage analysis.
|
|
45
54
|
#
|
|
46
55
|
# @param [Filter, String, Regexp] filter
|
|
47
56
|
# the filter to add
|
|
@@ -68,6 +77,18 @@ module ChefSpec
|
|
|
68
77
|
|
|
69
78
|
true
|
|
70
79
|
end
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# Add an output to send the coverage results to.
|
|
83
|
+
# @param [Proc] block
|
|
84
|
+
# the block to use as the output
|
|
85
|
+
#
|
|
86
|
+
# @return [true]
|
|
87
|
+
#
|
|
88
|
+
def add_output(&block)
|
|
89
|
+
@outputs << block
|
|
90
|
+
end
|
|
91
|
+
|
|
71
92
|
#
|
|
72
93
|
# Change the template for reporting of converage analysis.
|
|
73
94
|
#
|
|
@@ -151,12 +172,9 @@ module ChefSpec
|
|
|
151
172
|
resource unless resource.touched?
|
|
152
173
|
end.compact
|
|
153
174
|
report[:all_resources] = @collection.values
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
puts erb.evaluate(report)
|
|
158
|
-
rescue NameError => e
|
|
159
|
-
raise Error::ErbTemplateParseError.new(original_error: e.message)
|
|
175
|
+
|
|
176
|
+
@outputs.each do |block|
|
|
177
|
+
self.instance_exec(report, &block)
|
|
160
178
|
end
|
|
161
179
|
|
|
162
180
|
# Ensure we exit correctly (#351)
|
|
@@ -14,7 +14,12 @@ module Chef::DSL::DataQuery
|
|
|
14
14
|
raise ChefSpec::Error::SearchNotStubbed.new(args: [type, query])
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
if block
|
|
18
|
+
Array(stub.result).each {|r| block.call(r) }
|
|
19
|
+
true
|
|
20
|
+
else
|
|
21
|
+
stub.result
|
|
22
|
+
end
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
# @see Chef::DSL::DataQuery#data_bag
|
data/lib/chefspec/macros.rb
CHANGED
|
@@ -139,7 +139,7 @@ module ChefSpec
|
|
|
139
139
|
# stub_node('mynode.example')
|
|
140
140
|
#
|
|
141
141
|
# @example mocking a specific platform and version
|
|
142
|
-
# stub_node('mynode.example', platform: 'ubuntu', version: '
|
|
142
|
+
# stub_node('mynode.example', platform: 'ubuntu', version: '16.04')
|
|
143
143
|
#
|
|
144
144
|
# @example overriding a specific ohai attribute
|
|
145
145
|
# stub_node('mynode.example', ohai: { ipaddress: '1.2.3.4' })
|
data/lib/chefspec/rspec.rb
CHANGED
|
@@ -115,7 +115,7 @@ module ChefSpec
|
|
|
115
115
|
#
|
|
116
116
|
# @example Create a node from a +Chef::Node+ object
|
|
117
117
|
#
|
|
118
|
-
# node = stub_node('bacon', platform: 'ubuntu', version: '
|
|
118
|
+
# node = stub_node('bacon', platform: 'ubuntu', version: '16.04')
|
|
119
119
|
# create_node(node)
|
|
120
120
|
#
|
|
121
121
|
# @param [String, Chef::Node] object
|
data/lib/chefspec/solo_runner.rb
CHANGED
|
@@ -34,7 +34,7 @@ module ChefSpec
|
|
|
34
34
|
# ChefSpec::SoloRunner.new
|
|
35
35
|
#
|
|
36
36
|
# @example Specifying the platform and version
|
|
37
|
-
# ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '
|
|
37
|
+
# ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04')
|
|
38
38
|
#
|
|
39
39
|
# @example Specifying the cookbook path
|
|
40
40
|
# ChefSpec::SoloRunner.new(cookbook_path: ['/cookbooks'])
|
|
@@ -80,6 +80,7 @@ module ChefSpec
|
|
|
80
80
|
Chef::Config[:force_logger] = true
|
|
81
81
|
Chef::Config[:solo] = true
|
|
82
82
|
Chef::Config[:solo_legacy_mode] = true
|
|
83
|
+
Chef::Config[:use_policyfile] = false
|
|
83
84
|
Chef::Config[:environment_path] = @options[:environment_path]
|
|
84
85
|
|
|
85
86
|
yield node if block_given?
|
data/lib/chefspec/version.rb
CHANGED
data/lib/chefspec/zero_server.rb
CHANGED
|
@@ -16,6 +16,7 @@ module ChefSpec
|
|
|
16
16
|
@server ||= ChefZero::Server.new(
|
|
17
17
|
# Set the log level from RSpec, defaulting to warn
|
|
18
18
|
log_level: RSpec.configuration.log_level || :warn,
|
|
19
|
+
port: RSpec.configuration.server_runner_port,
|
|
19
20
|
|
|
20
21
|
# Set the data store
|
|
21
22
|
data_store: data_store(RSpec.configuration.server_runner_data_store),
|
data/spec/unit/macros_spec.rb
CHANGED
|
@@ -71,8 +71,8 @@ describe ChefSpec::Macros do
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it 'sets the automatic attributes for a specific platform and version' do
|
|
74
|
-
node = described_class.stub_node('node.example', platform: 'ubuntu', version: '
|
|
75
|
-
expect(node.automatic).to eq(Fauxhai.mock(platform: 'ubuntu', version: '
|
|
74
|
+
node = described_class.stub_node('node.example', platform: 'ubuntu', version: '16.04')
|
|
75
|
+
expect(node.automatic).to eq(Fauxhai.mock(platform: 'ubuntu', version: '16.04').data)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it 'sets the automatic attributes from a JSON data path' do
|
|
@@ -70,6 +70,7 @@ describe ChefSpec::SoloRunner do
|
|
|
70
70
|
expect(Chef::Config.force_logger).to be_truthy
|
|
71
71
|
expect(Chef::Config.no_lazy_load).to be_truthy
|
|
72
72
|
expect(Chef::Config.solo).to be_truthy
|
|
73
|
+
expect(Chef::Config.use_policyfile).to be_falsey
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
it 'yields a block to set node attributes' do
|
|
@@ -92,12 +93,12 @@ describe ChefSpec::SoloRunner do
|
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
context 'fauxhai attributes' do
|
|
95
|
-
let(:hash) { described_class.new(platform: 'ubuntu', version: '
|
|
96
|
+
let(:hash) { described_class.new(platform: 'ubuntu', version: '16.04').node.to_hash }
|
|
96
97
|
|
|
97
98
|
it 'sets the attributes from fauxhai' do
|
|
98
99
|
expect(hash['os']).to eq('linux')
|
|
99
100
|
expect(hash['languages']['ruby']['ruby_bin']).to eq('/usr/local/bin/ruby')
|
|
100
|
-
expect(hash['os_version']).to
|
|
101
|
+
expect(hash['os_version']).to match(/4.4.0-.*-generic/) # avoid failing when fauxhai data changes
|
|
101
102
|
expect(hash['fqdn']).to eq('fauxhai.local')
|
|
102
103
|
expect(hash['domain']).to eq('local')
|
|
103
104
|
expect(hash['ipaddress']).to eq('10.0.0.2')
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chefspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Crump
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-
|
|
12
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: chef
|
|
@@ -29,16 +29,22 @@ dependencies:
|
|
|
29
29
|
name: fauxhai
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
34
|
version: '3.6'
|
|
35
|
+
- - "<"
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '5'
|
|
35
38
|
type: :runtime
|
|
36
39
|
prerelease: false
|
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
41
|
requirements:
|
|
39
|
-
- - "
|
|
42
|
+
- - ">="
|
|
40
43
|
- !ruby/object:Gem::Version
|
|
41
44
|
version: '3.6'
|
|
45
|
+
- - "<"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5'
|
|
42
48
|
- !ruby/object:Gem::Dependency
|
|
43
49
|
name: rspec
|
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -528,6 +534,7 @@ files:
|
|
|
528
534
|
- examples/server/spec/client_spec.rb
|
|
529
535
|
- examples/server/spec/data_bag_spec.rb
|
|
530
536
|
- examples/server/spec/environment_spec.rb
|
|
537
|
+
- examples/server/spec/exotic_port_spec.rb
|
|
531
538
|
- examples/server/spec/node_spec.rb
|
|
532
539
|
- examples/server/spec/render_with_cached_spec.rb
|
|
533
540
|
- examples/server/spec/role_spec.rb
|
|
@@ -575,7 +582,9 @@ files:
|
|
|
575
582
|
- examples/stub_data_bag_item/spec/default_spec.rb
|
|
576
583
|
- examples/stub_node/recipes/default.rb
|
|
577
584
|
- examples/stub_node/spec/default_spec.rb
|
|
585
|
+
- examples/stub_search/recipes/block.rb
|
|
578
586
|
- examples/stub_search/recipes/default.rb
|
|
587
|
+
- examples/stub_search/spec/block_spec.rb
|
|
579
588
|
- examples/stub_search/spec/default_spec.rb
|
|
580
589
|
- examples/subscribes/recipes/before.rb
|
|
581
590
|
- examples/subscribes/recipes/chained.rb
|
|
@@ -713,6 +722,7 @@ files:
|
|
|
713
722
|
- features/env.feature
|
|
714
723
|
- features/erl_call.feature
|
|
715
724
|
- features/execute.feature
|
|
725
|
+
- features/exotic_zero_port.feature
|
|
716
726
|
- features/expect_exception.feature
|
|
717
727
|
- features/file.feature
|
|
718
728
|
- features/freebsd_package.feature
|
|
@@ -771,6 +781,7 @@ files:
|
|
|
771
781
|
- features/subversion.feature
|
|
772
782
|
- features/support/env.rb
|
|
773
783
|
- features/support/executor.rb
|
|
784
|
+
- features/support/exotic_zero_port.rb
|
|
774
785
|
- features/support/on_disk.rb
|
|
775
786
|
- features/systemd_unit.feature
|
|
776
787
|
- features/template.feature
|
|
@@ -964,7 +975,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
964
975
|
version: '0'
|
|
965
976
|
requirements: []
|
|
966
977
|
rubyforge_project:
|
|
967
|
-
rubygems_version: 2.6.
|
|
978
|
+
rubygems_version: 2.6.11
|
|
968
979
|
signing_key:
|
|
969
980
|
specification_version: 4
|
|
970
981
|
summary: Write RSpec examples and generate coverage reports for Chef recipes!
|
|
@@ -994,6 +1005,7 @@ test_files:
|
|
|
994
1005
|
- features/env.feature
|
|
995
1006
|
- features/erl_call.feature
|
|
996
1007
|
- features/execute.feature
|
|
1008
|
+
- features/exotic_zero_port.feature
|
|
997
1009
|
- features/expect_exception.feature
|
|
998
1010
|
- features/file.feature
|
|
999
1011
|
- features/freebsd_package.feature
|
|
@@ -1052,6 +1064,7 @@ test_files:
|
|
|
1052
1064
|
- features/subversion.feature
|
|
1053
1065
|
- features/support/env.rb
|
|
1054
1066
|
- features/support/executor.rb
|
|
1067
|
+
- features/support/exotic_zero_port.rb
|
|
1055
1068
|
- features/support/on_disk.rb
|
|
1056
1069
|
- features/systemd_unit.feature
|
|
1057
1070
|
- features/template.feature
|