|
341 | 341 | end
|
342 | 342 |
|
343 | 343 | it "returns the value of SHAKAPACKER_ASSET_HOST if set" do
|
344 |
| - original_env_value = ENV["SHAKAPACKER_ASSET_HOST"] |
345 |
| - ENV["SHAKAPACKER_ASSET_HOST"] = "custom_host.abc" |
346 |
| - |
347 |
| - expect(config.asset_host).to eq "custom_host.abc" |
348 |
| - |
349 |
| - ensure |
350 |
| - ENV["SHAKAPACKER_ASSET_HOST"] = original_env_value |
| 344 | + with_env_variable("SHAKAPACKER_ASSET_HOST" => "custom_host.abc") do |
| 345 | + expect(config.asset_host).to eq "custom_host.abc" |
| 346 | + end |
351 | 347 | end
|
352 | 348 |
|
353 | 349 | it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_ASSET_HOST is not set" do
|
354 |
| - original_env_value = ENV["SHAKAPACKER_ASSET_HOST"] |
355 |
| - ENV["SHAKAPACKER_ASSET_HOST"] = nil |
356 |
| - |
357 | 350 | allow(ActionController::Base.helpers).to receive(:compute_asset_host).and_return("domain.abc")
|
358 | 351 |
|
359 |
| - expect(config.asset_host).to eq "domain.abc" |
360 |
| - ensure |
361 |
| - ENV["SHAKAPACKER_ASSET_HOST"] = original_env_value |
| 352 | + with_env_variable("SHAKAPACKER_ASSET_HOST" => nil) do |
| 353 | + expect(config.asset_host).to eq "domain.abc" |
| 354 | + end |
362 | 355 | end
|
363 | 356 | end
|
364 | 357 |
|
|
372 | 365 | end
|
373 | 366 |
|
374 | 367 | it "returns the value of SHAKAPACKER_RELATIVE_URL_ROOT if set" do
|
375 |
| - original_env_value = ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] |
376 |
| - ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = "custom_value" |
377 |
| - |
378 |
| - expect(config.relative_url_root).to eq "custom_value" |
379 |
| - |
380 |
| - ensure |
381 |
| - ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = original_env_value |
| 368 | + with_env_variable("SHAKAPACKER_RELATIVE_URL_ROOT" => "custom_value") do |
| 369 | + expect(config.relative_url_root).to eq "custom_value" |
| 370 | + end |
382 | 371 | end
|
383 | 372 |
|
384 | 373 | it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_RELATIVE_URL_ROOT is not set" do
|
385 |
| - original_env_value = ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] |
386 |
| - ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = nil |
387 |
| - |
388 | 374 | allow(ActionController::Base).to receive(:relative_url_root).and_return("abcd")
|
389 | 375 |
|
390 |
| - expect(config.relative_url_root).to eq "abcd" |
391 |
| - |
392 |
| - ensure |
393 |
| - ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = original_env_value |
| 376 | + with_env_variable("SHAKAPACKER_RELATIVE_URL_ROOT" => nil) do |
| 377 | + expect(config.relative_url_root).to eq "abcd" |
| 378 | + end |
394 | 379 | end
|
395 | 380 | end
|
396 | 381 | end
|
0 commit comments