@@ -475,20 +475,26 @@ def file
475
475
File . join ( destination_root , "doc" , "COMMENTER" )
476
476
end
477
477
478
- unmodified_comments_file = /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n ind#igo\n # ind#igo\n __end__/
478
+ unmodified_comments_file = /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/
479
479
480
480
describe "#uncomment_lines" do
481
481
it "uncomments all matching lines in the file" do
482
482
action :uncomment_lines , "doc/COMMENTER" , "green"
483
- expect ( File . binread ( file ) ) . to match ( /__start__\n greenblue\n #\n # yellowblue\n #yellowred\n greenred\n orange\n purple\n ind#igo\n # ind#igo\n __end__/ )
483
+ expect ( File . binread ( file ) ) . to match ( /__start__\n greenblue\n #\n # yellowblue\n #yellowred\n greenred\n orange\n purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
484
484
485
485
action :uncomment_lines , "doc/COMMENTER" , "red"
486
- expect ( File . binread ( file ) ) . to match ( /__start__\n greenblue\n #\n # yellowblue\n yellowred\n greenred\n orange\n purple\n ind#igo\n # ind#igo\n __end__/ )
486
+ expect ( File . binread ( file ) ) . to match ( /__start__\n greenblue\n #\n # yellowblue\n yellowred\n greenred\n orange\n purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
487
487
end
488
488
489
489
it "correctly uncomments lines with hashes in them" do
490
490
action :uncomment_lines , "doc/COMMENTER" , "ind#igo"
491
- expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n ind#igo\n ind#igo\n __end__/ )
491
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n ind#igo\n ind#igo\n # spaces_between\n __end__/ )
492
+ end
493
+
494
+ it "will leave the space which existed before the comment hash in tact" do
495
+ action :uncomment_lines , "doc/COMMENTER" , "ind#igo"
496
+ action :uncomment_lines , "doc/COMMENTER" , "spaces_between"
497
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n ind#igo\n ind#igo\n spaces_between\n __end__/ )
492
498
end
493
499
494
500
it "does not modify already uncommented lines in the file" do
@@ -499,22 +505,22 @@ def file
499
505
500
506
it "does not uncomment the wrong line when uncommenting lines preceded by blank commented line" do
501
507
action :uncomment_lines , "doc/COMMENTER" , "yellow"
502
- expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n yellowblue\n yellowred\n #greenred\n orange\n purple\n ind#igo\n # ind#igo\n __end__/ )
508
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n yellowblue\n yellowred\n #greenred\n orange\n purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
503
509
end
504
510
end
505
511
506
512
describe "#comment_lines" do
507
513
it "comments lines which are not commented" do
508
514
action :comment_lines , "doc/COMMENTER" , "orange"
509
- expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n # orange\n purple\n ind#igo\n # ind#igo\n __end__/ )
515
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n # orange\n purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
510
516
511
517
action :comment_lines , "doc/COMMENTER" , "purple"
512
- expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n # orange\n # purple\n ind#igo\n # ind#igo\n __end__/ )
518
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n # orange\n # purple\n ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
513
519
end
514
520
515
521
it "correctly comments lines with hashes in them" do
516
522
action :comment_lines , "doc/COMMENTER" , "ind#igo"
517
- expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n # ind#igo\n # ind#igo\n __end__/ )
523
+ expect ( File . binread ( file ) ) . to match ( /__start__\n # greenblue\n #\n # yellowblue\n #yellowred\n #greenred\n orange\n purple\n # ind#igo\n # ind#igo\n # spaces_between \ n __end__/ )
518
524
end
519
525
520
526
it "does not modify already commented lines" do
0 commit comments