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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# frozen_string_literal: true
RSpec.describe "Resolving platform craziness" do
describe "with cross-platform gems" do
before :each do
@index = an_awesome_index
end
it "resolves a simple multi platform gem" do
dep "nokogiri"
platforms "ruby", "java"
should_resolve_as %w[nokogiri-1.4.2 nokogiri-1.4.2-java weakling-0.0.3]
end
it "doesn't pull gems that don't exist for the current platform" do
dep "nokogiri"
platforms "ruby"
should_resolve_as %w[nokogiri-1.4.2]
end
it "doesn't pull gems when the version is available for all requested platforms" do
dep "nokogiri"
platforms "mswin32"
should_resolve_as %w[nokogiri-1.4.2.1-x86-mswin32]
end
end
it "takes the latest ruby gem, even if an older platform specific version is available" do
@index = build_index do
gem "foo", "1.0.0"
gem "foo", "1.0.0", "x64-mingw32"
gem "foo", "1.1.0"
end
dep "foo"
platforms "x64-mingw32"
should_resolve_as %w[foo-1.1.0]
end
it "takes the ruby version if the platform version is incompatible" do
@index = build_index do
gem "bar", "1.0.0"
gem "foo", "1.0.0"
gem "foo", "1.0.0", "x64-mingw32" do
dep "bar", "< 1"
end
end
dep "foo"
platforms "x64-mingw32"
should_resolve_as %w[foo-1.0.0]
end
it "prefers the platform specific gem to the ruby version" do
@index = build_index do
gem "foo", "1.0.0"
gem "foo", "1.0.0", "x64-mingw32"
end
dep "foo"
platforms "x64-mingw32"
should_resolve_as %w[foo-1.0.0-x64-mingw32]
end
it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version" do
@index = build_index do
gem "foo", "1.0.0"
gem "foo", "1.0.0", "x64-mingw32"
gem "foo", "1.1.0" do |s|
s.required_ruby_version = [">= 2.0"]
end
gem "foo", "1.1.0", "x64-mingw32" do |s|
s.required_ruby_version = [">= 2.0", "< 2.4"]
end
gem "Ruby\0", "2.5.1"
end
dep "foo"
dep "Ruby\0", "2.5.1"
platforms "x64-mingw32"
should_resolve_as %w[foo-1.1.0]
end
it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version with multiple platforms" do
@index = build_index do
gem "foo", "1.0.0"
gem "foo", "1.0.0", "x64-mingw32"
gem "foo", "1.1.0" do |s|
s.required_ruby_version = [">= 2.0"]
end
gem "foo", "1.1.0", "x64-mingw32" do |s|
s.required_ruby_version = [">= 2.0", "< 2.4"]
end
gem "Ruby\0", "2.5.1"
end
dep "foo"
dep "Ruby\0", "2.5.1"
platforms "x86_64-linux", "x64-mingw32"
should_resolve_as %w[foo-1.1.0]
end
describe "with mingw32" do
before :each do
@index = build_index do
platforms "mingw32 mswin32 x64-mingw32" do |platform|
gem "thin", "1.2.7", platform
end
gem "win32-api", "1.5.1", "universal-mingw32"
end
end
it "finds mswin gems" do
# win32 is hardcoded to get CPU x86 in rubygems
platforms "mswin32"
dep "thin"
should_resolve_as %w[thin-1.2.7-x86-mswin32]
end
it "finds mingw gems" do
# mingw is _not_ hardcoded to add CPU x86 in rubygems
platforms "x86-mingw32"
dep "thin"
should_resolve_as %w[thin-1.2.7-mingw32]
end
it "finds x64-mingw gems" do
platforms "x64-mingw32"
dep "thin"
should_resolve_as %w[thin-1.2.7-x64-mingw32]
end
it "finds universal-mingw gems on x86-mingw" do
platform "x86-mingw32"
dep "win32-api"
should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
end
it "finds universal-mingw gems on x64-mingw" do
platform "x64-mingw32"
dep "win32-api"
should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
end
end
describe "with conflicting cases" do
before :each do
@index = build_index do
gem "foo", "1.0.0" do
dep "bar", ">= 0"
end
gem "bar", "1.0.0" do
dep "baz", "~> 1.0.0"
end
gem "bar", "1.0.0", "java" do
dep "baz", " ~> 1.1.0"
end
gem "baz", %w[1.0.0 1.1.0 1.2.0]
end
end
it "takes the ruby version as fallback" do
platforms "ruby", "java"
dep "foo"
should_resolve_as %w[bar-1.0.0 baz-1.0.0 foo-1.0.0]
end
end
end
|