puppet 4.0.0.rc1-x64-mingw32 → 4.0.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +11 -6
- data/Gemfile +1 -1
- data/conf/environment.conf +4 -2
- data/ext/build_defaults.yaml +3 -3
- data/ext/debian/control +2 -2
- data/ext/project_data.yaml +1 -1
- data/ext/rack/config.ru +1 -0
- data/ext/redhat/client.sysconfig +1 -1
- data/ext/redhat/puppet.spec.erb +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +2 -2
- data/lib/puppet/application/device.rb +22 -5
- data/lib/puppet/data_providers.rb +7 -4
- data/lib/puppet/data_providers/data_adapter.rb +6 -1
- data/lib/puppet/data_providers/data_function_support.rb +17 -4
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -1
- data/lib/puppet/data_providers/function_module_data_provider.rb +14 -19
- data/lib/puppet/defaults.rb +43 -16
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +33 -4
- data/lib/puppet/pops/evaluator/runtime3_support.rb +5 -1
- data/lib/puppet/pops/parser/egrammar.ra +2 -0
- data/lib/puppet/pops/parser/eparser.rb +732 -724
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/lexer2.rb +19 -21
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +19 -6
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +17 -0
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +2 -2
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/util/errors.rb +4 -2
- data/lib/puppet/util/network_device/config.rb +5 -0
- data/lib/puppet/util/run_mode.rb +28 -11
- data/lib/puppet/util/windows/registry.rb +3 -3
- data/lib/puppet/vendor/deep_merge/PUPPET_README.md +6 -0
- data/lib/puppet/vendor/load_plist.rb +1 -0
- data/lib/puppet/vendor/plist/CHANGELOG +82 -0
- data/lib/puppet/vendor/plist/MIT-LICENSE +21 -0
- data/lib/puppet/vendor/plist/PUPPET_README.md +6 -0
- data/lib/puppet/vendor/plist/README +36 -0
- data/lib/puppet/vendor/plist/Rakefile +144 -0
- data/lib/puppet/vendor/plist/docs/USAGE +104 -0
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +591 -0
- data/lib/puppet/vendor/plist/lib/plist.rb +22 -0
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +224 -0
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +225 -0
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +203 -0
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +104 -0
- data/lib/puppet/vendor/plist/test/assets/commented.plist +9 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +259 -0
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +24 -0
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +13 -0
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +115 -0
- data/lib/puppet/vendor/plist/test/test_generator.rb +59 -0
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +58 -0
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +82 -0
- data/lib/puppet/vendor/plist/test/test_parser.rb +90 -0
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +5 -13
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-file.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-inspect.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-resource_type.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/lib/puppet/functions/environment/data.rb +8 -6
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +4 -4
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +6 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/no_provider/manifests/init.pp +2 -0
- data/spec/integration/provider/yumrepo_spec.rb +127 -0
- data/spec/unit/application/device_spec.rb +52 -14
- data/spec/unit/functions/lookup_spec.rb +95 -55
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +0 -18
- data/spec/unit/pops/parser/lexer2_spec.rb +26 -16
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +21 -0
- data/spec/unit/pops/validator/validator_spec.rb +2 -3
- data/spec/unit/provider/macauthorization_spec.rb +1 -1
- data/spec/unit/provider/package/gem_spec.rb +201 -139
- data/spec/unit/provider/package/puppet_gem_spec.rb +67 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
- data/spec/unit/util/network_device/config_spec.rb +6 -0
- data/spec/unit/util/run_mode_spec.rb +26 -26
- data/spec/unit/util/windows/registry_spec.rb +4 -3
- metadata +3016 -2994
@@ -63,7 +63,7 @@ describe 'function for dynamically creating resources' do
|
|
63
63
|
it 'should fail to add non-existing type' do
|
64
64
|
expect do
|
65
65
|
@scope.function_create_resources(['create-resource-foo', { 'foo' => {} }])
|
66
|
-
end.to raise_error(
|
66
|
+
end.to raise_error(/Invalid resource type create-resource-foo/)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should be able to add edges' do
|
@@ -607,24 +607,6 @@ describe 'Injector' do
|
|
607
607
|
expect { injector.lookup(scope, 'broken_family2')}.to raise_error(/:uniq/)
|
608
608
|
end
|
609
609
|
|
610
|
-
it "a higher priority contribution is selected when resolution is :priority" do
|
611
|
-
hash_of_duck = type_factory.hash_of(duck_type)
|
612
|
-
multibind_id = "ducks"
|
613
|
-
|
614
|
-
bindings.multibind(multibind_id).type(hash_of_duck).name('donalds_nephews')
|
615
|
-
|
616
|
-
mb1 = bindings.bind.in_multibind(multibind_id)
|
617
|
-
pending 'priority based on layers not added, and priority on category removed'
|
618
|
-
mb1.type(duck_type).name('nephew').to(InjectorSpecModule::NamedDuck, 'Huey')
|
619
|
-
|
620
|
-
mb2 = bindings.bind.in_multibind(multibind_id)
|
621
|
-
mb2.type(duck_type).name('nephew').to(InjectorSpecModule::NamedDuck, 'Dewey')
|
622
|
-
|
623
|
-
binder.define_layers(layered_bindings)
|
624
|
-
|
625
|
-
expect(injector(binder).lookup(scope, hash_of_duck, "donalds_nephews")['nephew'].name).to eq('Huey')
|
626
|
-
end
|
627
|
-
|
628
610
|
it "a higher priority contribution wins when resolution is :merge" do
|
629
611
|
# THIS TEST MAY DEPEND ON HASH ORDER SINCE PRIORITY BASED ON CATEGORY IS REMOVED
|
630
612
|
hash_of_data = type_factory.hash_of_data()
|
@@ -118,10 +118,8 @@ describe 'Lexer2' do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
[ '_x::y', 'x::_y'].each do |string|
|
121
|
-
it "should consider the bare word '#{string}' to be a
|
122
|
-
expect
|
123
|
-
tokens_scanned_from(string)
|
124
|
-
}.to raise_error(/Illegal fully qualified name/)
|
121
|
+
it "should consider the bare word '#{string}' to be a WORD" do
|
122
|
+
expect(tokens_scanned_from(string)).to match_tokens2(:WORD)
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
@@ -209,21 +207,33 @@ describe 'Lexer2' do
|
|
209
207
|
end
|
210
208
|
end
|
211
209
|
|
212
|
-
{ '"a$x b"'
|
213
|
-
|
214
|
-
|
210
|
+
{ '"a$x b"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>2 }],
|
211
|
+
[:VARIABLE, 'x', {:line => 1, :pos=>3, :length=>2 }],
|
212
|
+
[:DQPOST, ' b', {:line => 1, :pos=>5, :length=>3 }]],
|
215
213
|
|
216
|
-
'"a$x.b"'
|
217
|
-
|
218
|
-
|
214
|
+
'"a$x.b"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>2 }],
|
215
|
+
[:VARIABLE, 'x', {:line => 1, :pos=>3, :length=>2 }],
|
216
|
+
[:DQPOST, '.b', {:line => 1, :pos=>5, :length=>3 }]],
|
219
217
|
|
220
|
-
'"$x.b"'
|
221
|
-
|
222
|
-
|
218
|
+
'"$x.b"' => [[:DQPRE, '', {:line => 1, :pos=>1, :length=>1 }],
|
219
|
+
[:VARIABLE, 'x', {:line => 1, :pos=>2, :length=>2 }],
|
220
|
+
[:DQPOST, '.b', {:line => 1, :pos=>4, :length=>3 }]],
|
223
221
|
|
224
|
-
'"a$x"'
|
225
|
-
|
226
|
-
|
222
|
+
'"a$x"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>2 }],
|
223
|
+
[:VARIABLE, 'x', {:line => 1, :pos=>3, :length=>2 }],
|
224
|
+
[:DQPOST, '', {:line => 1, :pos=>5, :length=>1 }]],
|
225
|
+
|
226
|
+
'"a${x}"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>4 }],
|
227
|
+
[:VARIABLE, 'x', {:line => 1, :pos=>5, :length=>1 }],
|
228
|
+
[:DQPOST, '', {:line => 1, :pos=>7, :length=>1 }]],
|
229
|
+
|
230
|
+
'"a${_x}"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>4 }],
|
231
|
+
[:VARIABLE, '_x', {:line => 1, :pos=>5, :length=>2 }],
|
232
|
+
[:DQPOST, '', {:line => 1, :pos=>8, :length=>1 }]],
|
233
|
+
|
234
|
+
'"a${y::_x}"' => [[:DQPRE, 'a', {:line => 1, :pos=>1, :length=>4 }],
|
235
|
+
[:VARIABLE, 'y::_x', {:line => 1, :pos=>5, :length=>5 }],
|
236
|
+
[:DQPOST, '', {:line => 1, :pos=>11, :length=>1 }]],
|
227
237
|
}.each do |source, expected|
|
228
238
|
it "should lex an interpolated variable 'x' from #{source}" do
|
229
239
|
expect(tokens_scanned_from(source)).to match_tokens2(*expected)
|
@@ -114,4 +114,25 @@ describe "egrammar parsing heredoc" do
|
|
114
114
|
].join("\n"))
|
115
115
|
end
|
116
116
|
|
117
|
+
it 'parses multiple heredocs on the same line' do
|
118
|
+
src = <<-CODE
|
119
|
+
notice({ @(foo) => @(bar) })
|
120
|
+
hello
|
121
|
+
-foo
|
122
|
+
world
|
123
|
+
-bar
|
124
|
+
notice '!'
|
125
|
+
CODE
|
126
|
+
expect(dump(parse(src))).to eq([
|
127
|
+
'(block',
|
128
|
+
' (invoke notice ({} ((@()',
|
129
|
+
' (sublocated \' hello\')',
|
130
|
+
' ) (@()',
|
131
|
+
' (sublocated \' world\')',
|
132
|
+
' ))))',
|
133
|
+
' (invoke notice \'!\')',
|
134
|
+
')'
|
135
|
+
].join("\n"))
|
136
|
+
end
|
137
|
+
|
117
138
|
end
|
@@ -19,9 +19,8 @@ describe "validating 4x" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should raise error for illegal names' do
|
22
|
-
|
23
|
-
expect(validate(
|
24
|
-
expect(validate(fqn('AAA'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_NAME)
|
22
|
+
expect(validate(parse('class aaa::_bbb {}'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
|
23
|
+
expect(validate(parse('class Aaa {}'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'should raise error for illegal variable names' do
|
@@ -3,184 +3,246 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
provider_class = Puppet::Type.type(:package).provider(:gem)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
let(:provider) do
|
15
|
-
provider = provider_class.new
|
16
|
-
provider.resource = resource
|
17
|
-
provider
|
18
|
-
end
|
19
|
-
|
20
|
-
before :each do
|
21
|
-
resource.provider = provider
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "when installing" do
|
25
|
-
it "should use the path to the gem" do
|
26
|
-
provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
|
27
|
-
provider.expects(:execute).with { |args| args[0] == "/my/gem" }.returns ""
|
28
|
-
provider.install
|
6
|
+
context 'installing myresource' do
|
7
|
+
describe provider_class do
|
8
|
+
let(:resource) do
|
9
|
+
Puppet::Type.type(:package).new(
|
10
|
+
:name => 'myresource',
|
11
|
+
:ensure => :installed
|
12
|
+
)
|
29
13
|
end
|
30
14
|
|
31
|
-
|
32
|
-
provider
|
33
|
-
provider.
|
15
|
+
let(:provider) do
|
16
|
+
provider = provider_class.new
|
17
|
+
provider.resource = resource
|
18
|
+
provider
|
34
19
|
end
|
35
20
|
|
36
|
-
|
37
|
-
provider
|
38
|
-
provider.install
|
21
|
+
before :each do
|
22
|
+
resource.provider = provider
|
39
23
|
end
|
40
24
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
describe "when installing" do
|
26
|
+
it "should use the path to the gem" do
|
27
|
+
provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
|
28
|
+
provider.expects(:execute).with { |args| args[0] == "/my/gem" }.returns ""
|
29
|
+
provider.install
|
30
|
+
end
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
it "should specify that the gem is being installed" do
|
33
|
+
provider.expects(:execute).with { |args| args[1] == "install" }.returns ""
|
34
|
+
provider.install
|
35
|
+
end
|
50
36
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
37
|
+
it "should specify that documentation should not be included" do
|
38
|
+
provider.expects(:execute).with { |args| args[2] == "--no-rdoc" }.returns ""
|
39
|
+
provider.install
|
40
|
+
end
|
55
41
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
42
|
+
it "should specify that RI should not be included" do
|
43
|
+
provider.expects(:execute).with { |args| args[3] == "--no-ri" }.returns ""
|
44
|
+
provider.install
|
45
|
+
end
|
61
46
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
resource[:source] = "/my/file"
|
66
|
-
provider.expects(:execute).with { |args| args[2] == "/my/file" }.returns ""
|
67
|
-
provider.install
|
68
|
-
end
|
47
|
+
it "should specify the package name" do
|
48
|
+
provider.expects(:execute).with { |args| args[4] == "myresource" }.returns ""
|
49
|
+
provider.install
|
69
50
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
provider.install
|
75
|
-
end
|
51
|
+
|
52
|
+
it "should not append install_options by default" do
|
53
|
+
provider.expects(:execute).with { |args| args.length == 5 }.returns ""
|
54
|
+
provider.install
|
76
55
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
56
|
+
|
57
|
+
it "should allow setting an install_options parameter" do
|
58
|
+
resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
|
59
|
+
provider.expects(:execute).with { |args| args[5] == '--force' && args[6] == '--bindir=/usr/bin' }.returns ''
|
60
|
+
provider.install
|
82
61
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
62
|
+
|
63
|
+
describe "when a source is specified" do
|
64
|
+
describe "as a normal file" do
|
65
|
+
it "should use the file name instead of the gem name" do
|
66
|
+
resource[:source] = "/my/file"
|
67
|
+
provider.expects(:execute).with { |args| args[2] == "/my/file" }.returns ""
|
68
|
+
provider.install
|
69
|
+
end
|
88
70
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
71
|
+
describe "as a file url" do
|
72
|
+
it "should use the file name instead of the gem name" do
|
73
|
+
resource[:source] = "file:///my/file"
|
74
|
+
provider.expects(:execute).with { |args| args[2] == "/my/file" }.returns ""
|
75
|
+
provider.install
|
76
|
+
end
|
77
|
+
end
|
78
|
+
describe "as a puppet url" do
|
79
|
+
it "should fail" do
|
80
|
+
resource[:source] = "puppet://my/file"
|
81
|
+
expect { provider.install }.to raise_error(Puppet::Error)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
describe "as a non-file and non-puppet url" do
|
85
|
+
it "should treat the source as a gem repository" do
|
86
|
+
resource[:source] = "http://host/my/file"
|
87
|
+
provider.expects(:execute).with { |args| args[2..4] == ["--source", "http://host/my/file", "myresource"] }.returns ""
|
88
|
+
provider.install
|
89
|
+
end
|
90
|
+
end
|
91
|
+
describe "with an invalid uri" do
|
92
|
+
it "should fail" do
|
93
|
+
URI.expects(:parse).raises(ArgumentError)
|
94
|
+
resource[:source] = "http:::::uppet:/:/my/file"
|
95
|
+
expect { provider.install }.to raise_error(Puppet::Error)
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
98
|
-
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
describe "#latest" do
|
102
|
+
it "should return a single value for 'latest'" do
|
103
|
+
#gemlist is used for retrieving both local and remote version numbers, and there are cases
|
104
|
+
# (particularly local) where it makes sense for it to return an array. That doesn't make
|
105
|
+
# sense for '#latest', though.
|
106
|
+
provider.class.expects(:gemlist).with({ :justme => 'myresource'}).returns({
|
106
107
|
:name => 'myresource',
|
107
108
|
:ensure => ["3.0"],
|
108
109
|
:provider => :gem,
|
109
|
-
|
110
|
-
|
111
|
-
|
110
|
+
})
|
111
|
+
expect(provider.latest).to eq("3.0")
|
112
|
+
end
|
112
113
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
114
|
+
it "should list from the specified source repository" do
|
115
|
+
resource[:source] = "http://foo.bar.baz/gems"
|
116
|
+
provider.class.expects(:gemlist).
|
117
|
+
with({:justme => 'myresource', :source => "http://foo.bar.baz/gems"}).
|
118
|
+
returns({
|
119
|
+
:name => 'myresource',
|
120
|
+
:ensure => ["3.0"],
|
121
|
+
:provider => :gem,
|
121
122
|
})
|
122
|
-
|
123
|
+
expect(provider.latest).to eq("3.0")
|
124
|
+
end
|
123
125
|
end
|
124
|
-
end
|
125
126
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
describe "#instances" do
|
128
|
+
before do
|
129
|
+
provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
|
130
|
+
end
|
130
131
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
it "should return an empty array when no gems installed" do
|
133
|
+
provider_class.expects(:execute).with(%w{/my/gem list --local}).returns("\n")
|
134
|
+
expect(provider_class.instances).to eq([])
|
135
|
+
end
|
135
136
|
|
136
|
-
|
137
|
-
|
137
|
+
it "should return ensure values as an array of installed versions" do
|
138
|
+
provider_class.expects(:execute).with(%w{/my/gem list --local}).returns <<-HEREDOC.gsub(/ /, '')
|
138
139
|
systemu (1.2.0)
|
139
140
|
vagrant (0.8.7, 0.6.9)
|
140
|
-
|
141
|
+
HEREDOC
|
141
142
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
expect(provider_class.instances.map {|p| p.properties}).to eq([
|
144
|
+
{:ensure => ["1.2.0"], :provider => :gem, :name => 'systemu'},
|
145
|
+
{:ensure => ["0.8.7", "0.6.9"], :provider => :gem, :name => 'vagrant'}
|
146
|
+
])
|
147
|
+
end
|
147
148
|
|
148
|
-
|
149
|
-
|
149
|
+
it "should ignore platform specifications" do
|
150
|
+
provider_class.expects(:execute).with(%w{/my/gem list --local}).returns <<-HEREDOC.gsub(/ /, '')
|
150
151
|
systemu (1.2.0)
|
151
152
|
nokogiri (1.6.1 ruby java x86-mingw32 x86-mswin32-60, 1.4.4.1 x86-mswin32)
|
152
|
-
|
153
|
+
HEREDOC
|
154
|
+
|
155
|
+
expect(provider_class.instances.map {|p| p.properties}).to eq([
|
156
|
+
{:ensure => ["1.2.0"], :provider => :gem, :name => 'systemu'},
|
157
|
+
{:ensure => ["1.6.1", "1.4.4.1"], :provider => :gem, :name => 'nokogiri'}
|
158
|
+
])
|
159
|
+
end
|
153
160
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
161
|
+
it "should not fail when an unmatched line is returned" do
|
162
|
+
provider_class.expects(:execute).with(%w{/my/gem list --local}).
|
163
|
+
returns(File.read(my_fixture('line-with-1.8.5-warning')))
|
164
|
+
|
165
|
+
expect(provider_class.instances.map {|p| p.properties}).
|
166
|
+
to eq([{:provider=>:gem, :ensure=>["0.3.2"], :name=>"columnize"},
|
167
|
+
{:provider=>:gem, :ensure=>["1.1.3"], :name=>"diff-lcs"},
|
168
|
+
{:provider=>:gem, :ensure=>["0.0.1"], :name=>"metaclass"},
|
169
|
+
{:provider=>:gem, :ensure=>["0.10.5"], :name=>"mocha"},
|
170
|
+
{:provider=>:gem, :ensure=>["0.8.7"], :name=>"rake"},
|
171
|
+
{:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-core"},
|
172
|
+
{:provider=>:gem, :ensure=>["2.9.1"], :name=>"rspec-expectations"},
|
173
|
+
{:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-mocks"},
|
174
|
+
{:provider=>:gem, :ensure=>["0.9.0"], :name=>"rubygems-bundler"},
|
175
|
+
{:provider=>:gem, :ensure=>["1.11.3.3"], :name=>"rvm"}])
|
176
|
+
end
|
158
177
|
end
|
159
178
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
{:provider=>:gem, :ensure=>["0.10.5"], :name=>"mocha"},
|
169
|
-
{:provider=>:gem, :ensure=>["0.8.7"], :name=>"rake"},
|
170
|
-
{:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-core"},
|
171
|
-
{:provider=>:gem, :ensure=>["2.9.1"], :name=>"rspec-expectations"},
|
172
|
-
{:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-mocks"},
|
173
|
-
{:provider=>:gem, :ensure=>["0.9.0"], :name=>"rubygems-bundler"},
|
174
|
-
{:provider=>:gem, :ensure=>["1.11.3.3"], :name=>"rvm"}])
|
179
|
+
describe "listing gems" do
|
180
|
+
describe "searching for a single package" do
|
181
|
+
it "searches for an exact match" do
|
182
|
+
provider_class.expects(:execute).with(includes('^bundler$')).returns(File.read(my_fixture('gem-list-single-package')))
|
183
|
+
expected = {:name => 'bundler', :ensure => %w[1.6.2], :provider => :gem}
|
184
|
+
expect(provider_class.gemlist({:justme => 'bundler'})).to eq(expected)
|
185
|
+
end
|
186
|
+
end
|
175
187
|
end
|
176
188
|
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'uninstalling myresource' do
|
192
|
+
describe provider_class do
|
193
|
+
let(:resource) do
|
194
|
+
Puppet::Type.type(:package).new(
|
195
|
+
:name => 'myresource',
|
196
|
+
:ensure => :absent
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
let(:provider) do
|
201
|
+
provider = provider_class.new
|
202
|
+
provider.resource = resource
|
203
|
+
provider
|
204
|
+
end
|
205
|
+
|
206
|
+
before :each do
|
207
|
+
resource.provider = provider
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "when uninstalling" do
|
211
|
+
it "should use the path to the gem" do
|
212
|
+
provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
|
213
|
+
provider.expects(:execute).with { |args| args[0] == "/my/gem" }.returns ""
|
214
|
+
provider.uninstall
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should specify that the gem is being uninstalled" do
|
218
|
+
provider.expects(:execute).with { |args| args[1] == "uninstall" }.returns ""
|
219
|
+
provider.uninstall
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should specify that the relevant executables should be removed without confirmation" do
|
223
|
+
provider.expects(:execute).with { |args| args[2] == "--executables" }.returns ""
|
224
|
+
provider.uninstall
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should specify that all the matching versions should be removed" do
|
228
|
+
provider.expects(:execute).with { |args| args[3] == "--all" }.returns ""
|
229
|
+
provider.uninstall
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should specify the package name" do
|
233
|
+
provider.expects(:execute).with { |args| args[4] == "myresource" }.returns ""
|
234
|
+
provider.uninstall
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should not append uninstall_options by default" do
|
238
|
+
provider.expects(:execute).with { |args| args.length == 5 }.returns ""
|
239
|
+
provider.uninstall
|
240
|
+
end
|
177
241
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
expected = {:name => 'bundler', :ensure => %w[1.6.2], :provider => :gem}
|
183
|
-
expect(provider_class.gemlist({:justme => 'bundler'})).to eq(expected)
|
242
|
+
it "should allow setting an uninstall_options parameter" do
|
243
|
+
resource[:uninstall_options] = [ '--ignore-dependencies', {'--version' => '0.1.1' } ]
|
244
|
+
provider.expects(:execute).with { |args| args[5] == '--ignore-dependencies' && args[6] == '--version=0.1.1' }.returns ''
|
245
|
+
provider.uninstall
|
184
246
|
end
|
185
247
|
end
|
186
248
|
end
|