|
| 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 |
0 commit comments