Sha256: 7929310a93c00ca65e60146d4b0876d02716d423d22866daccda8aa9de091240

Contents?: true

Size: 1.66 KB

Versions: 18

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe Berkshelf::Resolver do
  let(:berksfile) { double('berksfile') }
  let(:demand) { Berkshelf::Dependency.new(berksfile, "mysql", constraint: "= 1.2.4") }

  describe "ClassMethods" do
    describe "::initialize" do
      it 'adds the specified dependencies to the dependencies hash' do
        resolver = described_class.new(berksfile, demand)
        expect(resolver).to have_demand(demand)
      end
    end
  end

  subject { Berkshelf::Resolver.new(berksfile) }

  describe "#add_demand" do
    it 'adds the demand to the instance of resolver' do
      subject.add_demand(demand)
      expect(subject.demands).to include(demand)
    end

    it 'raises a DuplicateDemand exception if a demand of the same name is added' do
      subject.should_receive(:has_demand?).with(demand).and_return(true)

      expect {
        subject.add_demand(demand)
      }.to raise_error(Berkshelf::DuplicateDemand)
    end
  end

  describe "#demands" do
    it "returns an Array" do
      expect(subject.demands).to be_a(Array)
    end
  end

  describe "#get_demand" do
    before { subject.add_demand(demand) }

    context 'given a string representation of the demand to retrieve' do
      it 'returns a Berkshelf::Dependency of the same name' do
        expect(subject.get_demand(demand.name)).to eq(demand)
      end
    end
  end

  describe '#has_demand?' do
    before { subject.add_demand(demand) }

    it 'returns true if the demand exists' do
      expect(subject.has_demand?(demand.name)).to be_true
    end

    it 'returns false if the demand does not exist' do
      expect(subject.has_demand?('non-existent')).to be_false
    end
  end

  describe "#resolve"
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
berkshelf-3.1.5 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.1.4 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.1.3 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.1.2 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.1.1 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.1.0 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.1 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.rc1 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta9 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta8 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta7 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta6 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta5 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta4 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta3 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta2 spec/unit/berkshelf/resolver_spec.rb
berkshelf-3.0.0.beta1 spec/unit/berkshelf/resolver_spec.rb