summaryrefslogtreecommitdiff
path: root/spec/bundler/commands/fund_spec.rb
blob: ee3aff3a29dc8dd43b7fe6bf81dfe6dd844021aa (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true

RSpec.describe "bundle fund" do
  it "prints fund information for all gems in the bundle" do
    install_gemfile <<-G
      source "#{file_uri_for(gem_repo1)}"
      gem 'has_metadata'
      gem 'has_funding'
      gem 'rack-obama'
    G

    bundle "fund"

    expect(out).to include("* has_metadata (1.0)\n  Funding: https://example.com/has_metadata/funding")
    expect(out).to include("* has_funding (1.2.3)\n  Funding: https://example.com/has_funding/funding")
    expect(out).to_not include("rack-obama")
  end

  it "does not consider fund information for gem dependencies" do
    install_gemfile <<-G
      source "#{file_uri_for(gem_repo1)}"
      gem 'gem_with_dependent_funding'
    G

    bundle "fund"

    expect(out).to_not include("* has_funding (1.2.3)\n  Funding: https://example.com/has_funding/funding")
    expect(out).to_not include("gem_with_dependent_funding")
  end

  it "prints message if none of the gems have fund information" do
    install_gemfile <<-G
      source "#{file_uri_for(gem_repo1)}"
      gem 'rack-obama'
    G

    bundle "fund"

    expect(out).to include("None of the installed gems you directly depend on are looking for funding.")
  end

  describe "with --group option" do
    it "prints fund message for only specified group gems" do
      install_gemfile <<-G
      source "#{file_uri_for(gem_repo1)}"
        gem 'has_metadata', :group => :development
        gem 'has_funding'
      G

      bundle "fund --group development"
      expect(out).to include("* has_metadata (1.0)\n  Funding: https://example.com/has_metadata/funding")
      expect(out).to_not include("* has_funding (1.2.3)\n  Funding: https://example.com/has_funding/funding")
    end
  end
end