|
38 | 38 | end |
39 | 39 |
|
40 | 40 | describe "without version specified" do |
41 | | - it "version requirement becomes ~> major.minor.patch when resolved version is < 1.0" do |
| 41 | + it "version requirement becomes >= major.minor.patch when resolved version is < 1.0" do |
42 | 42 | bundle "add 'bar'" |
43 | | - expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) |
| 43 | + expect(bundled_app_gemfile.read).to match(/gem "bar", ">= 0.12.3"/) |
44 | 44 | expect(the_bundle).to include_gems "bar 0.12.3" |
45 | 45 | end |
46 | 46 |
|
47 | | - it "version requirement becomes ~> major.minor when resolved version is > 1.0" do |
| 47 | + it "version requirement becomes >= major.minor when resolved version is > 1.0" do |
48 | 48 | bundle "add 'baz'" |
49 | | - expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) |
| 49 | + expect(bundled_app_gemfile.read).to match(/gem "baz", ">= 1.2"/) |
50 | 50 | expect(the_bundle).to include_gems "baz 1.2.3" |
51 | 51 | end |
52 | 52 |
|
53 | | - it "version requirement becomes ~> major.minor.patch.pre when resolved version is < 1.0" do |
| 53 | + it "version requirement becomes >= major.minor.patch.pre when resolved version is < 1.0" do |
54 | 54 | bundle "add 'cat'" |
55 | | - expect(bundled_app_gemfile.read).to match(/gem "cat", "~> 0.12.3.pre"/) |
| 55 | + expect(bundled_app_gemfile.read).to match(/gem "cat", ">= 0.12.3.pre"/) |
56 | 56 | expect(the_bundle).to include_gems "cat 0.12.3.pre" |
57 | 57 | end |
58 | 58 |
|
59 | | - it "version requirement becomes ~> major.minor.pre when resolved version is > 1.0.pre" do |
| 59 | + it "version requirement becomes >= major.minor.pre when resolved version is >= 1.0.pre" do |
60 | 60 | bundle "add 'dog'" |
61 | | - expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/) |
| 61 | + expect(bundled_app_gemfile.read).to match(/gem "dog", ">= 1.1.pre"/) |
62 | 62 | expect(the_bundle).to include_gems "dog 1.1.3.pre" |
63 | 63 | end |
64 | 64 |
|
65 | | - it "version requirement becomes ~> major.minor.pre.tail when resolved version has a very long tail pre version" do |
| 65 | + it "version requirement becomes >= major.minor.pre.tail when resolved version has a very long tail pre version" do |
66 | 66 | bundle "add 'lemur'" |
67 | 67 | # the trailing pre purposely matches the release version to ensure that subbing the release doesn't change the pre.version" |
68 | | - expect(bundled_app_gemfile.read).to match(/gem "lemur", "~> 3.1.pre.2023.1.1"/) |
| 68 | + expect(bundled_app_gemfile.read).to match(/gem "lemur", ">= 3.1.pre.2023.1.1"/) |
69 | 69 | expect(the_bundle).to include_gems "lemur 3.1.1.pre.2023.1.1" |
70 | 70 | end |
71 | 71 | end |
|
100 | 100 | describe "with --group" do |
101 | 101 | it "adds dependency for the specified group" do |
102 | 102 | bundle "add 'foo' --group='development'" |
103 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", group: :development/) |
| 103 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", group: :development/) |
104 | 104 | expect(the_bundle).to include_gems "foo 2.0" |
105 | 105 | end |
106 | 106 |
|
107 | 107 | it "adds dependency to more than one group" do |
108 | 108 | bundle "add 'foo' --group='development, test'" |
109 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", groups: \[:development, :test\]/) |
| 109 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", groups: \[:development, :test\]/) |
110 | 110 | expect(the_bundle).to include_gems "foo 2.0" |
111 | 111 | end |
112 | 112 | end |
|
115 | 115 | it "adds dependency with specified source" do |
116 | 116 | bundle "add 'foo' --source='https://gem.repo2'" |
117 | 117 |
|
118 | | - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", source: "https://gem.repo2"}) |
| 118 | + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", source: "https://gem.repo2"}) |
119 | 119 | expect(the_bundle).to include_gems "foo 2.0" |
120 | 120 | end |
121 | 121 | end |
|
124 | 124 | it "adds dependency with specified path" do |
125 | 125 | bundle "add 'foo' --path='#{lib_path("foo-2.0")}'" |
126 | 126 |
|
127 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", path: "#{lib_path("foo-2.0")}"/) |
| 127 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", path: "#{lib_path("foo-2.0")}"/) |
128 | 128 | expect(the_bundle).to include_gems "foo 2.0" |
129 | 129 | end |
130 | 130 | end |
|
133 | 133 | it "adds dependency with specified git source" do |
134 | 134 | bundle "add foo --git=#{lib_path("foo-2.0")}" |
135 | 135 |
|
136 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}"/) |
| 136 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}"/) |
137 | 137 | expect(the_bundle).to include_gems "foo 2.0" |
138 | 138 | end |
139 | 139 | end |
|
146 | 146 | it "adds dependency with specified git source and branch" do |
147 | 147 | bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test" |
148 | 148 |
|
149 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test"/) |
| 149 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", branch: "test"/) |
150 | 150 | expect(the_bundle).to include_gems "foo 2.0" |
151 | 151 | end |
152 | 152 | end |
|
155 | 155 | it "adds dependency with specified git source and branch" do |
156 | 156 | bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))}" |
157 | 157 |
|
158 | | - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}"/) |
| 158 | + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}"/) |
159 | 159 | expect(the_bundle).to include_gems "foo 2.0" |
160 | 160 | end |
161 | 161 | end |
|
169 | 169 | it "adds dependency with specified github source" do |
170 | 170 | bundle "add rake --github=ruby/rake" |
171 | 171 |
|
172 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake"}) |
| 172 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake"}) |
173 | 173 | end |
174 | 174 |
|
175 | 175 | it "adds dependency with specified github source and branch" do |
176 | 176 | bundle "add rake --github=ruby/rake --branch=main" |
177 | 177 |
|
178 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "main"}) |
| 178 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", branch: "main"}) |
179 | 179 | end |
180 | 180 |
|
181 | 181 | it "adds dependency with specified github source and ref" do |
182 | 182 | ref = revision_for(lib_path("rake-13.0")) |
183 | 183 | bundle "add rake --github=ruby/rake --ref=#{ref}" |
184 | 184 |
|
185 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "#{ref}"}) |
| 185 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", ref: "#{ref}"}) |
186 | 186 | end |
187 | 187 |
|
188 | 188 | it "adds dependency with specified github source and glob" do |
189 | 189 | bundle "add rake --github=ruby/rake --glob='./*.gemspec'" |
190 | 190 |
|
191 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", glob: "\.\/\*\.gemspec"}) |
| 191 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", glob: "\.\/\*\.gemspec"}) |
192 | 192 | end |
193 | 193 |
|
194 | 194 | it "adds dependency with specified github source, branch and glob" do |
195 | 195 | bundle "add rake --github=ruby/rake --branch=main --glob='./*.gemspec'" |
196 | 196 |
|
197 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "main", glob: "\.\/\*\.gemspec"}) |
| 197 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", branch: "main", glob: "\.\/\*\.gemspec"}) |
198 | 198 | end |
199 | 199 |
|
200 | 200 | it "adds dependency with specified github source, ref and glob" do |
201 | 201 | ref = revision_for(lib_path("rake-13.0")) |
202 | 202 | bundle "add rake --github=ruby/rake --ref=#{ref} --glob='./*.gemspec'" |
203 | 203 |
|
204 | | - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "#{ref}", glob: "\.\/\*\.gemspec"}) |
| 204 | + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", ref: "#{ref}", glob: "\.\/\*\.gemspec"}) |
205 | 205 | end |
206 | 206 | end |
207 | 207 |
|
208 | 208 | describe "with --git and --glob" do |
209 | 209 | it "adds dependency with specified git source" do |
210 | 210 | bundle "add foo --git=#{lib_path("foo-2.0")} --glob='./*.gemspec'" |
211 | 211 |
|
212 | | - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", glob: "\./\*\.gemspec"}) |
| 212 | + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", glob: "\./\*\.gemspec"}) |
213 | 213 | expect(the_bundle).to include_gems "foo 2.0" |
214 | 214 | end |
215 | 215 | end |
|
222 | 222 | it "adds dependency with specified git source and branch" do |
223 | 223 | bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test --glob='./*.gemspec'" |
224 | 224 |
|
225 | | - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test", glob: "\./\*\.gemspec"}) |
| 225 | + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", branch: "test", glob: "\./\*\.gemspec"}) |
226 | 226 | expect(the_bundle).to include_gems "foo 2.0" |
227 | 227 | end |
228 | 228 | end |
|
231 | 231 | it "adds dependency with specified git source and branch" do |
232 | 232 | bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))} --glob='./*.gemspec'" |
233 | 233 |
|
234 | | - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}", glob: "\./\*\.gemspec"}) |
| 234 | + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}", glob: "\./\*\.gemspec"}) |
235 | 235 | expect(the_bundle).to include_gems "foo 2.0" |
236 | 236 | end |
237 | 237 | end |
|
308 | 308 | end |
309 | 309 |
|
310 | 310 | describe "with --optimistic" do |
311 | | - it "adds optimistic version" do |
| 311 | + it "ignores option" do |
312 | 312 | bundle "add 'foo' --optimistic" |
313 | 313 | expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0") |
314 | 314 | expect(the_bundle).to include_gems "foo 2.0" |
315 | 315 | end |
316 | 316 | end |
317 | 317 |
|
| 318 | + describe "with --pessimistic" do |
| 319 | + it "adds pessimistic version" do |
| 320 | + bundle "add 'foo' --pessimistic" |
| 321 | + expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0") |
| 322 | + expect(the_bundle).to include_gems "foo 2.0" |
| 323 | + end |
| 324 | + end |
| 325 | + |
318 | 326 | describe "with --quiet option" do |
319 | 327 | it "is quiet when there are no warnings" do |
320 | 328 | bundle "add 'foo' --quiet" |
@@ -356,27 +364,27 @@ def run |
356 | 364 | end |
357 | 365 |
|
358 | 366 | describe "with no option" do |
359 | | - it "adds pessimistic version" do |
| 367 | + it "adds optimistic version" do |
360 | 368 | bundle "add 'foo'" |
361 | | - expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0") |
| 369 | + expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0") |
362 | 370 | expect(the_bundle).to include_gems "foo 2.0" |
363 | 371 | end |
364 | 372 | end |
365 | 373 |
|
366 | | - describe "with --optimistic and --strict" do |
| 374 | + describe "with --pessimistic and --strict" do |
367 | 375 | it "throws error" do |
368 | | - bundle "add 'foo' --strict --optimistic", raise_on_error: false |
| 376 | + bundle "add 'foo' --strict --pessimistic", raise_on_error: false |
369 | 377 |
|
370 | | - expect(err).to include("You cannot specify `--strict` and `--optimistic` at the same time") |
| 378 | + expect(err).to include("You cannot specify `--strict` and `--pessimistic` at the same time") |
371 | 379 | end |
372 | 380 | end |
373 | 381 |
|
374 | 382 | context "multiple gems" do |
375 | 383 | it "adds multiple gems to gemfile" do |
376 | 384 | bundle "add bar baz" |
377 | 385 |
|
378 | | - expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) |
379 | | - expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) |
| 386 | + expect(bundled_app_gemfile.read).to match(/gem "bar", ">= 0.12.3"/) |
| 387 | + expect(bundled_app_gemfile.read).to match(/gem "baz", ">= 1.2"/) |
380 | 388 | end |
381 | 389 |
|
382 | 390 | it "throws error if any of the specified gems are present in the gemfile with different version" do |
|
0 commit comments