chef-sugar 2.2.0 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffd88ed3296573100935f5c32b367c0b358826c3
4
- data.tar.gz: 9939836e75d3a827c143aa1de882dc476e63d117
3
+ metadata.gz: caa6d7d523f36a96b77fbbb6b405c77fe6245c8c
4
+ data.tar.gz: c300171c8b01b7664afa7660eae39417c63f26f4
5
5
  SHA512:
6
- metadata.gz: 47ab4596120ad672030793e294e2939495b34a853a58972e20b56ae4b55d27dc69aef96dd647f424a992046a37f6e9c2870cd00787efb5a7f8a0536c4f15f056
7
- data.tar.gz: 029757c522fd23b773022f59d3230ff7a523cbc9696f292c8abe0f11eff8e34e9c11f66c0b310d8626781ba7bc450f74a26a7b83e0b1db8ed6dab95f3be6955d
6
+ metadata.gz: 605a75aafd4c650900c9963afbb97dfdc0dcc064ce24737de8d59c11491360d155e18e1cc34d6182564a5d0bc49f94156add3b819559f7eaf48c87ee6b0a483e
7
+ data.tar.gz: 9daa3408b7a6a465c8f59df7a9043d7b726ac7dfefe00845a9113672d5e912f506fdc0156fd1ae858917d9529e8f79d7168737ffe5ddc6afe1b88c55cc2cbd41
@@ -2,6 +2,15 @@ Chef Sugar Changelog
2
2
  =========================
3
3
  This file is used to list changes made in each version of the chef-sugar cookbook and gem.
4
4
 
5
+ v2.3.0 (2014-09-24)
6
+ -------------------
7
+ ### Improvements
8
+ - Add `vmware?` matcher
9
+ - Allow the attribute DSL to access parent attributes
10
+
11
+ ### Bug Fixes
12
+ - Return `true` or `false` from all Boolean methods (instead of `nil` or truthy values)
13
+
5
14
  v2.2.0 (2014-08-20)
6
15
  -------------------
7
16
  ### Improvements
data/README.md CHANGED
@@ -380,6 +380,7 @@ end
380
380
 
381
381
  ### Virtualization
382
382
  - `lxc?`
383
+ - `vmware?`
383
384
 
384
385
  #### Examples
385
386
  ```ruby
@@ -149,12 +149,23 @@ EOH
149
149
  #
150
150
  # @return [nil]
151
151
  # to prevent accidential method chaining if the block isn't closed
152
+ # @return [Object]
153
+ # If no argument is passed in, method becomes an attribute accessor
152
154
  #
153
155
  def method_missing(m, *args, &block)
154
156
  old_method_missing(m, *args, &block)
155
157
  rescue NoMethodError
156
- vivified[m.to_s] = args.size == 1 ? args.first : args
157
- nil
158
+ # The Node Attribute's key is the method name
159
+ key = m.to_s
160
+ # If arguments are passed in, set node attribute with args as the value
161
+ if args.size > 0
162
+ vivified[key] = args.size == 1 ? args.first : args
163
+ return nil
164
+ # If no arguments are passed in, attempt to access corresponding attribute
165
+ else
166
+ deep_key = current_namespace.dup << key
167
+ return deep_fetch!(*deep_key)
168
+ end
158
169
  end
159
170
 
160
171
  private
@@ -83,11 +83,12 @@ class Chef
83
83
  # otherwise
84
84
  #
85
85
  def installed_at_version?(cmd, version, flag = '--version')
86
- which(cmd) && if version.is_a?(Regexp)
87
- version_for(cmd, flag) =~ version
88
- else
89
- version_for(cmd, flag).include?(version)
90
- end
86
+ installed?(cmd) &&
87
+ if version.is_a?(Regexp)
88
+ !version_for(cmd, flag).match(version).nil?
89
+ else
90
+ version_for(cmd, flag).include?(version)
91
+ end
91
92
  end
92
93
 
93
94
  #
@@ -55,7 +55,7 @@ class Chef
55
55
  # @return (see vagrant?)
56
56
  #
57
57
  def vagrant_domain?(node)
58
- node['domain'] && node['domain'].include?('vagrantup.com')
58
+ node.key?('domain') && node['domain'].include?('vagrantup.com')
59
59
  end
60
60
 
61
61
  #
@@ -65,7 +65,7 @@ class Chef
65
65
  # @return (see vagrant?)
66
66
  #
67
67
  def vagrant_user?(node)
68
- node['etc'] && node['etc']['passwd'] && node['etc']['passwd']['vagrant']
68
+ node.key?('etc') && node['etc'].key?('passwd') && !!node['etc']['passwd']['vagrant']
69
69
  end
70
70
  end
71
71
 
@@ -16,6 +16,6 @@
16
16
 
17
17
  class Chef
18
18
  module Sugar
19
- VERSION = '2.2.0'
19
+ VERSION = '2.3.0'
20
20
  end
21
21
  end
@@ -29,13 +29,29 @@ class Chef
29
29
  # otherwise
30
30
  #
31
31
  def lxc?(node)
32
- node['virtualization'] && node['virtualization']['system'] == 'lxc'
32
+ node.key?('virtualization') && node['virtualization']['system'] == 'lxc'
33
+ end
34
+
35
+ #
36
+ # Determine if the current node is running under VMware.
37
+ #
38
+ # @param [Chef::Node] node
39
+ #
40
+ # @return [Boolean]
41
+ # true if the machine is currently running under VMware, false
42
+ # otherwise
43
+ #
44
+ def vmware?(node)
45
+ node.key?('virtualization') && node['virtualization']['system'] == 'vmware'
33
46
  end
34
47
  end
35
48
 
36
49
  module DSL
37
50
  # @see Chef::Sugar::Virtualization#lxc?
38
51
  def lxc?; Chef::Sugar::Virtualization.lxc?(node); end
39
- end
52
+
53
+ # @see Chef::Sugar::Virtualization#vmware?
54
+ def vmware?; Chef::Sugar::Virtualization.vmware?(node); end
55
+ end
40
56
  end
41
57
  end
@@ -14,4 +14,4 @@ For the most up-to-date information and documentation, please visit the [Chef
14
14
  Sugar project page on GitHub](https://github.com/sethvargo/chef-sugar).
15
15
  EOH
16
16
 
17
- version '2.2.0'
17
+ version '2.3.0'
@@ -18,7 +18,7 @@
18
18
  #
19
19
 
20
20
  chef_gem('chef-sugar') do
21
- version '2.0.0'
21
+ version '2.3.0'
22
22
  action :nothing
23
23
  end.run_action(:install)
24
24
 
@@ -6,24 +6,24 @@ describe Chef::Sugar::Architecture do
6
6
  describe '#_64_bit?' do
7
7
  it 'returns true when the system is 64 bit' do
8
8
  node = { 'kernel' => { 'machine' => 'x86_64' } }
9
- expect(described_class._64_bit?(node)).to be_truthy
9
+ expect(described_class._64_bit?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns false when the system is not 64 bit' do
13
13
  node = { 'kernel' => { 'machine' => 'i386' } }
14
- expect(described_class._64_bit?(node)).to be_falsey
14
+ expect(described_class._64_bit?(node)).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#_32_bit?' do
19
19
  it 'returns true when the system is 32 bit' do
20
20
  node = { 'kernel' => { 'machine' => 'i386' } }
21
- expect(described_class._32_bit?(node)).to be_truthy
21
+ expect(described_class._32_bit?(node)).to be true
22
22
  end
23
23
 
24
24
  it 'returns false when the system is not 32 bit' do
25
25
  node = { 'kernel' => { 'machine' => 'x86_64' } }
26
- expect(described_class._32_bit?(node)).to be_falsey
26
+ expect(described_class._32_bit?(node)).to be false
27
27
  end
28
28
  end
29
29
  end
@@ -6,120 +6,120 @@ describe Chef::Sugar::Cloud do
6
6
  describe '#cloud?' do
7
7
  it 'is true when the node is on cloud' do
8
8
  node = { 'cloud' => nil }
9
- expect(described_class.cloud?(node)).to be_truthy
9
+ expect(described_class.cloud?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'is false when the node is not on cloud' do
13
13
  node = {}
14
- expect(described_class.cloud?(node)).to be_falsey
14
+ expect(described_class.cloud?(node)).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#ec2?' do
19
19
  it 'is true when the node is on ec2' do
20
20
  node = { 'ec2' => nil }
21
- expect(described_class.ec2?(node)).to be_truthy
21
+ expect(described_class.ec2?(node)).to be true
22
22
  end
23
23
 
24
24
  it 'is false when the node is not on ec2' do
25
25
  node = {}
26
- expect(described_class.ec2?(node)).to be_falsey
26
+ expect(described_class.ec2?(node)).to be false
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#gce?' do
31
31
  it 'is true when the node is on gce' do
32
32
  node = { 'gce' => nil }
33
- expect(described_class.gce?(node)).to be_truthy
33
+ expect(described_class.gce?(node)).to be true
34
34
  end
35
35
 
36
36
  it 'is false when the node is not on gce' do
37
37
  node = {}
38
- expect(described_class.gce?(node)).to be_falsey
38
+ expect(described_class.gce?(node)).to be false
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#rackspace?' do
43
43
  it 'is true when the node is on rackspace' do
44
44
  node = { 'rackspace' => nil }
45
- expect(described_class.rackspace?(node)).to be_truthy
45
+ expect(described_class.rackspace?(node)).to be true
46
46
  end
47
47
 
48
48
  it 'is false when the node is not on rackspace' do
49
49
  node = {}
50
- expect(described_class.rackspace?(node)).to be_falsey
50
+ expect(described_class.rackspace?(node)).to be false
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#eucalyptus?' do
55
55
  it 'is true when the node is on eucalyptus' do
56
56
  node = { 'eucalyptus' => nil }
57
- expect(described_class.eucalyptus?(node)).to be_truthy
57
+ expect(described_class.eucalyptus?(node)).to be true
58
58
  end
59
59
 
60
60
  it 'is false when the node is not on eucalyptus' do
61
61
  node = {}
62
- expect(described_class.eucalyptus?(node)).to be_falsey
62
+ expect(described_class.eucalyptus?(node)).to be false
63
63
  end
64
64
  end
65
65
 
66
66
  describe '#euca?' do
67
67
  it 'is true when the node is on eucalyptus' do
68
68
  node = { 'eucalyptus' => nil }
69
- expect(described_class.euca?(node)).to be_truthy
69
+ expect(described_class.euca?(node)).to be true
70
70
  end
71
71
 
72
72
  it 'is false when the node is not on eucalyptus' do
73
73
  node = {}
74
- expect(described_class.euca?(node)).to be_falsey
74
+ expect(described_class.euca?(node)).to be false
75
75
  end
76
76
  end
77
77
 
78
78
  describe '#linode?' do
79
79
  it 'is true when the node is on linode' do
80
80
  node = { 'linode' => nil }
81
- expect(described_class.linode?(node)).to be_truthy
81
+ expect(described_class.linode?(node)).to be true
82
82
  end
83
83
 
84
84
  it 'is false when the node is not on linode' do
85
85
  node = {}
86
- expect(described_class.linode?(node)).to be_falsey
86
+ expect(described_class.linode?(node)).to be false
87
87
  end
88
88
  end
89
89
 
90
90
  describe '#openstack?' do
91
91
  it 'is true when the node is on openstack' do
92
92
  node = { 'openstack' => nil }
93
- expect(described_class.openstack?(node)).to be_truthy
93
+ expect(described_class.openstack?(node)).to be true
94
94
  end
95
95
 
96
96
  it 'is false when the node is not on openstack' do
97
97
  node = {}
98
- expect(described_class.openstack?(node)).to be_falsey
98
+ expect(described_class.openstack?(node)).to be false
99
99
  end
100
100
  end
101
101
 
102
102
  describe '#cloudstack?' do
103
103
  it 'is true when the node is on cloudstack' do
104
104
  node = { 'cloudstack' => nil }
105
- expect(described_class.cloudstack?(node)).to be_truthy
105
+ expect(described_class.cloudstack?(node)).to be true
106
106
  end
107
107
 
108
108
  it 'is false when the node is not on cloudstack' do
109
109
  node = {}
110
- expect(described_class.cloudstack?(node)).to be_falsey
110
+ expect(described_class.cloudstack?(node)).to be false
111
111
  end
112
112
  end
113
113
 
114
114
  describe '#azure?' do
115
115
  it 'is true when the node is on azure' do
116
116
  node = { 'azure' => nil }
117
- expect(described_class.azure?(node)).to be_truthy
117
+ expect(described_class.azure?(node)).to be true
118
118
  end
119
119
 
120
120
  it 'is false when the node is not on azure' do
121
121
  node = {}
122
- expect(described_class.azure?(node)).to be_falsey
122
+ expect(described_class.azure?(node)).to be false
123
123
  end
124
124
  end
125
125
  end
@@ -10,7 +10,7 @@ describe Chef::Sugar::Kernel do
10
10
 
11
11
  it 'loads the gem' do
12
12
  allow(Chef::Sugar::Kernel).to receive(:require).and_return(true)
13
- expect(described_class.require_chef_gem('bacon')).to be_truthy
13
+ expect(described_class.require_chef_gem('bacon')).to be true
14
14
  end
15
15
  end
16
16
  end
@@ -4,14 +4,14 @@ describe Chef::Node do
4
4
  describe '#in?' do
5
5
  it 'returns true when the node is in the environment' do
6
6
  allow(subject).to receive(:chef_environment).and_return('production')
7
- expect(subject.in?('production')).to be_truthy
8
- expect(subject.in?(/production$/)).to be_truthy
7
+ expect(subject.in?('production')).to be true
8
+ expect(subject.in?(/production$/)).to be true
9
9
  end
10
10
 
11
11
  it 'returns false when the node is not in the environment' do
12
12
  allow(subject).to receive(:chef_environment).and_return('staging')
13
- expect(subject.in?('production')).to be_falsey
14
- expect(subject.in?(/production$/)).to be_falsey
13
+ expect(subject.in?('production')).to be false
14
+ expect(subject.in?(/production$/)).to be false
15
15
  end
16
16
  end
17
17
 
@@ -99,6 +99,26 @@ describe Chef::Node do
99
99
  }
100
100
  })
101
101
  end
102
+
103
+ it 'can access attributes within itself' do
104
+ node.instance_eval do
105
+ namespace 'apache2' do
106
+ namespace 'config' do
107
+ root '/var/www'
108
+ ssl File.join(root, 'ssl')
109
+ end
110
+ end
111
+ end
112
+
113
+ expect(node.default).to eq({
114
+ 'apache2' => {
115
+ 'config' => {
116
+ 'root' => '/var/www',
117
+ 'ssl' => '/var/www/ssl',
118
+ }
119
+ }
120
+ })
121
+ end
102
122
  end
103
123
 
104
124
  end
@@ -6,159 +6,159 @@ describe Chef::Sugar::PlatformFamily do
6
6
  describe '#arch_linux?' do
7
7
  it 'returns true when the platform_family is arch linux' do
8
8
  node = { 'platform_family' => 'arch' }
9
- expect(described_class.arch_linux?(node)).to be_truthy
9
+ expect(described_class.arch_linux?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns false when the platform_family is not arch linux' do
13
13
  node = { 'platform_family' => 'windows' }
14
- expect(described_class.arch_linux?(node)).to be_falsey
14
+ expect(described_class.arch_linux?(node)).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#debian?' do
19
19
  it 'returns true when the platform_family is debian' do
20
20
  node = { 'platform_family' => 'debian' }
21
- expect(described_class.debian?(node)).to be_truthy
21
+ expect(described_class.debian?(node)).to be true
22
22
  end
23
23
 
24
24
  it 'returns false when the platform_family is not debian' do
25
25
  node = { 'platform_family' => 'windows' }
26
- expect(described_class.debian?(node)).to be_falsey
26
+ expect(described_class.debian?(node)).to be false
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#fedora?' do
31
31
  it 'returns true when the platform_family is fedora' do
32
32
  node = { 'platform_family' => 'fedora' }
33
- expect(described_class.fedora?(node)).to be_truthy
33
+ expect(described_class.fedora?(node)).to be true
34
34
  end
35
35
 
36
36
  it 'returns false when the platform_family is not fedora' do
37
37
  node = { 'platform_family' => 'windows' }
38
- expect(described_class.fedora?(node)).to be_falsey
38
+ expect(described_class.fedora?(node)).to be false
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#freebsd?' do
43
43
  it 'returns true when the platform_family is freebsd' do
44
44
  node = { 'platform_family' => 'freebsd' }
45
- expect(described_class.freebsd?(node)).to be_truthy
45
+ expect(described_class.freebsd?(node)).to be true
46
46
  end
47
47
 
48
48
  it 'returns false when the platform_family is not freebsd' do
49
49
  node = { 'platform_family' => 'windows' }
50
- expect(described_class.freebsd?(node)).to be_falsey
50
+ expect(described_class.freebsd?(node)).to be false
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#gentoo?' do
55
55
  it 'returns true when the platform_family is gentoo' do
56
56
  node = { 'platform_family' => 'gentoo' }
57
- expect(described_class.gentoo?(node)).to be_truthy
57
+ expect(described_class.gentoo?(node)).to be true
58
58
  end
59
59
 
60
60
  it 'returns false when the platform_family is not gentoo' do
61
61
  node = { 'platform_family' => 'windows' }
62
- expect(described_class.gentoo?(node)).to be_falsey
62
+ expect(described_class.gentoo?(node)).to be false
63
63
  end
64
64
  end
65
65
 
66
66
  describe '#mac_os_x?' do
67
67
  it 'returns true when the platform_family is mac_os_x' do
68
68
  node = { 'platform_family' => 'mac_os_x' }
69
- expect(described_class.mac_os_x?(node)).to be_truthy
69
+ expect(described_class.mac_os_x?(node)).to be true
70
70
  end
71
71
 
72
72
  it 'returns false when the platform_family is not mac_os_x' do
73
73
  node = { 'platform_family' => 'windows' }
74
- expect(described_class.mac_os_x?(node)).to be_falsey
74
+ expect(described_class.mac_os_x?(node)).to be false
75
75
  end
76
76
  end
77
77
 
78
78
  describe '#openbsd?' do
79
79
  it 'returns true when the platform_family is openbsd' do
80
80
  node = { 'platform_family' => 'openbsd' }
81
- expect(described_class.openbsd?(node)).to be_truthy
81
+ expect(described_class.openbsd?(node)).to be true
82
82
  end
83
83
 
84
84
  it 'returns false when the platform_family is not openbsd' do
85
85
  node = { 'platform_family' => 'windows' }
86
- expect(described_class.openbsd?(node)).to be_falsey
86
+ expect(described_class.openbsd?(node)).to be false
87
87
  end
88
88
  end
89
89
 
90
90
  describe '#rhel?' do
91
91
  it 'returns true when the platform_family is rhel' do
92
92
  node = { 'platform_family' => 'rhel' }
93
- expect(described_class.rhel?(node)).to be_truthy
93
+ expect(described_class.rhel?(node)).to be true
94
94
  end
95
95
 
96
96
  it 'returns false when the platform_family is not rhel' do
97
97
  node = { 'platform_family' => 'windows' }
98
- expect(described_class.rhel?(node)).to be_falsey
98
+ expect(described_class.rhel?(node)).to be false
99
99
  end
100
100
  end
101
101
 
102
102
  describe '#slackware?' do
103
103
  it 'returns true when the platform_family is slackware' do
104
104
  node = { 'platform_family' => 'slackware' }
105
- expect(described_class.slackware?(node)).to be_truthy
105
+ expect(described_class.slackware?(node)).to be true
106
106
  end
107
107
 
108
108
  it 'returns false when the platform_family is not slackware' do
109
109
  node = { 'platform_family' => 'windows' }
110
- expect(described_class.slackware?(node)).to be_falsey
110
+ expect(described_class.slackware?(node)).to be false
111
111
  end
112
112
  end
113
113
 
114
114
  describe '#suse?' do
115
115
  it 'returns true when the platform_family is suse' do
116
116
  node = { 'platform_family' => 'suse' }
117
- expect(described_class.suse?(node)).to be_truthy
117
+ expect(described_class.suse?(node)).to be true
118
118
  end
119
119
 
120
120
  it 'returns false when the platform_family is not suse' do
121
121
  node = { 'platform_family' => 'windows' }
122
- expect(described_class.suse?(node)).to be_falsey
122
+ expect(described_class.suse?(node)).to be false
123
123
  end
124
124
  end
125
125
 
126
126
  describe '#windows?' do
127
127
  it 'returns true when the platform_family is windows' do
128
128
  node = { 'platform_family' => 'windows' }
129
- expect(described_class.windows?(node)).to be_truthy
129
+ expect(described_class.windows?(node)).to be true
130
130
  end
131
131
 
132
132
  it 'returns false when the platform_family is not windows' do
133
133
  node = { 'platform_family' => 'debian' }
134
- expect(described_class.windows?(node)).to be_falsey
134
+ expect(described_class.windows?(node)).to be false
135
135
  end
136
136
  end
137
137
 
138
138
  describe '#linux?' do
139
139
  it 'returns true when the platform_family is Debian' do
140
140
  node = { 'platform_family' => 'debian' }
141
- expect(described_class.linux?(node)).to be_truthy
141
+ expect(described_class.linux?(node)).to be true
142
142
  end
143
143
 
144
144
  it 'returns true when the platform_family is RedHat' do
145
145
  node = { 'platform_family' => 'rhel' }
146
- expect(described_class.linux?(node)).to be_truthy
146
+ expect(described_class.linux?(node)).to be true
147
147
  end
148
148
 
149
149
  it 'returns false when the platform_family is Windows' do
150
150
  node = { 'platform_family' => 'windows' }
151
- expect(described_class.linux?(node)).to be_falsey
151
+ expect(described_class.linux?(node)).to be false
152
152
  end
153
153
 
154
154
  it 'returns false when the platform_family is OSX' do
155
155
  node = { 'platform_family' => 'mac_os_x' }
156
- expect(described_class.linux?(node)).to be_falsey
156
+ expect(described_class.linux?(node)).to be false
157
157
  end
158
158
 
159
159
  it 'returns false when the platform_family is OpenBSD' do
160
160
  node = { 'platform_family' => 'openbsd' }
161
- expect(described_class.linux?(node)).to be_falsey
161
+ expect(described_class.linux?(node)).to be false
162
162
  end
163
163
  end
164
164
  end
@@ -6,132 +6,132 @@ describe Chef::Sugar::Platform do
6
6
  describe '#linux_mint?' do
7
7
  it 'returns true when the platform is linux mint' do
8
8
  node = { 'platform' => 'linuxmint' }
9
- expect(described_class.linux_mint?(node)).to be_truthy
9
+ expect(described_class.linux_mint?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns false when the platform is not linux mint' do
13
13
  node = { 'platform' => 'windows' }
14
- expect(described_class.linux_mint?(node)).to be_falsey
14
+ expect(described_class.linux_mint?(node)).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#ubuntu?' do
19
19
  it 'returns true when the platform is ubuntu' do
20
20
  node = { 'platform' => 'ubuntu' }
21
- expect(described_class.ubuntu?(node)).to be_truthy
21
+ expect(described_class.ubuntu?(node)).to be true
22
22
  end
23
23
 
24
24
  it 'returns false when the platform is not ubuntu' do
25
25
  node = { 'platform' => 'windows' }
26
- expect(described_class.ubuntu?(node)).to be_falsey
26
+ expect(described_class.ubuntu?(node)).to be false
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#amazon_linux?' do
31
31
  it 'returns true when the platform is amazon linux' do
32
32
  node = { 'platform' => 'amazon' }
33
- expect(described_class.amazon_linux?(node)).to be_truthy
33
+ expect(described_class.amazon_linux?(node)).to be true
34
34
  end
35
35
 
36
36
  it 'returns false when the platform is not amazon linux' do
37
37
  node = { 'platform' => 'windows' }
38
- expect(described_class.amazon_linux?(node)).to be_falsey
38
+ expect(described_class.amazon_linux?(node)).to be false
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#centos?' do
43
43
  it 'returns true when the platform is centos' do
44
44
  node = { 'platform' => 'centos' }
45
- expect(described_class.centos?(node)).to be_truthy
45
+ expect(described_class.centos?(node)).to be true
46
46
  end
47
47
 
48
48
  it 'returns false when the platform is not centos' do
49
49
  node = { 'platform' => 'windows' }
50
- expect(described_class.centos?(node)).to be_falsey
50
+ expect(described_class.centos?(node)).to be false
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#oracle_linux?' do
55
55
  it 'returns true when the platform is oracle linux' do
56
56
  node = { 'platform' => 'oracle' }
57
- expect(described_class.oracle_linux?(node)).to be_truthy
57
+ expect(described_class.oracle_linux?(node)).to be true
58
58
  end
59
59
 
60
60
  it 'returns false when the platform is not oracle linux' do
61
61
  node = { 'platform' => 'windows' }
62
- expect(described_class.oracle_linux?(node)).to be_falsey
62
+ expect(described_class.oracle_linux?(node)).to be false
63
63
  end
64
64
  end
65
65
 
66
66
  describe '#scientific_linux?' do
67
67
  it 'returns true when the platform is scientific linux' do
68
68
  node = { 'platform' => 'scientific' }
69
- expect(described_class.scientific_linux?(node)).to be_truthy
69
+ expect(described_class.scientific_linux?(node)).to be true
70
70
  end
71
71
 
72
72
  it 'returns false when the platform is not scientific linux' do
73
73
  node = { 'platform' => 'windows' }
74
- expect(described_class.scientific_linux?(node)).to be_falsey
74
+ expect(described_class.scientific_linux?(node)).to be false
75
75
  end
76
76
  end
77
77
 
78
78
  describe '#redhat_enterprise_linux?' do
79
79
  it 'returns true when the platform is redhat enterprise linux' do
80
80
  node = { 'platform' => 'enterprise' }
81
- expect(described_class.redhat_enterprise_linux?(node)).to be_truthy
81
+ expect(described_class.redhat_enterprise_linux?(node)).to be true
82
82
  end
83
83
 
84
84
  it 'returns false when the platform is not redhat enterprise linux' do
85
85
  node = { 'platform' => 'windows' }
86
- expect(described_class.redhat_enterprise_linux?(node)).to be_falsey
86
+ expect(described_class.redhat_enterprise_linux?(node)).to be false
87
87
  end
88
88
  end
89
89
 
90
90
  describe '#solaris2?' do
91
91
  it 'returns true when the platform is solaris2' do
92
92
  node = { 'platform' => 'solaris2' }
93
- expect(described_class.solaris2?(node)).to be_truthy
93
+ expect(described_class.solaris2?(node)).to be true
94
94
  end
95
95
 
96
96
  it 'returns false when the platform is not solaris2' do
97
97
  node = { 'platform' => 'windows' }
98
- expect(described_class.solaris2?(node)).to be_falsey
98
+ expect(described_class.solaris2?(node)).to be false
99
99
  end
100
100
  end
101
101
 
102
102
  describe '#aix?' do
103
103
  it 'returns true when the platform is aix' do
104
104
  node = { 'platform' => 'aix' }
105
- expect(described_class.aix?(node)).to be_truthy
105
+ expect(described_class.aix?(node)).to be true
106
106
  end
107
107
 
108
108
  it 'returns false when the platform is not aix' do
109
109
  node = { 'platform' => 'windows' }
110
- expect(described_class.aix?(node)).to be_falsey
110
+ expect(described_class.aix?(node)).to be false
111
111
  end
112
112
  end
113
113
 
114
114
  describe '#smartos?' do
115
115
  it 'returns true when the platform is smartos' do
116
116
  node = { 'platform' => 'smartos' }
117
- expect(described_class.smartos?(node)).to be_truthy
117
+ expect(described_class.smartos?(node)).to be true
118
118
  end
119
119
 
120
120
  it 'returns false when the platform is not smartos' do
121
121
  node = { 'platform' => 'windows' }
122
- expect(described_class.smartos?(node)).to be_falsey
122
+ expect(described_class.smartos?(node)).to be false
123
123
  end
124
124
  end
125
125
 
126
126
  describe '#omnios?' do
127
127
  it 'returns true when the platform is omnios' do
128
128
  node = { 'platform' => 'omnios' }
129
- expect(described_class.omnios?(node)).to be_truthy
129
+ expect(described_class.omnios?(node)).to be true
130
130
  end
131
131
 
132
132
  it 'returns false when the platform is not omnios' do
133
133
  node = { 'platform' => 'windows' }
134
- expect(described_class.omnios?(node)).to be_falsey
134
+ expect(described_class.omnios?(node)).to be false
135
135
  end
136
136
  end
137
137
 
@@ -139,134 +139,134 @@ describe Chef::Sugar::Platform do
139
139
  describe '#ubuntu_after_lucid?' do
140
140
  it 'returns true when the version is later than 10.04' do
141
141
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
142
- expect(described_class.ubuntu_after_lucid?(node)).to be_truthy
142
+ expect(described_class.ubuntu_after_lucid?(node)).to be true
143
143
  end
144
144
 
145
145
  it 'returns false when the version is 10.04' do
146
146
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
147
- expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
147
+ expect(described_class.ubuntu_after_lucid?(node)).to be false
148
148
  end
149
149
 
150
150
  it 'returns false when the version is a patch release higher than 10.04' do
151
151
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
152
- expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
152
+ expect(described_class.ubuntu_after_lucid?(node)).to be false
153
153
  end
154
154
 
155
155
  it 'returns false when the version is less than 10.04' do
156
156
  node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
157
- expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
157
+ expect(described_class.ubuntu_after_lucid?(node)).to be false
158
158
  end
159
159
  end
160
160
 
161
161
  describe '#ubuntu_after_or_at_lucid?' do
162
162
  it 'returns true when the version is later than 10.04' do
163
163
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
164
- expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
164
+ expect(described_class.ubuntu_after_or_at_lucid?(node)).to be true
165
165
  end
166
166
 
167
167
  it 'returns true when the version is 10.04' do
168
168
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
169
- expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
169
+ expect(described_class.ubuntu_after_or_at_lucid?(node)).to be true
170
170
  end
171
171
 
172
172
  it 'returns true when the version is a patch release higher than 10.04' do
173
173
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
174
- expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
174
+ expect(described_class.ubuntu_after_or_at_lucid?(node)).to be true
175
175
  end
176
176
 
177
177
  it 'returns false when the version is less than 10.04' do
178
178
  node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
179
- expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_falsey
179
+ expect(described_class.ubuntu_after_or_at_lucid?(node)).to be false
180
180
  end
181
181
  end
182
182
 
183
183
  describe '#ubuntu_lucid?' do
184
184
  it 'returns false when the version is later than 10.04' do
185
185
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
186
- expect(described_class.ubuntu_lucid?(node)).to be_falsey
186
+ expect(described_class.ubuntu_lucid?(node)).to be false
187
187
  end
188
188
 
189
189
  it 'returns true when the version is 10.04' do
190
190
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
191
- expect(described_class.ubuntu_lucid?(node)).to be_truthy
191
+ expect(described_class.ubuntu_lucid?(node)).to be true
192
192
  end
193
193
 
194
194
  it 'returns true when the version is a patch release higher than 10.04' do
195
195
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
196
- expect(described_class.ubuntu_lucid?(node)).to be_truthy
196
+ expect(described_class.ubuntu_lucid?(node)).to be true
197
197
  end
198
198
 
199
199
  it 'returns false when the version is less than 10.04' do
200
200
  node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
201
- expect(described_class.ubuntu_lucid?(node)).to be_falsey
201
+ expect(described_class.ubuntu_lucid?(node)).to be false
202
202
  end
203
203
  end
204
204
 
205
205
  describe '#ubuntu_before_lucid?' do
206
206
  it 'returns false when the version is later than 10.04' do
207
207
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
208
- expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
208
+ expect(described_class.ubuntu_before_lucid?(node)).to be false
209
209
  end
210
210
 
211
211
  it 'returns false when the version is 10.04' do
212
212
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
213
- expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
213
+ expect(described_class.ubuntu_before_lucid?(node)).to be false
214
214
  end
215
215
 
216
216
  it 'returns false when the version is a patch release higher than 10.04' do
217
217
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
218
- expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
218
+ expect(described_class.ubuntu_before_lucid?(node)).to be false
219
219
  end
220
220
 
221
221
  it 'returns true when the version is less than 10.04' do
222
222
  node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
223
- expect(described_class.ubuntu_before_lucid?(node)).to be_truthy
223
+ expect(described_class.ubuntu_before_lucid?(node)).to be true
224
224
  end
225
225
  end
226
226
 
227
227
  describe '#ubuntu_before_or_at_lucid?' do
228
228
  it 'returns false when the version is later than 10.04' do
229
229
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
230
- expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_falsey
230
+ expect(described_class.ubuntu_before_or_at_lucid?(node)).to be false
231
231
  end
232
232
 
233
233
  it 'returns true when the version is 10.04' do
234
234
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
235
- expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
235
+ expect(described_class.ubuntu_before_or_at_lucid?(node)).to be true
236
236
  end
237
237
 
238
238
  it 'returns true when the version is a patch release higher than 10.04' do
239
239
  node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
240
- expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
240
+ expect(described_class.ubuntu_before_or_at_lucid?(node)).to be true
241
241
  end
242
242
 
243
243
  it 'returns true when the version is less than 10.04' do
244
244
  node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
245
- expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
245
+ expect(described_class.ubuntu_before_or_at_lucid?(node)).to be true
246
246
  end
247
247
  end
248
248
 
249
249
  describe '#debian_wheezy?' do
250
250
  it 'returns true when the version is a subset of the major' do
251
251
  node = { 'platform' => 'debian', 'platform_version' => '7.1' }
252
- expect(described_class.debian_wheezy?(node)).to be_truthy
252
+ expect(described_class.debian_wheezy?(node)).to be true
253
253
  end
254
254
 
255
255
  it 'returns false when the version is not the major' do
256
256
  node = { 'platform' => 'debian', 'platform_version' => '6.1' }
257
- expect(described_class.debian_wheezy?(node)).to be_falsey
257
+ expect(described_class.debian_wheezy?(node)).to be false
258
258
  end
259
259
  end
260
260
 
261
261
  describe '#debian_before_wheezy?' do
262
262
  it 'returns true when the version is a less than the major' do
263
263
  node = { 'platform' => 'debian', 'platform_version' => '6.5' }
264
- expect(described_class.debian_before_wheezy?(node)).to be_truthy
264
+ expect(described_class.debian_before_wheezy?(node)).to be true
265
265
  end
266
266
 
267
267
  it 'returns false when the version is not less than the major' do
268
268
  node = { 'platform' => 'debian', 'platform_version' => '8.0' }
269
- expect(described_class.debian_before_wheezy?(node)).to be_falsey
269
+ expect(described_class.debian_before_wheezy?(node)).to be false
270
270
  end
271
271
  end
272
272
  end
@@ -6,34 +6,34 @@ describe Chef::Sugar::Ruby do
6
6
  describe '#ruby_20?' do
7
7
  it 'returns true when the ruby version is 2.0' do
8
8
  node = { 'languages' => { 'ruby' => { 'version' => '2.0.0' } } }
9
- expect(described_class.ruby_20?(node)).to be_truthy
9
+ expect(described_class.ruby_20?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns true when the ruby version is less than 2.0' do
13
13
  node = { 'languages' => { 'ruby' => { 'version' => '1.9.3' } } }
14
- expect(described_class.ruby_20?(node)).to be_falsey
14
+ expect(described_class.ruby_20?(node)).to be false
15
15
  end
16
16
 
17
17
  it 'returns false when the ruby version is higher than 2.0' do
18
18
  node = { 'languages' => { 'ruby' => { 'version' => '3.0.0' } } }
19
- expect(described_class.ruby_20?(node)).to be_falsey
19
+ expect(described_class.ruby_20?(node)).to be false
20
20
  end
21
21
  end
22
22
 
23
23
  describe '#ruby_19?' do
24
24
  it 'returns true when the ruby version is 1.9' do
25
25
  node = { 'languages' => { 'ruby' => { 'version' => '1.9.1' } } }
26
- expect(described_class.ruby_19?(node)).to be_truthy
26
+ expect(described_class.ruby_19?(node)).to be true
27
27
  end
28
28
 
29
29
  it 'returns true when the ruby version is less than 1.9' do
30
30
  node = { 'languages' => { 'ruby' => { 'version' => '1.8.7' } } }
31
- expect(described_class.ruby_19?(node)).to be_falsey
31
+ expect(described_class.ruby_19?(node)).to be false
32
32
  end
33
33
 
34
34
  it 'returns false when the ruby version is higher than 1.9' do
35
35
  node = { 'languages' => { 'ruby' => { 'version' => '2.0.0' } } }
36
- expect(described_class.ruby_19?(node)).to be_falsey
36
+ expect(described_class.ruby_19?(node)).to be false
37
37
  end
38
38
  end
39
39
  end
@@ -8,12 +8,12 @@ describe Chef::Sugar::RunContext do
8
8
 
9
9
  it 'returns true when the recipe exists' do
10
10
  allow(node).to receive(:recipe?).and_return(true)
11
- expect(described_class.includes_recipe?(node, 'foo')).to be_truthy
11
+ expect(described_class.includes_recipe?(node, 'foo')).to be true
12
12
  end
13
13
 
14
14
  it 'returns false when the recipe does not exist' do
15
15
  allow(node).to receive(:recipe?).and_return(false)
16
- expect(described_class.includes_recipe?(node, 'bar')).to be_falsey
16
+ expect(described_class.includes_recipe?(node, 'bar')).to be false
17
17
  end
18
18
  end
19
19
  end
@@ -42,12 +42,12 @@ describe Chef::Sugar::Shell do
42
42
  it 'returns true if the given binary exists' do
43
43
  allow(described_class).to receive(:which).and_return(nil)
44
44
  allow(described_class).to receive(:which).with('mongo').and_return(true)
45
- expect(described_class.installed?('mongo')).to be_truthy
45
+ expect(described_class.installed?('mongo')).to be true
46
46
  end
47
47
 
48
48
  it 'returns false if the given binary does not exist' do
49
49
  allow(File).to receive(:executable?).and_return(false)
50
- expect(described_class.installed?('node')).to be_falsey
50
+ expect(described_class.installed?('node')).to be false
51
51
  end
52
52
  end
53
53
 
@@ -55,30 +55,30 @@ describe Chef::Sugar::Shell do
55
55
  it 'returns true if the command is installed at the correct version' do
56
56
  allow(described_class).to receive(:which).and_return(true)
57
57
  allow(described_class).to receive(:version_for).and_return('1.2.3')
58
- expect(described_class.installed_at_version?('mongo', '1.2.3')).to be_truthy
58
+ expect(described_class.installed_at_version?('mongo', '1.2.3')).to be true
59
59
  end
60
60
 
61
61
  it 'returns true if the command is installed at the correct version and has additional output' do
62
62
  allow(described_class).to receive(:which).and_return(true)
63
63
  allow(described_class).to receive(:version_for).and_return('Mongo DB version 1.2.3. Some other text.')
64
- expect(described_class.installed_at_version?('mongo', '1.2.3')).to be_truthy
64
+ expect(described_class.installed_at_version?('mongo', '1.2.3')).to be true
65
65
  end
66
66
 
67
67
  it 'returns true if the command is installed at the correct version with a regex' do
68
68
  allow(described_class).to receive(:which).and_return(true)
69
69
  allow(described_class).to receive(:version_for).and_return('1.2.3')
70
- expect(described_class.installed_at_version?('mongo', /1\.2/)).to be_truthy
70
+ expect(described_class.installed_at_version?('mongo', /1\.2/)).to be true
71
71
  end
72
72
 
73
73
  it 'returns false if the command is installed at the wrong version' do
74
74
  allow(described_class).to receive(:which).and_return(true)
75
75
  allow(described_class).to receive(:version_for).and_return('1.2.3')
76
- expect(described_class.installed_at_version?('mongo', '4.5.6')).to be_falsey
76
+ expect(described_class.installed_at_version?('mongo', '4.5.6')).to be false
77
77
  end
78
78
 
79
79
  it 'returns false if the command is not installed' do
80
80
  allow(described_class).to receive(:which).and_return(nil)
81
- expect(described_class.installed_at_version?('mongo', '1.0.0')).to be_falsey
81
+ expect(described_class.installed_at_version?('mongo', '1.0.0')).to be false
82
82
  end
83
83
  end
84
84
 
@@ -6,22 +6,22 @@ describe Chef::Sugar::Vagrant do
6
6
  describe '#vagrant?' do
7
7
  it 'returns true when the machine is on vagrant' do
8
8
  node = { 'vagrant' => {} }
9
- expect(described_class.vagrant?(node)).to be_truthy
9
+ expect(described_class.vagrant?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns true when the domain is vagrantup.com' do
13
13
  node = { 'domain' => 'bacon.vagrantup.com' }
14
- expect(described_class.vagrant?(node)).to be_truthy
14
+ expect(described_class.vagrant?(node)).to be true
15
15
  end
16
16
 
17
17
  it 'returns true when the vagrant user exists on the system' do
18
18
  node = { 'etc' => { 'passwd' => { 'vagrant' => {} } } }
19
- expect(described_class.vagrant?(node)).to be_truthy
19
+ expect(described_class.vagrant?(node)).to be true
20
20
  end
21
21
 
22
22
  it 'returns false when the machine is not on vagrant' do
23
23
  node = {}
24
- expect(described_class.vagrant?(node)).to be_falsey
24
+ expect(described_class.vagrant?(node)).to be false
25
25
  end
26
26
  end
27
27
  end
@@ -6,17 +6,34 @@ describe Chef::Sugar::Virtualization do
6
6
  describe '#lxc?' do
7
7
  it 'returns true when the machine is a linux contianer' do
8
8
  node = { 'virtualization' => { 'system' => 'lxc' } }
9
- expect(described_class.lxc?(node)).to be_truthy
9
+ expect(described_class.lxc?(node)).to be true
10
10
  end
11
11
 
12
12
  it 'returns false when the virtual machine is not lxc' do
13
13
  node = { 'virtualization' => { 'system' => 'vbox' } }
14
- expect(described_class.lxc?(node)).to be_falsey
14
+ expect(described_class.lxc?(node)).to be false
15
15
  end
16
16
 
17
17
  it 'returns false when the machine is not virtual' do
18
18
  node = {}
19
- expect(described_class.lxc?(node)).to be_falsey
19
+ expect(described_class.lxc?(node)).to be false
20
+ end
21
+ end
22
+
23
+ describe '#vmware?' do
24
+ it 'returns true when the machine is under vmware' do
25
+ node = { 'virtualization' => { 'system' => 'vmware' } }
26
+ expect(described_class.vmware?(node)).to be true
27
+ end
28
+
29
+ it 'returns false when the virtual machine is not under vmware' do
30
+ node = { 'virtualization' => { 'system' => 'vbox' } }
31
+ expect(described_class.vmware?(node)).to be false
32
+ end
33
+
34
+ it 'returns false when the machine is not virtual' do
35
+ node = {}
36
+ expect(described_class.vmware?(node)).to be false
20
37
  end
21
38
  end
22
39
  end
@@ -4,6 +4,6 @@ describe 'chef-sugar::default' do
4
4
  let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
5
5
 
6
6
  it 'installs the chef gem' do
7
- expect(chef_run).to install_chef_gem('chef-sugar')
7
+ expect(chef_run).to install_chef_gem('chef-sugar').with(version: Chef::Sugar::VERSION)
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-sugar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler