chefspec 7.3.1 → 7.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/chefspec.gemspec +1 -1
- data/examples/stubs_for/resources/default.rb +8 -1
- data/examples/stubs_for/spec/default_spec.rb +24 -1
- data/lib/chefspec/api/stubs_for.rb +3 -2
- data/lib/chefspec/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4571155e2841a391b08c56d4f7c6f9594a1101a0169d7f152f4d491b6657a4
|
4
|
+
data.tar.gz: 678d85972226787749577775b6f92b41863af50fa7e76d6a6b0e3771994d61d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef50f634ca41ff0c7eaf209cbfe6cc3ff890b2e072141aad3ad21862b5c6239fcf85adca96e5e5e95c18337673e4a4df5ab27d3729f7de4d7e615312d710717
|
7
|
+
data.tar.gz: c1c2c5e2f9bdfffdf6fdb2bc6c113a40a6274d626e4a34196738263cfcf4d73525d3818b271e5b8924e52411f8fd520c4a6c649e7c4f7fa8102c9f91f28a43af
|
data/CHANGELOG.md
CHANGED
data/chefspec.gemspec
CHANGED
@@ -5,6 +5,7 @@ property :value
|
|
5
5
|
property :run_resource, [true, false], default: false
|
6
6
|
property :run_load, [true, false], default: false
|
7
7
|
property :run_provider, [true, false], default: false
|
8
|
+
property :user, default: nil
|
8
9
|
|
9
10
|
def foo
|
10
11
|
shell_out(cmd).stdout
|
@@ -16,5 +17,11 @@ end
|
|
16
17
|
|
17
18
|
action :run do
|
18
19
|
new_resource.foo if new_resource.run_resource
|
19
|
-
|
20
|
+
if new_resource.run_provider
|
21
|
+
if new_resource.user
|
22
|
+
shell_out!(new_resource.cmd, user: new_resource.user)
|
23
|
+
else
|
24
|
+
shell_out!(new_resource.cmd)
|
25
|
+
end
|
26
|
+
end
|
20
27
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
describe 'stubs_for' do
|
2
2
|
platform 'ubuntu'
|
3
3
|
step_into :stubs_for_test, :stubs_for_old
|
4
|
-
default_attributes['test'] = {run_load: false, run_resource: false, run_provider: false}
|
4
|
+
default_attributes['test'] = {run_load: false, run_resource: false, run_provider: false, user: nil}
|
5
5
|
recipe do
|
6
6
|
stubs_for_test 'test' do
|
7
7
|
cmd 'this_is_not_a_cmd'
|
8
8
|
run_load node['test']['run_load']
|
9
9
|
run_resource node['test']['run_resource']
|
10
10
|
run_provider node['test']['run_provider']
|
11
|
+
user node['test']['user']
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -113,6 +114,28 @@ describe 'stubs_for' do
|
|
113
114
|
end
|
114
115
|
subject
|
115
116
|
end
|
117
|
+
|
118
|
+
context 'with a user' do
|
119
|
+
default_attributes['test']['user'] = 'foo'
|
120
|
+
|
121
|
+
it do
|
122
|
+
stubs_for_provider('stubs_for_test[test]') do |prov|
|
123
|
+
allow(prov).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf', user: 'foo')
|
124
|
+
end
|
125
|
+
subject
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'with a user and a generic stub' do
|
130
|
+
default_attributes['test']['user'] = 'foo'
|
131
|
+
|
132
|
+
it do
|
133
|
+
stubs_for_provider('stubs_for_test[test]') do |prov|
|
134
|
+
allow(prov).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
135
|
+
end
|
136
|
+
subject
|
137
|
+
end
|
138
|
+
end
|
116
139
|
end
|
117
140
|
|
118
141
|
context 'with a single group-level resource stub' do
|
@@ -86,7 +86,7 @@ module ChefSpec
|
|
86
86
|
def receive_shell_out(*cmd, stdout: '', stderr: '', exitstatus: 0, **opts)
|
87
87
|
# Ruby does not allow constructing an actual exitstatus object from Ruby code. Really.
|
88
88
|
fake_exitstatus = double(exitstatus: exitstatus)
|
89
|
-
fake_cmd = Mixlib::ShellOut.new(*cmd
|
89
|
+
fake_cmd = Mixlib::ShellOut.new(*cmd)
|
90
90
|
fake_cmd.define_singleton_method(:run_command) { } # Do nothing, just in case.
|
91
91
|
# Inject our canned data.
|
92
92
|
fake_cmd.instance_exec do
|
@@ -100,7 +100,8 @@ module ChefSpec
|
|
100
100
|
else
|
101
101
|
:shell_out
|
102
102
|
end
|
103
|
-
|
103
|
+
with_args = cmd + (opts.empty? ? [any_args] : [hash_including(opts)])
|
104
|
+
receive(shell_out_method).with(*with_args).and_return(fake_cmd)
|
104
105
|
end
|
105
106
|
|
106
107
|
module ClassMethods
|
data/lib/chefspec/version.rb
CHANGED
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: 7.3.
|
4
|
+
version: 7.3.2
|
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: 2018-09-
|
12
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 12.
|
20
|
+
version: 12.16.42
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 12.
|
27
|
+
version: 12.16.42
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: fauxhai
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -797,7 +797,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
797
797
|
version: '0'
|
798
798
|
requirements: []
|
799
799
|
rubyforge_project:
|
800
|
-
rubygems_version: 2.7.
|
800
|
+
rubygems_version: 2.7.6
|
801
801
|
signing_key:
|
802
802
|
specification_version: 4
|
803
803
|
summary: Write RSpec examples and generate coverage reports for Chef recipes!
|