summaryrefslogtreecommitdiff
path: root/spec/bundler/index_spec.rb
blob: 0f3f6e49445c3984e30db04a2830df8561854152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

RSpec.describe Bundler::Index do
  let(:specs) { [] }
  subject { described_class.build {|i| i.use(specs) } }

  context "specs with a nil platform" do
    let(:spec) do
      Gem::Specification.new do |s|
        s.name = "json"
        s.version = "1.8.3"
        allow(s).to receive(:platform).and_return(nil)
      end
    end
    let(:specs) { [spec] }

    describe "#search_by_spec" do
      it "finds the spec when a nil platform is specified" do
        expect(subject.search(spec)).to eq([spec])
      end

      it "finds the spec when a ruby platform is specified" do
        query = spec.dup.tap {|s| s.platform = "ruby" }
        expect(subject.search(query)).to eq([spec])
      end
    end
  end

  context "with specs that include development dependencies" do
    let(:specs) { [*build_spec("a", "1.0.0") {|s| s.development("b", "~> 1.0") }] }

    it "does not include b in #dependency_names" do
      expect(subject.dependency_names).not_to include("b")
    end
  end
end