-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathmatch_metadata_spec.rb
More file actions
124 lines (98 loc) · 4.6 KB
/
match_metadata_spec.rb
File metadata and controls
124 lines (98 loc) · 4.6 KB
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
119
120
121
122
123
124
# frozen_string_literal: true
RSpec.describe Bundler::MatchMetadata do
let(:klass) do
Class.new do
include Bundler::MatchMetadata
attr_accessor :required_ruby_version, :required_rubygems_version, :dependencies
def initialize(ruby_version, rubygems_version)
@required_ruby_version = ruby_version
@required_rubygems_version = rubygems_version
@dependencies = []
end
alias_method :runtime_dependencies, :dependencies
end
end
describe "#matches_current_ruby?" do
context "when the ruby version has an upper bound that excludes the current ruby" do
let(:spec) { klass.new(Gem::Requirement.new(">= 3.0", "< 3.1"), Gem::Requirement.default) }
it "returns false by default" do
expect(spec.matches_current_ruby?).to be false
end
it "returns true when ignore_ruby_upper_bounds is set" do
bundle "config set ignore_ruby_upper_bounds true"
expect(spec.matches_current_ruby?).to be true
end
end
context "when the ruby version has only a lower bound" do
let(:spec) { klass.new(Gem::Requirement.new(">= 2.0"), Gem::Requirement.default) }
it "returns true regardless of setting" do
expect(spec.matches_current_ruby?).to be true
bundle "config set ignore_ruby_upper_bounds true"
expect(spec.matches_current_ruby?).to be true
end
end
context "when the ruby version has only an upper bound" do
let(:spec) { klass.new(Gem::Requirement.new("< 3.1"), Gem::Requirement.default) }
it "returns false by default" do
expect(spec.matches_current_ruby?).to be false
end
it "returns true when ignore_ruby_upper_bounds is set (upper bound removed, defaults to >= 0)" do
bundle "config set ignore_ruby_upper_bounds true"
expect(spec.matches_current_ruby?).to be true
end
end
end
describe "#matches_current_rubygems?" do
context "when the rubygems version has an upper bound that excludes the current rubygems" do
let(:spec) { klass.new(Gem::Requirement.default, Gem::Requirement.new(">= 3.0", "< 3.1")) }
it "returns false by default" do
expect(spec.matches_current_rubygems?).to be false
end
it "returns true when ignore_rubygems_upper_bounds is set" do
bundle "config set ignore_rubygems_upper_bounds true"
expect(spec.matches_current_rubygems?).to be true
end
end
context "when the rubygems version has only a lower bound" do
let(:spec) { klass.new(Gem::Requirement.default, Gem::Requirement.new(">= 2.0")) }
it "returns true regardless of setting" do
expect(spec.matches_current_rubygems?).to be true
bundle "config set ignore_rubygems_upper_bounds true"
expect(spec.matches_current_rubygems?).to be true
end
end
end
describe "#metadata_dependency" do
context "when ignore_ruby_upper_bounds is set" do
before { bundle "config set ignore_ruby_upper_bounds true" }
it "removes upper bounds from Ruby dependency" do
spec = klass.new(Gem::Requirement.new(">= 3.0", "< 3.1"), Gem::Requirement.default)
dep = spec.send(:metadata_dependency, "Ruby", spec.required_ruby_version)
expect(dep.requirement).to eq(Gem::Requirement.new(">= 3.0"))
end
it "returns nil when only upper bounds exist" do
spec = klass.new(Gem::Requirement.new("< 3.1"), Gem::Requirement.default)
dep = spec.send(:metadata_dependency, "Ruby", spec.required_ruby_version)
expect(dep).to be_nil
end
it "does not affect RubyGems dependency" do
spec = klass.new(Gem::Requirement.default, Gem::Requirement.new(">= 3.0", "< 4.0"))
dep = spec.send(:metadata_dependency, "RubyGems", spec.required_rubygems_version)
expect(dep.requirement).to eq(Gem::Requirement.new(">= 3.0", "< 4.0"))
end
end
context "when ignore_rubygems_upper_bounds is set" do
before { bundle "config set ignore_rubygems_upper_bounds true" }
it "removes upper bounds from RubyGems dependency" do
spec = klass.new(Gem::Requirement.default, Gem::Requirement.new(">= 3.0", "< 4.0"))
dep = spec.send(:metadata_dependency, "RubyGems", spec.required_rubygems_version)
expect(dep.requirement).to eq(Gem::Requirement.new(">= 3.0"))
end
it "does not affect Ruby dependency" do
spec = klass.new(Gem::Requirement.new(">= 3.0", "< 3.1"), Gem::Requirement.default)
dep = spec.send(:metadata_dependency, "Ruby", spec.required_ruby_version)
expect(dep.requirement).to eq(Gem::Requirement.new(">= 3.0", "< 3.1"))
end
end
end
end