diff options
| author | Koza <[email protected]> | 2023-04-12 19:54:44 +0200 |
|---|---|---|
| committer | Koza <[email protected]> | 2023-04-12 19:55:12 +0200 |
| commit | c891d749bc4dbaf621cf7afeb70c3d08178df098 (patch) | |
| tree | 99650746e4db150d3ecf2c390bc9982146e2d309 /test | |
| parent | aa1ef598f4ec5990cc5e9e43bf37b5e04cccdecc (diff) | |
| download | caxlsx-c891d749bc4dbaf621cf7afeb70c3d08178df098.tar.gz caxlsx-c891d749bc4dbaf621cf7afeb70c3d08178df098.zip | |
Mock out external image requests to make the CI more stable
Diffstat (limited to 'test')
| -rw-r--r-- | test/drawing/tc_pic.rb | 5 | ||||
| -rw-r--r-- | test/tc_helper.rb | 1 | ||||
| -rw-r--r-- | test/util/tc_mime_type_utils.rb | 5 |
3 files changed, 9 insertions, 2 deletions
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 34f24eb3..21d3f931 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -2,13 +2,16 @@ require 'tc_helper.rb' class TestPic < Test::Unit::TestCase def setup + stub_request(:get, 'https://example.com/sample-image.png') + .to_return(body: File.new('examples/sample.png'), status: 200) + @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @test_img = @test_img_jpg = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" @test_img_png = File.dirname(__FILE__) + "/../fixtures/image1.png" @test_img_gif = File.dirname(__FILE__) + "/../fixtures/image1.gif" @test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg" - @test_img_remote_png = "https://via.placeholder.com/150.png" + @test_img_remote_png = "https://example.com/sample-image.png" @test_img_remote_fake = "invalid_URI" @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 @image_remote = ws.add_image :image_src => @test_img_remote_png, remote: true, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 diff --git a/test/tc_helper.rb b/test/tc_helper.rb index af40a1e4..fb85870a 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -7,4 +7,5 @@ end require 'test/unit' require "timecop" +require 'webmock/test_unit' require "axlsx.rb" diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb index 9d116931..52c49e2e 100644 --- a/test/util/tc_mime_type_utils.rb +++ b/test/util/tc_mime_type_utils.rb @@ -1,8 +1,11 @@ require 'tc_helper.rb' class TestMimeTypeUtils < Test::Unit::TestCase def setup + stub_request(:get, 'https://example.com/sample-image.png') + .to_return(body: File.new('examples/sample.png'), status: 200) + @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" - @test_img_url = "https://via.placeholder.com/150.png" + @test_img_url = "https://example.com/sample-image.png" end def teardown |
