|
161 | 161 | end |
162 | 162 | end |
163 | 163 |
|
| 164 | + describe "cooldown conflicts between duplicate source declarations" do |
| 165 | + it "warns when a block source duplicates the global source with a different cooldown" do |
| 166 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 167 | + expect(Bundler.ui).to receive(:warn).with(/declared more than once with different cooldown values \(`cooldown: 0` here, `cooldown: 7` previously\)/) |
| 168 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 0) |
| 169 | + end |
| 170 | + |
| 171 | + it "warns when a global source duplicates a block source with a different cooldown" do |
| 172 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 0) |
| 173 | + expect(Bundler.ui).to receive(:warn).with(/declared more than once with different cooldown values \(`cooldown: 7` here, `cooldown: 0` previously\)/) |
| 174 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 175 | + end |
| 176 | + |
| 177 | + it "warns when a block source duplicates another block source with a different cooldown" do |
| 178 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 7) |
| 179 | + expect(Bundler.ui).to receive(:warn).with(/declared more than once with different cooldown values/) |
| 180 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 0) |
| 181 | + end |
| 182 | + |
| 183 | + it "warns when a global remote is declared again with a different cooldown" do |
| 184 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 185 | + expect(Bundler.ui).to receive(:warn).with(/declared more than once with different cooldown values/) |
| 186 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 0) |
| 187 | + end |
| 188 | + |
| 189 | + it "warns when a duplicate declaration adds a cooldown to a source declared without one" do |
| 190 | + source_list.add_global_rubygems_remote("https://rubygems.org") |
| 191 | + expect(Bundler.ui).to receive(:warn).with(/declared more than once with different cooldown values \(`cooldown: 7` here, no cooldown previously\)/) |
| 192 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 7) |
| 193 | + end |
| 194 | + |
| 195 | + it "does not warn when the duplicate declaration uses the same cooldown" do |
| 196 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 197 | + expect(Bundler.ui).not_to receive(:warn) |
| 198 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"], "cooldown" => 7) |
| 199 | + end |
| 200 | + |
| 201 | + it "does not warn when the duplicate declaration has no cooldown" do |
| 202 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 203 | + expect(Bundler.ui).not_to receive(:warn) |
| 204 | + source_list.add_rubygems_source("remotes" => ["https://rubygems.org"]) |
| 205 | + end |
| 206 | + |
| 207 | + it "does not warn when different sources declare different cooldowns" do |
| 208 | + source_list.add_global_rubygems_remote("https://rubygems.org", cooldown: 7) |
| 209 | + expect(Bundler.ui).not_to receive(:warn) |
| 210 | + source_list.add_rubygems_source("remotes" => ["https://other-rubygems.org"], "cooldown" => 0) |
| 211 | + end |
| 212 | + end |
| 213 | + |
164 | 214 | describe "#all_sources" do |
165 | 215 | it "includes the global rubygems source when rubygems sources have been added" do |
166 | 216 | source_list.add_git_source("uri" => "git://host/path.git") |
|
0 commit comments