chefspec 7.3.0 → 7.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4149e5d01cef76e9961206a3c21e026f8d1514c5411d4e736775494e7df2fd5e
4
- data.tar.gz: 1c2f041d3734fb0d1b4311652e545753ae93e13ac1d5699287754a2005ab30c5
3
+ metadata.gz: e61ac80763278adaab322cc1801df9673c5ea2d49df59bc7c26977a9e3405923
4
+ data.tar.gz: e64079926befe6e129ebfa265f9aa3c9c942f628ea8365cf5bd627ecb09c25ed
5
5
  SHA512:
6
- metadata.gz: 86b9445a05713b120154104b065300b29944c2178277c0dbaf57271baed0d675b9582272c73044101cc36625b7ff9e1d189efff6f8525dbac2aed5ba225be0fd
7
- data.tar.gz: 6dc383647ef0ca7f97c3a4ecfbe68a4323949a95d03c8ee853c80000682a7eab9deebed4db231cedd7ba0765c37d18a3304e145ed012739b6a5283b927f43889
6
+ metadata.gz: 014e1bbaa47b6a88e6cb5f488d5ea25ff012694c0f7f97d18c12048d7377a9f204cb114ff9e68c7e4d4a575293bed12cc432ac623f516028db48c72cb090dfb8
7
+ data.tar.gz: e7d54267e71d29d6fb57a1518d38ba4df4959fc6e49b967dc9860f2dbaedc39fcb12fb15704846b544daf3d017514a91ff7526849d1b13bc1869f4f193b84d06
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG for ChefSpec
2
2
 
3
+ ## 7.3.1 (September 1, 2018)
4
+
5
+ - Add additional hooks for customizing the runner creation process.
6
+
3
7
  ## 7.3.0 (August 30, 2018)
4
8
 
5
9
  - Major syntax overhaul and update. Check out the [README](/README.md) for examples of the updated syntax. The older syntax is still present and will be supported at least until ChefSpec 8.0, but documentation has been moved to [README_old](/README_old.md).
@@ -51,4 +51,13 @@ describe 'spec_attributes' do
51
51
  it { is_expected.to write_log('thing1=un thing2=two version=3.0') }
52
52
  end
53
53
  end
54
+
55
+ context 'before attributes' do
56
+ before do
57
+ chefspec_default_attributes['myapp'] ||= {}
58
+ chefspec_default_attributes['myapp']['version'] = '4.0'
59
+ end
60
+
61
+ it { is_expected.to write_log('version=4.0') }
62
+ end
54
63
  end
@@ -14,27 +14,33 @@ module ChefSpec
14
14
  # Only run the preload if a platform is configured via the new system
15
15
  # since otherwise it will spam warnings about the platform not being
16
16
  # set.
17
- chef_runner.preload! if chefspec_platform
17
+ chef_runner_instance.preload! if chefspec_platform
18
18
  ex.run
19
19
  ensure
20
20
  $CHEFSPEC_MODE = old_chefspec_mode
21
21
  end
22
22
  end
23
23
 
24
- # Let variables to set the platform in a scoped way. Used below by
24
+ # Let variables to set data in a scoped way. Used below by
25
25
  # {ClassMethods#platform}.
26
+ let(:chefspec_default_attributes) { chefspec_attributes(:default_attributes) }
27
+ let(:chefspec_normal_attributes) { chefspec_attributes(:normal_attributes) }
28
+ let(:chefspec_override_attributes) { chefspec_attributes(:override_attributes) }
29
+ let(:chefspec_automatic_attributes) { chefspec_attributes(:automatic_attributes) }
26
30
  let(:chefspec_platform) { nil }
27
31
  let(:chefspec_platform_version) { nil }
28
32
 
29
- # Set up the runner object but don't actually run anything yet. This can
30
- # be overridden if needed to set up very custom things.
31
- let(:chef_runner) do
33
+ # Compute the options for the runner.
34
+ #
35
+ # @abstract
36
+ # @return [Hash<Symbol, Object>]
37
+ def chef_runner_options
32
38
  options = {
33
39
  step_into: chefspec_ancestor_gather([], :step_into) {|memo, val| memo | val },
34
- default_attributes: chefspec_attributes(:default_attributes),
35
- normal_attributes: chefspec_attributes(:normal_attributes),
36
- override_attributes: chefspec_attributes(:override_attributes),
37
- automatic_attributes: chefspec_attributes(:automatic_attributes),
40
+ default_attributes: chefspec_default_attributes,
41
+ normal_attributes: chefspec_normal_attributes,
42
+ override_attributes: chefspec_override_attributes,
43
+ automatic_attributes: chefspec_automatic_attributes,
38
44
  spec_declaration_locations: self.class.declaration_locations.last[0],
39
45
  }
40
46
  # Only specify these if set in the example so we don't override the
@@ -43,16 +49,32 @@ module ChefSpec
43
49
  options[:version] = chefspec_platform_version if chefspec_platform_version
44
50
  # Merge in any final overrides.
45
51
  options.update(chefspec_attributes(:chefspec_options).symbolize_keys)
46
- # At some point this is probably going to need a flag for ServerRunner
47
- # because someone will complain.
48
- ChefSpec::SoloRunner.new(options)
52
+ options
49
53
  end
50
54
 
51
- # By default, run the recipe in the base `describe` block.
52
- let(:chef_run) do
53
- chef_runner.converge(described_recipe)
55
+ # Class of runner to use.
56
+ #
57
+ # @abstract
58
+ # @return [Class]
59
+ def chef_runner_class
60
+ ChefSpec::SoloRunner
61
+ end
62
+
63
+ # Create an instance of the runner.
64
+ #
65
+ # This should only be used in cases where the `let()` cache would be a problem.
66
+ #
67
+ # @return [ChefSpec::SoloRunner]
68
+ def chef_runner_instance
69
+ chef_runner_class.new(chef_runner_options)
54
70
  end
55
71
 
72
+ # Set up the runner object but don't actually run anything yet.
73
+ let(:chef_runner) { chef_runner_instance }
74
+
75
+ # By default, run the recipe in the base `describe` block.
76
+ let(:chef_run) { chef_runner.converge(described_recipe) }
77
+
56
78
  # Helper method for some of the nestable test value methods like
57
79
  # {ClassMethods#default_attributes} and {ClassMethods#step_into}.
58
80
  #
@@ -1,3 +1,3 @@
1
1
  module ChefSpec
2
- VERSION = '7.3.0'
2
+ VERSION = '7.3.1'
3
3
  end
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.0
4
+ version: 7.3.1
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-08-30 00:00:00.000000000 Z
12
+ date: 2018-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef