chef-sugar 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/CHANGELOG.md +16 -2
- data/README.md +4 -4
- data/chef-sugar.gemspec +1 -1
- data/lib/chef/sugar/platform.rb +1 -0
- data/lib/chef/sugar/platform_family.rb +9 -3
- data/lib/chef/sugar/shell.rb +11 -6
- data/lib/chef/sugar/version.rb +1 -1
- data/metadata.rb +1 -1
- data/recipes/default.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/chef/sugar/architecture_spec.rb +4 -4
- data/spec/unit/chef/sugar/cloud_spec.rb +20 -20
- data/spec/unit/chef/sugar/data_bag_spec.rb +5 -5
- data/spec/unit/chef/sugar/kernel_spec.rb +2 -2
- data/spec/unit/chef/sugar/node_spec.rb +6 -6
- data/spec/unit/chef/sugar/platform_family_spec.rb +41 -26
- data/spec/unit/chef/sugar/platform_spec.rb +38 -38
- data/spec/unit/chef/sugar/ruby_spec.rb +6 -6
- data/spec/unit/chef/sugar/run_context_spec.rb +4 -4
- data/spec/unit/chef/sugar/shell_spec.rb +35 -23
- data/spec/unit/chef/sugar/vagrant_spec.rb +4 -4
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93e0d5081147bfd7cd05eb8091c27da520a831e8
|
4
|
+
data.tar.gz: ae8139070b27cca2c83659be2d1bf23b14e31157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2b69db6e0c2ec129c90bb89ba67c48fb65b68cbb83da240ddb22b72d0285b0b019a35733f8f61cb7c32e42ff8f3444a665f259fa04479c088d27a307d40ea9
|
7
|
+
data.tar.gz: da5c22f889074fd2e7d8c3f46f9429ae95524c521bd50e31c9af446ea14a4471176968da07579d67c1d7c69df5cd415b9e7edbbfa0c71c36b38470d49e18def4
|
data/.hound.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,22 @@ 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
|
-
|
6
|
-
|
5
|
+
v2.0.0 (2014-06-16)
|
6
|
+
-------------------
|
7
|
+
### Breaking
|
8
|
+
- Remove `not_linux?` method
|
9
|
+
- Remove `not_windows?` method
|
10
|
+
|
11
|
+
### Improvements
|
12
|
+
- Miscellaneous spelling fixes
|
13
|
+
- Update a failing unit test for `installed?`
|
14
|
+
- Add Mac OS X to the list of platforms (Yosemite)
|
15
|
+
- Upgrade to RSpec 3
|
16
|
+
- Fix `which` (and `installed?` and `installed_at_version?`) when given an absolute path
|
17
|
+
- Fix `linux?` check to only return true on real linuxes
|
18
|
+
|
19
|
+
v1.3.0 (2014-05-05)
|
20
|
+
-------------------
|
7
21
|
- Check both `$stdout` and `$stderr` in `version_for`
|
8
22
|
- Add additional platform versions
|
9
23
|
- Make `includes_recipe?` a top-level API (instead of just Node)
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ include_recipe 'chef-sugar::default'
|
|
42
42
|
|
43
43
|
Alternatively you can put it in a base role or recipe and it will be included subsequently.
|
44
44
|
|
45
|
-
Requiring the Chef Sugar Gem will automatically extend the Recipe DSL, `Chef::Resource`, and `Chef::Provider` with helpful
|
45
|
+
Requiring the Chef Sugar Gem will automatically extend the Recipe DSL, `Chef::Resource`, and `Chef::Provider` with helpful convenience methods.
|
46
46
|
|
47
47
|
### Module Method
|
48
48
|
If you are working outside of the Recipe DSL, you can use the module methods instead of the Recipe DSL. In general, the module methods have the same name as their Recipe-DSL counterparts, but require the node object as a parameter. For example:
|
@@ -181,7 +181,7 @@ end
|
|
181
181
|
```
|
182
182
|
|
183
183
|
### Constraints
|
184
|
-
- `
|
184
|
+
- `constraints` - create a new constraint (or requirement) that can be used to test version validations.
|
185
185
|
- `chef_version` - (DSL only) a wrapper for `version(Chef::VERSION)`
|
186
186
|
- `version` - create a new version that can be used to test constraint validation.
|
187
187
|
|
@@ -210,7 +210,7 @@ end
|
|
210
210
|
```
|
211
211
|
|
212
212
|
### Kernel
|
213
|
-
- `require_chef_gem` - "safely" require a gem. Loading a gem with Chef is sometimes difficult and confusing. The errors that Chef produces are also sometimes not very intuitive. In the event you require a gem to exist on the system, you can use `require_chef_gem`, which
|
213
|
+
- `require_chef_gem` - "safely" require a gem. Loading a gem with Chef is sometimes difficult and confusing. The errors that Chef produces are also sometimes not very intuitive. In the event you require a gem to exist on the system, you can use `require_chef_gem`, which will attempt to require the gem and then produce helpful output if the gem is not installed:
|
214
214
|
|
215
215
|
Chef could not load the gem `#{name}'! You may need to install the gem
|
216
216
|
manually with `gem install #{name}', or include a recipe before you can
|
@@ -320,7 +320,7 @@ node['attribute'] = if windows?
|
|
320
320
|
```
|
321
321
|
|
322
322
|
### Ruby
|
323
|
-
**Note:** The applies to the
|
323
|
+
**Note:** The applies to the Ruby found at `node['languages']['ruby']`.
|
324
324
|
|
325
325
|
- `ruby_20?`
|
326
326
|
- `ruby_19?`
|
data/chef-sugar.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
28
28
|
spec.add_development_dependency 'rake'
|
29
29
|
|
30
|
-
spec.add_development_dependency 'chefspec', '~>
|
30
|
+
spec.add_development_dependency 'chefspec', '~> 4.0'
|
31
31
|
spec.add_development_dependency 'test-kitchen', '~> 1.1'
|
32
32
|
spec.add_development_dependency 'kitchen-vagrant', '~> 0.14'
|
33
33
|
end
|
data/lib/chef/sugar/platform.rb
CHANGED
@@ -143,7 +143,6 @@ class Chef
|
|
143
143
|
def windows?(node)
|
144
144
|
node['platform_family'] == 'windows'
|
145
145
|
end
|
146
|
-
alias_method :not_linux?, :windows?
|
147
146
|
|
148
147
|
#
|
149
148
|
# Determine if the current system is a linux derivative
|
@@ -153,9 +152,16 @@ class Chef
|
|
153
152
|
# @return [Boolean]
|
154
153
|
#
|
155
154
|
def linux?(node)
|
156
|
-
|
155
|
+
%w(
|
156
|
+
arch
|
157
|
+
debian
|
158
|
+
fedora
|
159
|
+
gentoo
|
160
|
+
rhel
|
161
|
+
slackware
|
162
|
+
suse
|
163
|
+
).include?(node['platform_family'])
|
157
164
|
end
|
158
|
-
alias_method :not_windows?, :linux?
|
159
165
|
end
|
160
166
|
|
161
167
|
module DSL
|
data/lib/chef/sugar/shell.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require 'mixlib/shellout'
|
18
|
+
require 'pathname'
|
18
19
|
|
19
20
|
class Chef
|
20
21
|
module Sugar
|
@@ -30,14 +31,18 @@ class Chef
|
|
30
31
|
# @return [String, nil]
|
31
32
|
#
|
32
33
|
def which(cmd)
|
33
|
-
|
34
|
+
if Pathname.new(cmd).absolute?
|
35
|
+
File.executable?(cmd) ? cmd : nil
|
36
|
+
else
|
37
|
+
paths = ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin)
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
paths.each do |path|
|
40
|
+
possible = File.join(path, cmd)
|
41
|
+
return possible if File.executable?(possible)
|
42
|
+
end
|
39
43
|
|
40
|
-
|
44
|
+
nil
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
#
|
data/lib/chef/sugar/version.rb
CHANGED
data/metadata.rb
CHANGED
data/recipes/default.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -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
|
9
|
+
expect(described_class._64_bit?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class._64_bit?(node)).to be_falsey
|
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
|
21
|
+
expect(described_class._32_bit?(node)).to be_truthy
|
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
|
26
|
+
expect(described_class._32_bit?(node)).to be_falsey
|
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
|
9
|
+
expect(described_class.cloud?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class.cloud?(node)).to be_falsey
|
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
|
21
|
+
expect(described_class.ec2?(node)).to be_truthy
|
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
|
26
|
+
expect(described_class.ec2?(node)).to be_falsey
|
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
|
33
|
+
expect(described_class.gce?(node)).to be_truthy
|
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
|
38
|
+
expect(described_class.gce?(node)).to be_falsey
|
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
|
45
|
+
expect(described_class.rackspace?(node)).to be_truthy
|
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
|
50
|
+
expect(described_class.rackspace?(node)).to be_falsey
|
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
|
57
|
+
expect(described_class.eucalyptus?(node)).to be_truthy
|
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
|
62
|
+
expect(described_class.eucalyptus?(node)).to be_falsey
|
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
|
69
|
+
expect(described_class.euca?(node)).to be_truthy
|
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
|
74
|
+
expect(described_class.euca?(node)).to be_falsey
|
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
|
81
|
+
expect(described_class.linode?(node)).to be_truthy
|
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
|
86
|
+
expect(described_class.linode?(node)).to be_falsey
|
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
|
93
|
+
expect(described_class.openstack?(node)).to be_truthy
|
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
|
98
|
+
expect(described_class.openstack?(node)).to be_falsey
|
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
|
105
|
+
expect(described_class.cloudstack?(node)).to be_truthy
|
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
|
110
|
+
expect(described_class.cloudstack?(node)).to be_falsey
|
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
|
117
|
+
expect(described_class.azure?(node)).to be_truthy
|
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
|
122
|
+
expect(described_class.azure?(node)).to be_falsey
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Chef::Sugar::DataBag do
|
4
4
|
describe '#encrypted_data_bag_item' do
|
5
|
-
before { Chef::EncryptedDataBagItem.
|
5
|
+
before { allow(Chef::EncryptedDataBagItem).to receive(:load) }
|
6
6
|
|
7
7
|
it 'loads the encrypted data bag item' do
|
8
8
|
expect(Chef::EncryptedDataBagItem).to receive(:load)
|
@@ -13,8 +13,8 @@ describe Chef::Sugar::DataBag do
|
|
13
13
|
|
14
14
|
context 'when Chef::Config is set' do
|
15
15
|
it 'loads the secret key from the Chef::Config' do
|
16
|
-
Chef::Config.
|
17
|
-
File.
|
16
|
+
allow(Chef::Config).to receive(:[]).with(:encrypted_data_bag_secret).and_return('/data/path')
|
17
|
+
allow(File).to receive(:read).with('/data/path').and_return('B@c0n')
|
18
18
|
|
19
19
|
expect(Chef::EncryptedDataBagItem).to receive(:load)
|
20
20
|
.with('accounts', 'github', 'B@c0n')
|
@@ -37,7 +37,7 @@ describe Chef::Sugar::DataBag do
|
|
37
37
|
|
38
38
|
context 'when the environment exists' do
|
39
39
|
it 'loads the data from the environment' do
|
40
|
-
Chef::EncryptedDataBagItem.
|
40
|
+
allow(Chef::EncryptedDataBagItem).to receive(:load).and_return(
|
41
41
|
'production' => {
|
42
42
|
'username' => 'sethvargo',
|
43
43
|
'password' => 'bacon',
|
@@ -53,7 +53,7 @@ describe Chef::Sugar::DataBag do
|
|
53
53
|
|
54
54
|
context 'when the environment does not exist' do
|
55
55
|
it 'loads the data from the default bucket' do
|
56
|
-
Chef::EncryptedDataBagItem.
|
56
|
+
allow(Chef::EncryptedDataBagItem).to receive(:load).and_return(
|
57
57
|
'staging' => {
|
58
58
|
'username' => 'sethvargo',
|
59
59
|
'password' => 'bacon',
|
@@ -9,8 +9,8 @@ describe Chef::Sugar::Kernel do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'loads the gem' do
|
12
|
-
Chef::Sugar::Kernel.
|
13
|
-
expect(described_class.require_chef_gem('bacon')).to
|
12
|
+
allow(Chef::Sugar::Kernel).to receive(:require).and_return(true)
|
13
|
+
expect(described_class.require_chef_gem('bacon')).to be_truthy
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -3,15 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe Chef::Node do
|
4
4
|
describe '#in?' do
|
5
5
|
it 'returns true when the node is in the environment' do
|
6
|
-
subject.
|
7
|
-
expect(subject.in?('production')).to
|
8
|
-
expect(subject.in?(/production$/)).to
|
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
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns false when the node is not in the environment' do
|
12
|
-
subject.
|
13
|
-
expect(subject.in?('production')).to
|
14
|
-
expect(subject.in?(/production$/)).to
|
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
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -6,144 +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
|
9
|
+
expect(described_class.arch_linux?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class.arch_linux?(node)).to be_falsey
|
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
|
21
|
+
expect(described_class.debian?(node)).to be_truthy
|
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
|
26
|
+
expect(described_class.debian?(node)).to be_falsey
|
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
|
33
|
+
expect(described_class.fedora?(node)).to be_truthy
|
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
|
38
|
+
expect(described_class.fedora?(node)).to be_falsey
|
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
|
45
|
+
expect(described_class.freebsd?(node)).to be_truthy
|
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
|
50
|
+
expect(described_class.freebsd?(node)).to be_falsey
|
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
|
57
|
+
expect(described_class.gentoo?(node)).to be_truthy
|
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
|
62
|
+
expect(described_class.gentoo?(node)).to be_falsey
|
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
|
69
|
+
expect(described_class.mac_os_x?(node)).to be_truthy
|
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
|
74
|
+
expect(described_class.mac_os_x?(node)).to be_falsey
|
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
|
81
|
+
expect(described_class.openbsd?(node)).to be_truthy
|
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
|
86
|
+
expect(described_class.openbsd?(node)).to be_falsey
|
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
|
93
|
+
expect(described_class.rhel?(node)).to be_truthy
|
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
|
98
|
+
expect(described_class.rhel?(node)).to be_falsey
|
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
|
105
|
+
expect(described_class.slackware?(node)).to be_truthy
|
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
|
110
|
+
expect(described_class.slackware?(node)).to be_falsey
|
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
|
117
|
+
expect(described_class.suse?(node)).to be_truthy
|
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
|
122
|
+
expect(described_class.suse?(node)).to be_falsey
|
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
|
129
|
+
expect(described_class.windows?(node)).to be_truthy
|
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
|
134
|
+
expect(described_class.windows?(node)).to be_falsey
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
describe '#linux?' do
|
139
|
-
it 'returns true when the platform_family is
|
139
|
+
it 'returns true when the platform_family is Debian' do
|
140
140
|
node = { 'platform_family' => 'debian' }
|
141
|
-
expect(described_class.
|
141
|
+
expect(described_class.linux?(node)).to be_truthy
|
142
142
|
end
|
143
143
|
|
144
|
-
it 'returns
|
144
|
+
it 'returns true when the platform_family is RedHat' do
|
145
|
+
node = { 'platform_family' => 'rhel' }
|
146
|
+
expect(described_class.linux?(node)).to be_truthy
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns false when the platform_family is Windows' do
|
145
150
|
node = { 'platform_family' => 'windows' }
|
146
|
-
expect(described_class.
|
151
|
+
expect(described_class.linux?(node)).to be_falsey
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'returns false when the platform_family is OSX' do
|
155
|
+
node = { 'platform_family' => 'mac_os_x' }
|
156
|
+
expect(described_class.linux?(node)).to be_falsey
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'returns false when the platform_family is OpenBSD' do
|
160
|
+
node = { 'platform_family' => 'openbsd' }
|
161
|
+
expect(described_class.linux?(node)).to be_falsey
|
147
162
|
end
|
148
163
|
end
|
149
164
|
end
|
@@ -6,84 +6,84 @@ 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
|
9
|
+
expect(described_class.linux_mint?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class.linux_mint?(node)).to be_falsey
|
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
|
21
|
+
expect(described_class.ubuntu?(node)).to be_truthy
|
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
|
26
|
+
expect(described_class.ubuntu?(node)).to be_falsey
|
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
|
33
|
+
expect(described_class.amazon_linux?(node)).to be_truthy
|
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
|
38
|
+
expect(described_class.amazon_linux?(node)).to be_falsey
|
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
|
45
|
+
expect(described_class.centos?(node)).to be_truthy
|
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
|
50
|
+
expect(described_class.centos?(node)).to be_falsey
|
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
|
57
|
+
expect(described_class.oracle_linux?(node)).to be_truthy
|
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
|
62
|
+
expect(described_class.oracle_linux?(node)).to be_falsey
|
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
|
69
|
+
expect(described_class.scientific_linux?(node)).to be_truthy
|
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
|
74
|
+
expect(described_class.scientific_linux?(node)).to be_falsey
|
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
|
81
|
+
expect(described_class.redhat_enterprise_linux?(node)).to be_truthy
|
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
|
86
|
+
expect(described_class.redhat_enterprise_linux?(node)).to be_falsey
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -91,134 +91,134 @@ describe Chef::Sugar::Platform do
|
|
91
91
|
describe '#ubuntu_after_lucid?' do
|
92
92
|
it 'returns true when the version is later than 10.04' do
|
93
93
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
|
94
|
-
expect(described_class.ubuntu_after_lucid?(node)).to
|
94
|
+
expect(described_class.ubuntu_after_lucid?(node)).to be_truthy
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'returns false when the version is 10.04' do
|
98
98
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
|
99
|
-
expect(described_class.ubuntu_after_lucid?(node)).to
|
99
|
+
expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'returns false when the version is a patch release higher than 10.04' do
|
103
103
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
|
104
|
-
expect(described_class.ubuntu_after_lucid?(node)).to
|
104
|
+
expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'returns false when the version is less than 10.04' do
|
108
108
|
node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
|
109
|
-
expect(described_class.ubuntu_after_lucid?(node)).to
|
109
|
+
expect(described_class.ubuntu_after_lucid?(node)).to be_falsey
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe '#ubuntu_after_or_at_lucid?' do
|
114
114
|
it 'returns true when the version is later than 10.04' do
|
115
115
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
|
116
|
-
expect(described_class.ubuntu_after_or_at_lucid?(node)).to
|
116
|
+
expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'returns true when the version is 10.04' do
|
120
120
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
|
121
|
-
expect(described_class.ubuntu_after_or_at_lucid?(node)).to
|
121
|
+
expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'returns true when the version is a patch release higher than 10.04' do
|
125
125
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
|
126
|
-
expect(described_class.ubuntu_after_or_at_lucid?(node)).to
|
126
|
+
expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_truthy
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'returns false when the version is less than 10.04' do
|
130
130
|
node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
|
131
|
-
expect(described_class.ubuntu_after_or_at_lucid?(node)).to
|
131
|
+
expect(described_class.ubuntu_after_or_at_lucid?(node)).to be_falsey
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
describe '#ubuntu_lucid?' do
|
136
136
|
it 'returns false when the version is later than 10.04' do
|
137
137
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
|
138
|
-
expect(described_class.ubuntu_lucid?(node)).to
|
138
|
+
expect(described_class.ubuntu_lucid?(node)).to be_falsey
|
139
139
|
end
|
140
140
|
|
141
141
|
it 'returns true when the version is 10.04' do
|
142
142
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
|
143
|
-
expect(described_class.ubuntu_lucid?(node)).to
|
143
|
+
expect(described_class.ubuntu_lucid?(node)).to be_truthy
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'returns true when the version is a patch release higher than 10.04' do
|
147
147
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
|
148
|
-
expect(described_class.ubuntu_lucid?(node)).to
|
148
|
+
expect(described_class.ubuntu_lucid?(node)).to be_truthy
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'returns false when the version is less than 10.04' do
|
152
152
|
node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
|
153
|
-
expect(described_class.ubuntu_lucid?(node)).to
|
153
|
+
expect(described_class.ubuntu_lucid?(node)).to be_falsey
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
157
|
describe '#ubuntu_before_lucid?' do
|
158
158
|
it 'returns false when the version is later than 10.04' do
|
159
159
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
|
160
|
-
expect(described_class.ubuntu_before_lucid?(node)).to
|
160
|
+
expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
|
161
161
|
end
|
162
162
|
|
163
163
|
it 'returns false when the version is 10.04' do
|
164
164
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
|
165
|
-
expect(described_class.ubuntu_before_lucid?(node)).to
|
165
|
+
expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'returns false when the version is a patch release higher than 10.04' do
|
169
169
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
|
170
|
-
expect(described_class.ubuntu_before_lucid?(node)).to
|
170
|
+
expect(described_class.ubuntu_before_lucid?(node)).to be_falsey
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'returns true when the version is less than 10.04' do
|
174
174
|
node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
|
175
|
-
expect(described_class.ubuntu_before_lucid?(node)).to
|
175
|
+
expect(described_class.ubuntu_before_lucid?(node)).to be_truthy
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
describe '#ubuntu_before_or_at_lucid?' do
|
180
180
|
it 'returns false when the version is later than 10.04' do
|
181
181
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.10' }
|
182
|
-
expect(described_class.ubuntu_before_or_at_lucid?(node)).to
|
182
|
+
expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_falsey
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'returns true when the version is 10.04' do
|
186
186
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04' }
|
187
|
-
expect(described_class.ubuntu_before_or_at_lucid?(node)).to
|
187
|
+
expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'returns true when the version is a patch release higher than 10.04' do
|
191
191
|
node = { 'platform' => 'ubuntu', 'platform_version' => '10.04.4' }
|
192
|
-
expect(described_class.ubuntu_before_or_at_lucid?(node)).to
|
192
|
+
expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
|
193
193
|
end
|
194
194
|
|
195
195
|
it 'returns true when the version is less than 10.04' do
|
196
196
|
node = { 'platform' => 'ubuntu', 'platform_version' => '9.10' }
|
197
|
-
expect(described_class.ubuntu_before_or_at_lucid?(node)).to
|
197
|
+
expect(described_class.ubuntu_before_or_at_lucid?(node)).to be_truthy
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
201
|
describe '#debian_wheezy?' do
|
202
202
|
it 'returns true when the version is a subset of the major' do
|
203
203
|
node = { 'platform' => 'debian', 'platform_version' => '7.1' }
|
204
|
-
expect(described_class.debian_wheezy?(node)).to
|
204
|
+
expect(described_class.debian_wheezy?(node)).to be_truthy
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'returns false when the version is not the major' do
|
208
208
|
node = { 'platform' => 'debian', 'platform_version' => '6.1' }
|
209
|
-
expect(described_class.debian_wheezy?(node)).to
|
209
|
+
expect(described_class.debian_wheezy?(node)).to be_falsey
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
213
|
describe '#debian_before_wheezy?' do
|
214
214
|
it 'returns true when the version is a less than the major' do
|
215
215
|
node = { 'platform' => 'debian', 'platform_version' => '6.5' }
|
216
|
-
expect(described_class.debian_before_wheezy?(node)).to
|
216
|
+
expect(described_class.debian_before_wheezy?(node)).to be_truthy
|
217
217
|
end
|
218
218
|
|
219
219
|
it 'returns false when the version is not less than the major' do
|
220
220
|
node = { 'platform' => 'debian', 'platform_version' => '8.0' }
|
221
|
-
expect(described_class.debian_before_wheezy?(node)).to
|
221
|
+
expect(described_class.debian_before_wheezy?(node)).to be_falsey
|
222
222
|
end
|
223
223
|
end
|
224
224
|
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
|
9
|
+
expect(described_class.ruby_20?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class.ruby_20?(node)).to be_falsey
|
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
|
19
|
+
expect(described_class.ruby_20?(node)).to be_falsey
|
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
|
26
|
+
expect(described_class.ruby_19?(node)).to be_truthy
|
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
|
31
|
+
expect(described_class.ruby_19?(node)).to be_falsey
|
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
|
36
|
+
expect(described_class.ruby_19?(node)).to be_falsey
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -7,13 +7,13 @@ describe Chef::Sugar::RunContext do
|
|
7
7
|
let(:node) { double(Chef::Node) }
|
8
8
|
|
9
9
|
it 'returns true when the recipe exists' do
|
10
|
-
node.
|
11
|
-
expect(described_class.includes_recipe?(node, 'foo')).to
|
10
|
+
allow(node).to receive(:recipe?).and_return(true)
|
11
|
+
expect(described_class.includes_recipe?(node, 'foo')).to be_truthy
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'returns false when the recipe does not exist' do
|
15
|
-
node.
|
16
|
-
expect(described_class.includes_recipe?(node, 'bar')).to
|
15
|
+
allow(node).to receive(:recipe?).and_return(false)
|
16
|
+
expect(described_class.includes_recipe?(node, 'bar')).to be_falsey
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,15 +3,27 @@ require 'spec_helper'
|
|
3
3
|
describe Chef::Sugar::Shell do
|
4
4
|
describe '#which' do
|
5
5
|
it 'returns the first executable matching the command' do
|
6
|
-
File.
|
7
|
-
File.
|
6
|
+
allow(File).to receive(:executable?).and_return(false)
|
7
|
+
allow(File).to receive(:executable?).with('/usr/bin/mongo').and_return(true)
|
8
8
|
expect(described_class.which('mongo')).to eq('/usr/bin/mongo')
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns nil when no command is found' do
|
12
|
-
File.
|
12
|
+
allow(File).to receive(:executable?).and_return(false)
|
13
13
|
expect(described_class.which('node')).to be_nil
|
14
14
|
end
|
15
|
+
|
16
|
+
context 'with an absolute path' do
|
17
|
+
it 'returns the executable if it exists' do
|
18
|
+
allow(File).to receive(:executable?).with('/usr/local/bin/bash').and_return(true)
|
19
|
+
expect(described_class.which('/usr/local/bin/bash')).to eq('/usr/local/bin/bash')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns nil when the file is not executable' do
|
23
|
+
allow(File).to receive(:executable?).with('/usr/local/bin/bash').and_return(false)
|
24
|
+
expect(described_class.which('/usr/local/bin/bash')).to be_nil
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
29
|
describe '#dev_null' do
|
@@ -28,51 +40,51 @@ describe Chef::Sugar::Shell do
|
|
28
40
|
|
29
41
|
describe '#installed?' do
|
30
42
|
it 'returns true if the given binary exists' do
|
31
|
-
|
32
|
-
|
33
|
-
expect(described_class.installed?('mongo')).to
|
43
|
+
allow(described_class).to receive(:which).and_return(nil)
|
44
|
+
allow(described_class).to receive(:which).with('mongo').and_return(true)
|
45
|
+
expect(described_class.installed?('mongo')).to be_truthy
|
34
46
|
end
|
35
47
|
|
36
48
|
it 'returns false if the given binary does not exist' do
|
37
|
-
File.
|
38
|
-
expect(described_class.installed?('node')).to
|
49
|
+
allow(File).to receive(:executable?).and_return(false)
|
50
|
+
expect(described_class.installed?('node')).to be_falsey
|
39
51
|
end
|
40
52
|
end
|
41
53
|
|
42
54
|
describe '#installed_at_version?' do
|
43
55
|
it 'returns true if the command is installed at the correct version' do
|
44
|
-
described_class.
|
45
|
-
described_class.
|
46
|
-
expect(described_class.installed_at_version?('mongo', '1.2.3')).to
|
56
|
+
allow(described_class).to receive(:which).and_return(true)
|
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
|
47
59
|
end
|
48
60
|
|
49
61
|
it 'returns true if the command is installed at the correct version and has additional output' do
|
50
|
-
described_class.
|
51
|
-
described_class.
|
52
|
-
expect(described_class.installed_at_version?('mongo', '1.2.3')).to
|
62
|
+
allow(described_class).to receive(:which).and_return(true)
|
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
|
53
65
|
end
|
54
66
|
|
55
67
|
it 'returns true if the command is installed at the correct version with a regex' do
|
56
|
-
described_class.
|
57
|
-
described_class.
|
58
|
-
expect(described_class.installed_at_version?('mongo', /1\.2/)).to
|
68
|
+
allow(described_class).to receive(:which).and_return(true)
|
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
|
59
71
|
end
|
60
72
|
|
61
73
|
it 'returns false if the command is installed at the wrong version' do
|
62
|
-
described_class.
|
63
|
-
described_class.
|
64
|
-
expect(described_class.installed_at_version?('mongo', '4.5.6')).to
|
74
|
+
allow(described_class).to receive(:which).and_return(true)
|
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
|
65
77
|
end
|
66
78
|
|
67
79
|
it 'returns false if the command is not installed' do
|
68
|
-
described_class.
|
69
|
-
expect(described_class.installed_at_version?('mongo', '1.0.0')).to
|
80
|
+
allow(described_class).to receive(:which).and_return(nil)
|
81
|
+
expect(described_class.installed_at_version?('mongo', '1.0.0')).to be_falsey
|
70
82
|
end
|
71
83
|
end
|
72
84
|
|
73
85
|
describe '#version_for' do
|
74
86
|
let(:shell_out) { double('shell_out', run_command: nil, error!: nil, stdout: '1.2.3', stderr: 'Oh no!') }
|
75
|
-
before { Mixlib::ShellOut.
|
87
|
+
before { allow(Mixlib::ShellOut).to receive(:new).and_return(shell_out) }
|
76
88
|
|
77
89
|
it 'runs the thing in shellout' do
|
78
90
|
expect(Mixlib::ShellOut).to receive(:new).with('mongo --version')
|
@@ -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
|
9
|
+
expect(described_class.vagrant?(node)).to be_truthy
|
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
|
14
|
+
expect(described_class.vagrant?(node)).to be_truthy
|
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
|
19
|
+
expect(described_class.vagrant?(node)).to be_truthy
|
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
|
24
|
+
expect(described_class.vagrant?(node)).to be_falsey
|
25
25
|
end
|
26
26
|
end
|
27
27
|
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:
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: test-kitchen
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,6 +90,7 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- ".gitignore"
|
93
|
+
- ".hound.yml"
|
93
94
|
- ".kitchen.yml"
|
94
95
|
- ".travis.yml"
|
95
96
|
- CHANGELOG.md
|