@@ -258,29 +258,6 @@ describe "install" do
258
258
259
259
pending " updates locked commit when switching between branches (if locked commit is not reachable)"
260
260
261
- it " fails to install when dependency requirement changed in production" do
262
- metadata = {dependencies: {web: " 2.0.0" }}
263
- lock = {web: " 1.0.0" }
264
-
265
- with_shard(metadata, lock) do
266
- ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
267
- ex.stdout.should contain(" Outdated shard.lock" )
268
- ex.stderr.should be_empty
269
- refute_installed " web"
270
- end
271
- end
272
-
273
- it " fails to install when dependency requirement (commit) changed in production" do
274
- metadata = {dependencies: {inprogress: {git: git_url(:inprogress ), commit: git_commits(:inprogress )[1 ]}}}
275
- lock = {inprogress: " 0.1.0+git.commit.#{ git_commits(:inprogress ).first } " }
276
-
277
- with_shard(metadata, lock) do
278
- ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
279
- ex.stdout.should contain(" Outdated shard.lock" )
280
- refute_installed " inprogress"
281
- end
282
- end
283
-
284
261
it " updates when dependency requirement changed" do
285
262
metadata = {dependencies: {web: " 2.0.0" }}
286
263
lock = {web: " 1.0.0" }
@@ -350,36 +327,6 @@ describe "install" do
350
327
end
351
328
end
352
329
353
- it " fails if shard.lock and shard.yml has different sources" do
354
- # The sources will not match, so the .lock is not valid regarding the specs
355
- metadata = {dependencies: {awesome: {git: git_url(:forked_awesome )}}}
356
- lock = {awesome: " 0.1.0" , d: " 0.1.0" }
357
-
358
- with_shard(metadata, lock) do
359
- assert_locked " awesome" , " 0.1.0" , source: {git: git_url(:awesome )}
360
-
361
- ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
362
- ex.stdout.should contain(" Outdated shard.lock (awesome source changed)" )
363
- ex.stderr.should be_empty
364
- end
365
- end
366
-
367
- it " fails if shard.lock and shard.yml has different sources with incompatible versions." do
368
- # User should use update command in this scenario
369
- # forked_awesome does not have a 0.3.0
370
- # awesome has 0.3.0
371
- metadata = {dependencies: {awesome: {git: git_url(:forked_awesome )}}}
372
- lock = {awesome: " 0.3.0" }
373
-
374
- with_shard(metadata, lock) do
375
- assert_locked " awesome" , " 0.3.0" , source: {git: git_url(:awesome )}
376
-
377
- ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
378
- ex.stdout.should contain(" Maybe a commit, branch or file doesn't exist?" )
379
- ex.stderr.should be_empty
380
- end
381
- end
382
-
383
330
it " install subdependency of new dependency respecting lock" do
384
331
metadata = {dependencies: {c: " *" , d: " *" }}
385
332
lock = {d: " 0.1.0" }
@@ -451,74 +398,165 @@ describe "install" do
451
398
end
452
399
end
453
400
454
- it " production doesn't install development dependencies " do
455
- metadata = {
456
- dependencies: { web: " * " , orm: " * " },
457
- development_dependencies : {mock: " * " },
458
- }
401
+ describe " with --production " do
402
+ it " fails if shard.lock and shard.yml has different sources " do
403
+ # The sources will not match, so the .lock is not valid regarding the specs
404
+ metadata = { dependencies : {awesome: { git: git_url( :forked_awesome )}}}
405
+ lock = { awesome: " 0.1.0 " , d: " 0.1.0 " }
459
406
460
- with_shard(metadata) do
461
- File .exists?(File .join(application_path, " shard.lock" )).should be_false
462
- run " shards install --production"
407
+ with_shard(metadata, lock) do
408
+ assert_locked " awesome" , " 0.1.0" , source: {git: git_url(:awesome )}
463
409
464
- # it installed dependencies (recursively)
465
- assert_installed " web"
466
- assert_installed " orm"
467
- assert_installed " pg"
410
+ ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
411
+ ex.stdout.should contain(" Outdated shard.lock (awesome source changed)" )
412
+ ex.stderr.should be_empty
413
+ end
414
+ end
468
415
469
- # it didn't install development dependencies
470
- refute_installed " mock"
471
- refute_installed " minitest"
416
+ it " fails if shard.lock and shard.yml has different sources with incompatible versions." do
417
+ # User should use update command in this scenario
418
+ # forked_awesome does not have a 0.3.0
419
+ # awesome has 0.3.0
420
+ metadata = {dependencies: {awesome: {git: git_url(:forked_awesome )}}}
421
+ lock = {awesome: " 0.3.0" }
422
+
423
+ with_shard(metadata, lock) do
424
+ assert_locked " awesome" , " 0.3.0" , source: {git: git_url(:awesome )}
472
425
473
- # it didn't generate lock file
474
- File .exists?(File .join(application_path, " shard.lock" )).should be_false
426
+ ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
427
+ ex.stdout.should contain(" Maybe a commit, branch or file doesn't exist?" )
428
+ ex.stderr.should be_empty
429
+ end
475
430
end
476
- end
477
431
478
- it " production doesn't install new dependencies" do
479
- metadata = {
480
- dependencies: {
481
- web: " ~> 1.0.0" ,
482
- orm: " *" ,
483
- },
484
- }
485
- lock = {web: " 1.0.0" }
432
+ it " fails to install when dependency requirement changed" do
433
+ metadata = {dependencies: {web: " 2.0.0" }}
434
+ lock = {web: " 1.0.0" }
486
435
487
- with_shard(metadata, lock) do
488
- ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
489
- ex.stdout.should contain(" Outdated shard.lock" )
490
- ex.stderr.should be_empty
436
+ with_shard(metadata, lock) do
437
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
438
+ ex.stdout.should contain(" Outdated shard.lock" )
439
+ ex.stderr.should be_empty
440
+ refute_installed " web"
441
+ end
491
442
end
492
- end
493
443
494
- it " install in production mode " do
495
- metadata = {dependencies: {web: " * " }}
496
- lock = {web : " 1.0.0 " }
444
+ it " fails to install when dependency requirement (commit) changed " do
445
+ metadata = {dependencies: {inprogress: { git: git_url( :inprogress ), commit: git_commits( :inprogress )[ 1 ]} }}
446
+ lock = {inprogress : " 0. 1.0+git.commit. #{ git_commits( :inprogress ).first } " }
497
447
498
- with_shard(metadata, lock) do
499
- run " shards install --production"
500
- assert_installed " web" , " 1.0.0"
448
+ with_shard(metadata, lock) do
449
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
450
+ ex.stdout.should contain(" Outdated shard.lock" )
451
+ refute_installed " inprogress"
452
+ end
501
453
end
502
- end
503
454
504
- it " install in production mode with locked commit" do
505
- metadata = {dependencies: {web: " *" }}
506
- web_version = " 2.1.0+git.commit.#{ git_commits(:web ).first } "
507
- lock = {web: web_version}
455
+ it " doesn't install new dependencies" do
456
+ metadata = {
457
+ dependencies: {
458
+ web: " ~> 1.0.0" ,
459
+ orm: " *" ,
460
+ },
461
+ }
462
+ lock = {web: " 1.0.0" }
508
463
509
- with_shard(metadata, lock) do
510
- run " shards install --production"
511
- assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
464
+ with_shard(metadata, lock) do
465
+ ex = expect_raises(FailedCommand ) { run " shards install --production --no-color" }
466
+ ex.stdout.should contain(" Outdated shard.lock" )
467
+ ex.stderr.should be_empty
468
+ end
512
469
end
513
- end
514
470
515
- it " install in production mode with locked commit by a previous shards version" do
516
- metadata = {dependencies: {web: " *" }}
471
+ it " install" do
472
+ metadata = {dependencies: {web: " *" }}
473
+ lock = {web: " 1.0.0" }
517
474
518
- with_shard(metadata) do
519
- File .write " shard.lock" , {version: " 1.0" , shards: {web: {git: git_url(:web ), commit: git_commits(:web ).first}}}
520
- run " shards install --production"
521
- assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
475
+ with_shard(metadata, lock) do
476
+ run " shards install --production"
477
+ assert_installed " web" , " 1.0.0"
478
+ end
479
+ end
480
+
481
+ it " install with locked commit" do
482
+ metadata = {dependencies: {web: " *" }}
483
+ web_version = " 2.1.0+git.commit.#{ git_commits(:web ).first } "
484
+ lock = {web: web_version}
485
+
486
+ with_shard(metadata, lock) do
487
+ run " shards install --production"
488
+ assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
489
+ end
490
+ end
491
+
492
+ it " install with locked commit by a previous shards version" do
493
+ metadata = {dependencies: {web: " *" }}
494
+
495
+ with_shard(metadata) do
496
+ File .write " shard.lock" , {version: " 1.0" , shards: {web: {git: git_url(:web ), commit: git_commits(:web ).first}}}
497
+ run " shards install --production"
498
+ assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
499
+ end
500
+ end
501
+
502
+ it " fails if lock is not up to date with override in main dependency" do
503
+ metadata = {dependencies: {
504
+ awesome: " *" ,
505
+ }}
506
+ lock = {awesome: " 0.1.0" , d: " 0.1.0" }
507
+ override = {dependencies: {
508
+ awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
509
+ }}
510
+ expected_commit = git_commits(:forked_awesome ).first
511
+
512
+ with_shard(metadata, lock, override) do
513
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
514
+ ex.stdout.should contain(" Outdated shard.lock" )
515
+ ex.stderr.should be_empty
516
+ refute_installed " awesome"
517
+ end
518
+ end
519
+
520
+ it " fails if lock is not up to date with override in nested dependency" do
521
+ metadata = {dependencies: {
522
+ intermediate: " *" ,
523
+ }}
524
+ lock = {intermediate: " 0.1.0" , awesome: " 0.1.0" , d: " 0.1.0" }
525
+ override = {dependencies: {
526
+ awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
527
+ }}
528
+ expected_commit = git_commits(:forked_awesome ).first
529
+
530
+ with_shard(metadata, lock, override) do
531
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
532
+ ex.stdout.should contain(" Outdated shard.lock" )
533
+ ex.stderr.should be_empty
534
+ refute_installed " awesome"
535
+ end
536
+ end
537
+
538
+ it " doesn't install development dependencies" do
539
+ metadata = {
540
+ dependencies: {web: " *" , orm: " *" },
541
+ development_dependencies: {mock: " *" },
542
+ }
543
+
544
+ with_shard(metadata) do
545
+ File .exists?(File .join(application_path, " shard.lock" )).should be_false
546
+ run " shards install --production"
547
+
548
+ # it installed dependencies (recursively)
549
+ assert_installed " web"
550
+ assert_installed " orm"
551
+ assert_installed " pg"
552
+
553
+ # it didn't install development dependencies
554
+ refute_installed " mock"
555
+ refute_installed " minitest"
556
+
557
+ # it didn't generate lock file
558
+ File .exists?(File .join(application_path, " shard.lock" )).should be_false
559
+ end
522
560
end
523
561
end
524
562
@@ -1072,42 +1110,6 @@ describe "install" do
1072
1110
end
1073
1111
end
1074
1112
1075
- it " fails if lock is not up to date with override in main dependency in production" do
1076
- metadata = {dependencies: {
1077
- awesome: " *" ,
1078
- }}
1079
- lock = {awesome: " 0.1.0" , d: " 0.1.0" }
1080
- override = {dependencies: {
1081
- awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
1082
- }}
1083
- expected_commit = git_commits(:forked_awesome ).first
1084
-
1085
- with_shard(metadata, lock, override) do
1086
- ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
1087
- ex.stdout.should contain(" Outdated shard.lock" )
1088
- ex.stderr.should be_empty
1089
- refute_installed " awesome"
1090
- end
1091
- end
1092
-
1093
- it " fails if lock is not up to date with override in nested dependency in production" do
1094
- metadata = {dependencies: {
1095
- intermediate: " *" ,
1096
- }}
1097
- lock = {intermediate: " 0.1.0" , awesome: " 0.1.0" , d: " 0.1.0" }
1098
- override = {dependencies: {
1099
- awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
1100
- }}
1101
- expected_commit = git_commits(:forked_awesome ).first
1102
-
1103
- with_shard(metadata, lock, override) do
1104
- ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
1105
- ex.stdout.should contain(" Outdated shard.lock" )
1106
- ex.stderr.should be_empty
1107
- refute_installed " awesome"
1108
- end
1109
- end
1110
-
1111
1113
it " uses override relative file specified in SHARDS_OVERRIDE env var" do
1112
1114
metadata = {dependencies: {
1113
1115
intermediate: " *" ,
0 commit comments