<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2009 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))

describe Chef::Provider::Package::Macports do
  before(:each) do
    @node = Chef::Node.new
    @new_resource = mock("Chef::Resource::Package", 
      :null_object => true,
      :name => "zsh",
      :package_name => "zsh",
      :version => nil
    )
    @current_resource = mock("Chef::Resource::Package", 
      :null_object => true,
      :name => "zsh",
      :package_name => "zsh",
      :version => nil
    )

    @provider = Chef::Provider::Package::Macports.new(@node, @new_resource)    
    Chef::Resource::Package.stub!(:new).and_return(@current_resource)

    @status = mock("Status", :exitstatus => 0)
    @stdin = mock("STDIN", :null_object => true)
    @stdout = mock("STDOUT", :null_object => true)
    @stderr = mock("STDERR", :null_object => true)
    @pid = mock("PID", :null_object => true)
  end

  describe "load_current_resource" do
    it "should create a current resource with the name of the new_resource" do
      @provider.should_receive(:current_installed_version).and_return(nil)
      @provider.should_receive(:macports_candidate_version).and_return("4.2.7")

      @provider.load_current_resource
      @provider.current_resource.name.should == "zsh"
    end
    
    it "should create a current resource with the version if the package is installed" do
      @provider.should_receive(:macports_candidate_version).and_return("4.2.7")
      @provider.should_receive(:current_installed_version).and_return("4.2.7")
      <commit_msg>update macport specs for new method signatures<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2009 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))

describe Chef::Provider::Package::Macports do
  before(:each) do
    @node = Chef::Node.new
    @run_context = Chef::RunContext.new(@node, {})
    @new_resource = Chef::Resource::Package.new("zsh")
    @current_resource = Chef::Resource::Package.new("zsh")

    @provider = Chef::Provider::Package::Macports.new(@new_resource, @run_context)
    Chef::Resource::Package.stub!(:new).and_return(@current_resource)

    @status = mock("Status", :exitstatus => 0)
    @stdin = mock("STDIN", :null_object => true)
    @stdout = mock("STDOUT", :null_object => true)
    @stderr = mock("STDERR", :null_object => true)
    @pid = mock("PID", :null_object => true)
  end

  describe "load_current_resource" do
    it "should create a current resource with the name of the new_resource" do
      @provider.should_receive(:current_installed_version).and_return(nil)
      @provider.should_receive(:macports_candidate_version).and_return("4.2.7")

      @provider.load_current_resource
      @provider.current_resource.name.should == "zsh"
    end
    
    it "should create a current resource with the version if the package is installed" do
      @provider.should_receive(:macports_candidate_version).and_return("4.2.7")
      @provider.should_receive(:current_installed_version).and_return("4.2.7")
      
{'fraction_non_alphanumeric': 0.13224845289938117, 'fraction_numerical': 0.009168003667201467, 'mean_word_length': 4.195238095238095, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2759966', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1288, 'n_words': 366}