diff options
Diffstat (limited to 'spec/unit/provider/package/freebsd_spec.rb')
-rw-r--r-- | spec/unit/provider/package/freebsd_spec.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/spec/unit/provider/package/freebsd_spec.rb b/spec/unit/provider/package/freebsd_spec.rb index 2901b84f49..037d559bc2 100644 --- a/spec/unit/provider/package/freebsd_spec.rb +++ b/spec/unit/provider/package/freebsd_spec.rb @@ -30,12 +30,12 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - ::File.stub!(:exist?).with('/usr/ports/Makefile').and_return(false) + ::File.stub(:exist?).with('/usr/ports/Makefile').and_return(false) end describe "when determining the current package state" do before do - @provider.stub!(:ports_candidate_version).and_return("4.3.6") + @provider.stub(:ports_candidate_version).and_return("4.3.6") end it "should create a current resource with the name of the new_resource" do @@ -79,14 +79,14 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7") @provider.should_receive(:shell_out!).with('pkg_info -E "zsh*"', :env => nil, :returns => [0,1]).and_return(pkg_info) #@provider.should_receive(:popen4).with('pkg_info -E "zsh*"').and_yield(@pid, @stdin, ["zsh-4.3.6_7"], @stderr).and_return(@status) - @provider.stub!(:package_name).and_return("zsh") + @provider.stub(:package_name).and_return("zsh") @provider.current_installed_version.should == "4.3.6_7" end it "does not set the current version number when the package is not installed" do pkg_info = OpenStruct.new(:stdout => "") @provider.should_receive(:shell_out!).with('pkg_info -E "zsh*"', :env => nil, :returns => [0,1]).and_return(pkg_info) - @provider.stub!(:package_name).and_return("zsh") + @provider.stub(:package_name).and_return("zsh") @provider.current_installed_version.should be_nil end @@ -94,21 +94,21 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh") @provider.should_receive(:shell_out!).with("whereis -s zsh", :env => nil).and_return(whereis) #@provider.should_receive(:popen4).with("whereis -s zsh").and_yield(@pid, @stdin, ["zsh: /usr/ports/shells/zsh"], @stderr).and_return(@status) - @provider.stub!(:port_name).and_return("zsh") + @provider.stub(:port_name).and_return("zsh") @provider.port_path.should == "/usr/ports/shells/zsh" end # Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile. it "should return the ports candidate version when given a valid port path" do - @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh") + @provider.stub(:port_path).and_return("/usr/ports/shells/zsh") make_v = OpenStruct.new(:stdout => "4.3.6\n") @provider.should_receive(:shell_out!).with("make -V PORTVERSION", {:cwd=>"/usr/ports/shells/zsh", :returns=>[0, 1], :env=>nil}).and_return(make_v) @provider.ports_candidate_version.should == "4.3.6" end it "should figure out the package name when we have ports" do - ::File.stub!(:exist?).with('/usr/ports/Makefile').and_return(true) - @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh") + ::File.stub(:exist?).with('/usr/ports/Makefile').and_return(true) + @provider.stub(:port_path).and_return("/usr/ports/shells/zsh") make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n") @provider.should_receive(:shell_out!).with("make -V PKGNAME", {:cwd=>"/usr/ports/shells/zsh", :env=>nil, :returns=>[0, 1]}).and_return(make_v) #@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7") @@ -121,9 +121,9 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @cmd_result = OpenStruct.new(:status => true) @provider.current_resource = @current_resource - @provider.stub!(:package_name).and_return("zsh") - @provider.stub!(:latest_link_name).and_return("zsh") - @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh") + @provider.stub(:package_name).and_return("zsh") + @provider.stub(:latest_link_name).and_return("zsh") + @provider.stub(:port_path).and_return("/usr/ports/shells/zsh") end it "should run pkg_add -r with the package name" do @@ -132,7 +132,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do end it "should run make install when installing from ports" do - @new_resource.stub!(:source).and_return("ports") + @new_resource.stub(:source).and_return("ports") @provider.should_not_receive(:shell_out!).with("make -DBATCH -f /usr/ports/shells/zsh/Makefile install", :timeout => 1200, :env=>nil) @provider.should_receive(:shell_out!).with("make -DBATCH install", :timeout => 1200, :env=>nil, :cwd => @provider.port_path).and_return(@cmd_result) @provider.install_package("zsh", "4.3.6_7") @@ -177,9 +177,9 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @current_resource = Chef::Resource::Package.new("ruby-iconv") @provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.stub!(:port_path).and_return("/usr/ports/converters/ruby-iconv") - @provider.stub!(:package_name).and_return("ruby18-iconv") - @provider.stub!(:latest_link_name).and_return("ruby18-iconv") + @provider.stub(:port_path).and_return("/usr/ports/converters/ruby-iconv") + @provider.stub(:package_name).and_return("ruby18-iconv") + @provider.stub(:latest_link_name).and_return("ruby18-iconv") @install_result = OpenStruct.new(:status => true) end @@ -190,7 +190,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do end it "should run make install when installing from ports" do - @new_resource.stub!(:source).and_return("ports") + @new_resource.stub(:source).and_return("ports") @provider.should_receive(:shell_out!).with("make -DBATCH install", :timeout => 1200, :env=>nil, :cwd => @provider.port_path).and_return(@install_result) @provider.install_package("ruby-iconv", "1.0") end @@ -202,7 +202,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @new_resource.version "4.3.6_7" @current_resource.version "4.3.6_7" @provider.current_resource = @current_resource - @provider.stub!(:package_name).and_return("zsh") + @provider.stub(:package_name).and_return("zsh") end it "should run pkg_delete with the package name and version" do @@ -227,14 +227,14 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do it "should return the port path for a valid port name" do whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++") @provider.should_receive(:shell_out!).with("whereis -s bonnie++", :env => nil).and_return(whereis) - @provider.stub!(:port_name).and_return("bonnie++") + @provider.stub(:port_name).and_return("bonnie++") @provider.port_path.should == "/usr/ports/benchmarks/bonnie++" end it "should return the version number when it is installed" do pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96") @provider.should_receive(:shell_out!).with('pkg_info -E "bonnie++*"', :env => nil, :returns => [0,1]).and_return(pkg_info) - @provider.stub!(:package_name).and_return("bonnie++") + @provider.stub(:package_name).and_return("bonnie++") @provider.current_installed_version.should == "1.96" end end @@ -262,8 +262,8 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @current_resource = Chef::Resource::Package.new("perl5.8") @provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.stub!(:package_name).and_return("perl") - @provider.stub!(:latest_link_name).and_return("perl") + @provider.stub(:package_name).and_return("perl") + @provider.stub(:latest_link_name).and_return("perl") cmd = OpenStruct.new(:status => true) @provider.should_receive(:shell_out!).with("pkg_add -r perl", :env => nil).and_return(cmd) @@ -276,8 +276,8 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do @current_resource = Chef::Resource::Package.new("mysql50-server") @provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.stub!(:package_name).and_return("mysql-server") - @provider.stub!(:latest_link_name).and_return("mysql50-server") + @provider.stub(:package_name).and_return("mysql-server") + @provider.stub(:latest_link_name).and_return("mysql50-server") cmd = OpenStruct.new(:status => true) @provider.should_receive(:shell_out!).with("pkg_add -r mysql50-server", :env=>nil).and_return(cmd) |