@@ -398,143 +398,181 @@ describe "install" do
398
398
end
399
399
end
400
400
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" }
401
+ [" frozen" , " production" ].each do |flag |
402
+ describe " with --#{ flag } " do
403
+ it " fails if shard.lock and shard.yml has different sources" do
404
+ # The sources will not match, so the .lock is not valid regarding the specs
405
+ metadata = {dependencies: {awesome: {git: git_url(:forked_awesome )}}}
406
+ lock = {awesome: " 0.1.0" , d: " 0.1.0" }
407
+
408
+ with_shard(metadata, lock) do
409
+ assert_locked " awesome" , " 0.1.0" , source: {git: git_url(:awesome )}
410
+
411
+ ex = expect_raises(FailedCommand ) { run " shards install --#{ flag } --no-color" }
412
+ ex.stdout.should contain(" Outdated shard.lock (awesome source changed)" )
413
+ ex.stderr.should be_empty
414
+ end
415
+ end
406
416
407
- with_shard(metadata, lock) do
408
- assert_locked " awesome " , " 0.1.0 " , source : {git: git_url( :awesome ) }
417
+ it " fails if shard. lock is missing " do
418
+ metadata = { dependencies : {web: " * " } }
409
419
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
420
+ with_shard(metadata) do
421
+ ex = expect_raises(FailedCommand ) { run " shards install --#{ flag } --no-color" }
422
+ ex.stdout.should contain(" Missing shard.lock" )
423
+ ex.stderr.should be_empty
424
+ end
413
425
end
414
- end
415
426
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" }
427
+ it " fails if shard.lock and shard.yml has different sources with incompatible versions." do
428
+ # User should use update command in this scenario
429
+ # forked_awesome does not have a 0.3.0
430
+ # awesome has 0.3.0
431
+ metadata = {dependencies: {awesome: {git: git_url(:forked_awesome )}}}
432
+ lock = {awesome: " 0.3.0" }
422
433
423
- with_shard(metadata, lock) do
424
- assert_locked " awesome" , " 0.3.0" , source: {git: git_url(:awesome )}
434
+ with_shard(metadata, lock) do
435
+ assert_locked " awesome" , " 0.3.0" , source: {git: git_url(:awesome )}
425
436
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
437
+ ex = expect_raises(FailedCommand ) { run " shards install --#{ flag } --no-color" }
438
+ ex.stdout.should contain(" Maybe a commit, branch or file doesn't exist?" )
439
+ ex.stderr.should be_empty
440
+ end
429
441
end
430
- end
431
442
432
- it " fails to install when dependency requirement changed" do
433
- metadata = {dependencies: {web: " 2.0.0" }}
434
- lock = {web: " 1.0.0" }
443
+ it " fails to install when dependency requirement changed" do
444
+ metadata = {dependencies: {web: " 2.0.0" }}
445
+ lock = {web: " 1.0.0" }
446
+
447
+ with_shard(metadata, lock) do
448
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --#{ flag } " }
449
+ ex.stdout.should contain(" Outdated shard.lock" )
450
+ ex.stderr.should be_empty
451
+ refute_installed " web"
452
+ end
453
+ end
454
+
455
+ it " fails to install when dependency requirement (commit) changed" do
456
+ metadata = {dependencies: {inprogress: {git: git_url(:inprogress ), commit: git_commits(:inprogress )[1 ]}}}
457
+ lock = {inprogress: " 0.1.0+git.commit.#{ git_commits(:inprogress ).first } " }
458
+
459
+ with_shard(metadata, lock) do
460
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --#{ flag } " }
461
+ ex.stdout.should contain(" Outdated shard.lock" )
462
+ refute_installed " inprogress"
463
+ end
464
+ end
435
465
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"
466
+ it " doesn't install new dependencies" do
467
+ metadata = {
468
+ dependencies: {
469
+ web: " ~> 1.0.0" ,
470
+ orm: " *" ,
471
+ },
472
+ }
473
+ lock = {web: " 1.0.0" }
474
+
475
+ with_shard(metadata, lock) do
476
+ ex = expect_raises(FailedCommand ) { run " shards install --#{ flag } --no-color" }
477
+ ex.stdout.should contain(" Outdated shard.lock" )
478
+ ex.stderr.should be_empty
479
+ end
441
480
end
442
- end
443
481
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 } " }
482
+ it " install" do
483
+ metadata = {dependencies: {web: " * " }}
484
+ lock = {web : " 1.0.0 " }
447
485
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 "
486
+ with_shard(metadata, lock) do
487
+ run " shards install --#{ flag } "
488
+ assert_installed " web " , " 1.0.0 "
489
+ end
452
490
end
453
- end
454
491
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" }
492
+ it " install with locked commit" do
493
+ metadata = {dependencies: {web: " *" }}
494
+ web_version = " 2.1.0+git.commit.#{ git_commits(:web ).first } "
495
+ lock = {web: web_version}
463
496
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
497
+ with_shard(metadata, lock) do
498
+ run " shards install --#{ flag } "
499
+ assert_installed " web " , " 2.1.0 " , git: git_commits( :web ).first
500
+ end
468
501
end
469
- end
470
502
471
- it " install" do
472
- metadata = {dependencies: {web: " *" }}
473
- lock = {web: " 1.0.0" }
503
+ it " install with locked commit by a previous shards version" do
504
+ metadata = {dependencies: {web: " *" }}
474
505
475
- with_shard(metadata, lock) do
476
- run " shards install --production"
477
- assert_installed " web" , " 1.0.0"
506
+ with_shard(metadata) do
507
+ File .write " shard.lock" , {version: " 1.0" , shards: {web: {git: git_url(:web ), commit: git_commits(:web ).first}}}
508
+ run " shards install --#{ flag } "
509
+ assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
510
+ end
478
511
end
479
- end
480
512
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}
513
+ it " fails if lock is not up to date with override in main dependency" do
514
+ metadata = {dependencies: {
515
+ awesome: " *" ,
516
+ }}
517
+ lock = {awesome: " 0.1.0" , d: " 0.1.0" }
518
+ override = {dependencies: {
519
+ awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
520
+ }}
521
+ expected_commit = git_commits(:forked_awesome ).first
522
+
523
+ with_shard(metadata, lock, override) do
524
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --#{ flag } " }
525
+ ex.stdout.should contain(" Outdated shard.lock" )
526
+ ex.stderr.should be_empty
527
+ refute_installed " awesome"
528
+ end
529
+ end
485
530
486
- with_shard(metadata, lock) do
487
- run " shards install --production"
488
- assert_installed " web" , " 2.1.0" , git: git_commits(:web ).first
531
+ it " fails if lock is not up to date with override in nested dependency" do
532
+ metadata = {dependencies: {
533
+ intermediate: " *" ,
534
+ }}
535
+ lock = {intermediate: " 0.1.0" , awesome: " 0.1.0" , d: " 0.1.0" }
536
+ override = {dependencies: {
537
+ awesome: {git: git_url(:forked_awesome ), branch: " feature/super" },
538
+ }}
539
+ expected_commit = git_commits(:forked_awesome ).first
540
+
541
+ with_shard(metadata, lock, override) do
542
+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --#{ flag } " }
543
+ ex.stdout.should contain(" Outdated shard.lock" )
544
+ ex.stderr.should be_empty
545
+ refute_installed " awesome"
546
+ end
489
547
end
490
548
end
549
+ end
491
550
492
- it " install with locked commit by a previous shards version" do
493
- metadata = {dependencies: {web: " *" }}
551
+ describe " with --without-development" do
552
+ it " doesn't install development dependencies" do
553
+ metadata = {
554
+ dependencies: {web: " *" , orm: " *" },
555
+ development_dependencies: {mock: " *" },
556
+ }
494
557
495
558
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
559
+ File .exists?(File .join(application_path, " shard.lock" )).should be_false
560
+ run " shards install --without-development"
501
561
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
562
+ # it installed dependencies (recursively)
563
+ assert_installed " web"
564
+ assert_installed " orm"
519
565
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
566
+ # it didn't install development dependencies
567
+ refute_installed " mock"
568
+ refute_installed " minitest"
529
569
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"
570
+ File .exists?(File .join(application_path, " shard.lock" )).should be_true
535
571
end
536
572
end
573
+ end
537
574
575
+ describe " with --production" do
538
576
it " doesn't install development dependencies" do
539
577
metadata = {
540
578
dependencies: {web: " *" , orm: " *" },
0 commit comments