@@ -61,15 +61,15 @@ def test_execute_add
6161 end
6262
6363 def test_execute_add_without_trailing_slash
64- setup_fake_source ( ' https://rubygems.pkg.github.com/my-org' )
64+ setup_fake_source ( " https://rubygems.pkg.github.com/my-org" )
6565
6666 @cmd . handle_options %W[ --add https://rubygems.pkg.github.com/my-org ]
6767
6868 use_ui @ui do
6969 @cmd . execute
7070 end
7171
72- assert_equal [ @gem_repo , ' https://rubygems.pkg.github.com/my-org/' ] , Gem . sources
72+ assert_equal [ @gem_repo , " https://rubygems.pkg.github.com/my-org/" ] , Gem . sources
7373
7474 expected = <<-EOF
7575https://rubygems.pkg.github.com/my-org/ added to sources
@@ -78,16 +78,17 @@ def test_execute_add_without_trailing_slash
7878 assert_equal expected , @ui . output
7979 assert_equal "" , @ui . error
8080 end
81+
8182 def test_execute_add_multiple_trailing_slash
82- setup_fake_source ( ' https://rubygems.pkg.github.com/my-org/' )
83+ setup_fake_source ( " https://rubygems.pkg.github.com/my-org/" )
8384
8485 @cmd . handle_options %W[ --add https://rubygems.pkg.github.com/my-org/// ]
8586
8687 use_ui @ui do
8788 @cmd . execute
8889 end
8990
90- assert_equal [ @gem_repo , ' https://rubygems.pkg.github.com/my-org/' ] , Gem . sources
91+ assert_equal [ @gem_repo , " https://rubygems.pkg.github.com/my-org/" ] , Gem . sources
9192
9293 expected = <<-EOF
9394https://rubygems.pkg.github.com/my-org/ added to sources
@@ -98,15 +99,15 @@ def test_execute_add_multiple_trailing_slash
9899 end
99100
100101 def test_execute_append_without_trailing_slash
101- setup_fake_source ( ' https://rubygems.pkg.github.com/my-org' )
102+ setup_fake_source ( " https://rubygems.pkg.github.com/my-org" )
102103
103104 @cmd . handle_options %W[ --append https://rubygems.pkg.github.com/my-org ]
104105
105106 use_ui @ui do
106107 @cmd . execute
107108 end
108109
109- assert_equal [ @gem_repo , ' https://rubygems.pkg.github.com/my-org/' ] , Gem . sources
110+ assert_equal [ @gem_repo , " https://rubygems.pkg.github.com/my-org/" ] , Gem . sources
110111
111112 expected = <<-EOF
112113https://rubygems.pkg.github.com/my-org/ added to sources
@@ -117,15 +118,15 @@ def test_execute_append_without_trailing_slash
117118 end
118119
119120 def test_execute_prepend_without_trailing_slash
120- setup_fake_source ( ' https://rubygems.pkg.github.com/my-org' )
121+ setup_fake_source ( " https://rubygems.pkg.github.com/my-org" )
121122
122123 @cmd . handle_options %W[ --prepend https://rubygems.pkg.github.com/my-org ]
123124
124125 use_ui @ui do
125126 @cmd . execute
126127 end
127128
128- assert_equal [ @gem_repo , ' https://rubygems.pkg.github.com/my-org/' ] , Gem . sources
129+ assert_equal [ " https://rubygems.pkg.github.com/my-org/" , @gem_repo ] , Gem . sources
129130
130131 expected = <<-EOF
131132https://rubygems.pkg.github.com/my-org/ added to sources
@@ -605,17 +606,14 @@ def test_execute_add_https_rubygems_org
605606
606607 @cmd . handle_options %W[ --add #{ https_rubygems_org } ]
607608
608- ui = Gem ::MockGemUi . new "n"
609-
610- use_ui ui do
611- assert_raise Gem ::MockGemUi ::TermError do
612- @cmd . execute
613- end
609+ use_ui @ui do
610+ @cmd . execute
614611 end
615612
616- assert_equal [ @gem_repo ] , Gem . sources
613+ assert_equal [ @gem_repo , https_rubygems_org ] , Gem . sources
617614
618615 expected = <<-EXPECTED
616+ #{ https_rubygems_org } added to sources
619617 EXPECTED
620618
621619 assert_equal expected , @ui . output
@@ -629,17 +627,14 @@ def test_execute_append_https_rubygems_org
629627
630628 @cmd . handle_options %W[ --append #{ https_rubygems_org } ]
631629
632- ui = Gem ::MockGemUi . new "n"
633-
634- use_ui ui do
635- assert_raise Gem ::MockGemUi ::TermError do
636- @cmd . execute
637- end
630+ use_ui @ui do
631+ @cmd . execute
638632 end
639633
640- assert_equal [ @gem_repo ] , Gem . sources
634+ assert_equal [ @gem_repo , https_rubygems_org ] , Gem . sources
641635
642636 expected = <<-EXPECTED
637+ #{ https_rubygems_org } added to sources
643638 EXPECTED
644639
645640 assert_equal expected , @ui . output
@@ -872,6 +867,31 @@ def test_execute_remove_redundant_source_trailing_slash
872867 Gem . configuration . sources = nil
873868 end
874869
870+ def test_execute_remove_without_trailing_slash
871+ source_uri = "https://rubygems.pkg.github.com/my-org/"
872+
873+ Gem . configuration . sources = [ source_uri ]
874+
875+ setup_fake_source ( source_uri )
876+
877+ @cmd . handle_options %W[ --remove https://rubygems.pkg.github.com/my-org ]
878+
879+ use_ui @ui do
880+ @cmd . execute
881+ end
882+
883+ assert_equal [ ] , Gem . sources
884+
885+ expected = <<-EOF
886+ #{ source_uri } removed from sources
887+ EOF
888+
889+ assert_equal expected , @ui . output
890+ assert_equal "" , @ui . error
891+ ensure
892+ Gem . configuration . sources = nil
893+ end
894+
875895 def test_execute_update
876896 @cmd . handle_options %w[ --update ]
877897
@@ -982,6 +1002,6 @@ def setup_fake_source(uri)
9821002 Marshal . dump specs , io
9831003 end
9841004
985- @fetcher . data [ "#{ uri } /specs.#{ @marshal_version } .gz" ] = specs_dump_gz . string
1005+ @fetcher . data [ "#{ uri . chomp ( "/" ) } /specs.#{ @marshal_version } .gz" ] = specs_dump_gz . string
9861006 end
9871007end
0 commit comments