Ticket #35394: patch-spec-unit-provider-package-macports_spec.rb.patch

File patch-spec-unit-provider-package-macports_spec.rb.patch, 3.0 KB (added by macports@…, 12 years ago)
  • spec/unit/provider/package/macports_spec.rb

    describe provider_class do 
    3030    it { should be_versionable }
    3131  end
    3232
    33   describe "when listing all instances", :'fails_on_ruby_1.9.2' => true do
     33  describe "when listing all instances" do
    3434    it "should call port -q installed" do
    3535      provider_class.expects(:port).with("-q", :installed).returns("")
    3636      provider_class.instances
    describe provider_class do 
    4545      provider_class.expects(:port).returns("foo @1.234.5_2")
    4646      provider_class.instances.size.should == 0
    4747    end
     48
     49    it "should ignore variants" do
     50      provider_class.parse_installed_query_line("bar @1.0beta2_38_1+x11+java (active)").
     51        should == {:provider=>:macports, :revision=>"1", :name=>"bar", :ensure=>"1.0beta2_38"}
     52    end
     53
    4854  end
    4955
    5056  describe "when installing" do
    describe provider_class do 
    7884      "1.2.3 2"
    7985    end
    8086    let :infoargs do
    81       ["-q", :info, "--line", "--version", "--revision",  resource_name]
     87      ["/opt/local/bin/port", "-q", :info, "--line", "--version", "--revision",  resource_name]
    8288    end
    8389
    8490    it "should return nil when the package cannot be found" do
    8591      resource[:name] = resource_name
    86       provider.expects(:port).returns("")
     92      provider.expects(:execute).with(infoargs, {:combine=>false}).returns("")
    8793      provider.latest.should == nil
    8894    end
    8995
    9096    it "should return the current version if the installed port has the same revision" do
    9197      current_hash[:revision] = "2"
    92       provider.expects(:port).with(*infoargs).returns(new_info_line)
     98      provider.expects(:execute).with(infoargs, {:combine=>false}).returns(new_info_line)
    9399      provider.expects(:query).returns(current_hash)
    94100      provider.latest.should == current_hash[:ensure]
    95101    end
    96102
    97103    it "should return the new version_revision if the installed port has a lower revision" do
    98104      current_hash[:revision] = "1"
    99       provider.expects(:port).with(*infoargs).returns(new_info_line)
     105      provider.expects(:execute).with(infoargs, {:combine=>false}).returns(new_info_line)
    100106      provider.expects(:query).returns(current_hash)
    101107      provider.latest.should == "1.2.3_2"
    102108    end
     109
     110    it "should return the newest version if the port is not installed" do
     111      resource[:name] = resource_name
     112      provider.expects(:execute).with(infoargs, {:combine=>false}).returns(new_info_line)
     113      provider.expects(:execute).with(["/opt/local/bin/port", "-q", :installed, resource[:name]], {:combine=>false}).returns("")
     114      provider.latest.should == "1.2.3_2"
     115    end
    103116  end
    104117
    105118  describe "when updating a port" do
    describe provider_class do 
    111124      provider.update
    112125    end
    113126
    114     it "should execute port install if the port is not installed", :'fails_on_ruby_1.9.2' => true do
     127    it "should execute port install if the port is not installed" do
    115128      resource[:name] = resource_name
    116129      resource[:ensure] = :present
    117130      provider.stubs(:query).returns("")