Skip to content

Commit c1926ca

Browse files
committed
added specs for easy_install resource/provider
1 parent ef1d4d3 commit c1926ca

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# Author:: David Balatero (dbalatero@gmail.com)
3+
#
4+
# Copyright:: Copyright (c) 2009 David Balatero
5+
# License:: Apache License, Version 2.0
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))
21+
22+
describe Chef::Provider::Package::EasyInstall, "easy_install_binary_path" do
23+
before(:each) do
24+
@node = mock("Chef::Node", :null_object => true)
25+
@new_resource = mock("Chef::Resource::Package",
26+
:null_object => true,
27+
:name => "boto",
28+
:version => "1.8d",
29+
:package_name => "boto",
30+
:easy_install_binary => nil
31+
)
32+
@provider = Chef::Provider::Package::EasyInstall.new(@node, @new_resource)
33+
end
34+
35+
it "should return a relative path to easy_install if no easy_install_binary is given" do
36+
@provider.easy_install_binary_path.should eql("easy_install")
37+
end
38+
39+
it "should return a specific path to easy_install if a easy_install_binary is given" do
40+
@new_resource.should_receive(:easy_install_binary).and_return("/opt/local/bin/custom/easy_install")
41+
@provider.easy_install_binary_path.should eql("/opt/local/bin/custom/easy_install")
42+
end
43+
end
44+
45+
describe Chef::Provider::Package::EasyInstall, "install_package" do
46+
before(:each) do
47+
@node = mock("Chef::Node", :null_object => true)
48+
@new_resource = mock("Chef::Resource::Package",
49+
:null_object => true,
50+
:name => "boto",
51+
:version => "1.8d",
52+
:package_name => "boto",
53+
:easy_install_binary => nil
54+
)
55+
@provider = Chef::Provider::Package::EasyInstall.new(@node, @new_resource)
56+
end
57+
58+
it "should run gem install with the package name and version" do
59+
@provider.should_receive(:run_command).with({
60+
:command => "easy_install \"boto==1.8d\""
61+
})
62+
@provider.install_package("boto", "1.8d")
63+
end
64+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Author:: Joe Williams (<joe@joetify.com>)
3+
# Copyright:: Copyright (c) 2009 Joe Williams
4+
# License:: Apache License, Version 2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
20+
21+
describe Chef::Resource::EasyInstallPackage, "initialize" do
22+
23+
before(:each) do
24+
@resource = Chef::Resource::EasyInstallPackage.new("foo")
25+
end
26+
27+
it "should return a Chef::Resource::EasyInstallPackage" do
28+
@resource.should be_a_kind_of(Chef::Resource::EasyInstallPackage)
29+
end
30+
31+
it "should set the resource_name to :easy_install_package" do
32+
@resource.resource_name.should eql(:easy_install_package)
33+
end
34+
35+
it "should set the provider to Chef::Provider::Package::EasyInstall" do
36+
@resource.provider.should eql(Chef::Provider::Package::EasyInstall)
37+
end
38+
end
39+
40+
describe Chef::Resource::EasyInstall, "easy_install_binary" do
41+
before(:each) do
42+
@resource = Chef::Resource::EasyInstall.new("foo")
43+
end
44+
45+
it "should set the gem_binary variable to whatever is passed in" do
46+
@resource.gem_binary("/opt/local/bin/easy_install")
47+
@resource.gem_binary.should eql("/opt/local/bin/easy_install")
48+
end
49+
end

0 commit comments

Comments
 (0)