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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
# frozen_string_literal: true
RSpec.describe "bundle fund" do
before do
build_repo2 do
build_gem "has_funding_and_other_metadata" do |s|
s.metadata = {
"bug_tracker_uri" => "https://example.com/user/bestgemever/issues",
"changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md",
"documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
"homepage_uri" => "https://bestgemever.example.io",
"mailing_list_uri" => "https://groups.example.com/bestgemever",
"funding_uri" => "https://example.com/has_funding_and_other_metadata/funding",
"source_code_uri" => "https://example.com/user/bestgemever",
"wiki_uri" => "https://example.com/user/bestgemever/wiki",
}
end
build_gem "has_funding", "1.2.3" do |s|
s.metadata = {
"funding_uri" => "https://example.com/has_funding/funding",
}
end
build_gem "gem_with_dependent_funding", "1.0" do |s|
s.add_dependency "has_funding"
end
end
end
it "prints fund information for all gems in the bundle" do
install_gemfile <<-G
source "https://gem.repo2"
gem 'has_funding_and_other_metadata'
gem 'has_funding'
gem 'myrack-obama'
G
bundle "fund"
expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding")
expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
expect(out).to_not include("myrack-obama")
end
it "does not consider fund information for gem dependencies" do
install_gemfile <<-G
source "https://gem.repo2"
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 "does not consider fund information for uninstalled optional dependencies" do
install_gemfile <<-G
source "https://gem.repo2"
group :whatever, optional: true do
gem 'has_funding_and_other_metadata'
end
gem 'has_funding'
gem 'myrack-obama'
G
bundle "fund"
expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
expect(out).to_not include("has_funding_and_other_metadata")
expect(out).to_not include("myrack-obama")
end
it "considers fund information for installed optional dependencies" do
bundle "config set with whatever"
install_gemfile <<-G
source "https://gem.repo2"
group :whatever, optional: true do
gem 'has_funding_and_other_metadata'
end
gem 'has_funding'
gem 'myrack-obama'
G
bundle "fund"
expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding")
expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
expect(out).to_not include("myrack-obama")
end
it "prints message if none of the gems have fund information" do
install_gemfile <<-G
source "https://gem.repo2"
gem 'myrack-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 "https://gem.repo2"
gem 'has_funding_and_other_metadata', :group => :development
gem 'has_funding'
G
bundle "fund --group development"
expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding")
expect(out).to_not include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
end
end
end
|