From f730951e7f454ee22720665d1d8ab5e493b30ad2 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 15 Jun 2020 13:26:20 -0500 Subject: [PATCH] gems: drop webmock. --- Gemfile | 1 - Gemfile.lock | 8 -------- test/test_helper.rb | 1 - test/test_helpers/reportbooru_helper.rb | 4 ++-- test/unit/cloudflare_service_test.rb | 8 ++++---- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 4304f26cd..70656ec6b 100644 --- a/Gemfile +++ b/Gemfile @@ -84,7 +84,6 @@ group :test do gem "mocha", require: "mocha/minitest" gem "ffaker" gem "simplecov", "~> 0.17.0", require: false - gem "webmock", require: "webmock/minitest" gem "minitest-ci" gem "minitest-reporters", require: "minitest/reporters" gem "mock_redis" diff --git a/Gemfile.lock b/Gemfile.lock index 7933ca1f5..222928350 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,8 +123,6 @@ GEM coderay (1.1.3) concurrent-ruby (1.1.6) connection_pool (2.2.3) - crack (0.4.3) - safe_yaml (~> 1.0.0) crass (1.0.6) daemons (1.3.1) delayed_job (4.1.8) @@ -156,7 +154,6 @@ GEM ffi (~> 1.0) globalid (0.4.2) activesupport (>= 4.2.0) - hashdiff (1.0.1) http (4.4.1) addressable (~> 2.3) http-cookie (~> 1.0) @@ -402,10 +399,6 @@ GEM unicorn-worker-killer (0.4.4) get_process_mem (~> 0) unicorn (>= 4, < 6) - webmock (3.8.3) - addressable (>= 2.3.6) - crack (>= 0.3.2) - hashdiff (>= 0.4.0, < 2.0.0) webpacker (5.1.1) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -497,7 +490,6 @@ DEPENDENCIES stripe unicorn unicorn-worker-killer - webmock webpacker (>= 4.0.x) whenever diff --git a/test/test_helper.rb b/test/test_helper.rb index 7832ec36c..1d81bdb12 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -43,7 +43,6 @@ class ActiveSupport::TestCase setup do Socket.stubs(:gethostname).returns("www.example.com") - WebMock.allow_net_connect! @temp_dir = Dir.mktmpdir("danbooru-temp-") storage_manager = StorageManager::Local.new(base_dir: @temp_dir) diff --git a/test/test_helpers/reportbooru_helper.rb b/test/test_helpers/reportbooru_helper.rb index 6a99dc5d4..3ec926202 100644 --- a/test/test_helpers/reportbooru_helper.rb +++ b/test/test_helpers/reportbooru_helper.rb @@ -1,7 +1,7 @@ module ReportbooruHelper - def mock_request(url, method: :get, status: 200, body: nil, http: Danbooru::Http.any_instance) + def mock_request(url, method: :get, status: 200, body: nil, http: Danbooru::Http.any_instance, **options) response = HTTP::Response.new(status: status, body: body, version: "1.1") - http.stubs(method).with(url).returns(response) + http.stubs(method).with(url, **options).returns(response) end def mock_post_search_rankings(date = Date.today, rankings) diff --git a/test/unit/cloudflare_service_test.rb b/test/unit/cloudflare_service_test.rb index 146068a6d..cb9bc86be 100644 --- a/test/unit/cloudflare_service_test.rb +++ b/test/unit/cloudflare_service_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'webmock/minitest' class CloudflareServiceTest < ActiveSupport::TestCase def setup @@ -8,10 +7,11 @@ class CloudflareServiceTest < ActiveSupport::TestCase context "#purge_cache" do should "make calls to cloudflare's api" do - stub_request(:any, "api.cloudflare.com") - @cloudflare.purge_cache(["http://localhost/file.txt"]) + url = "http://www.example.com/file.jpg" + mock_request("https://api.cloudflare.com/client/v4/zones/123/purge_cache", method: :delete, json: { files: [url] }) - assert_requested(:delete, "https://api.cloudflare.com/client/v4/zones/123/purge_cache", times: 1) + response = @cloudflare.purge_cache([url]) + assert_equal(200, response.status) end end end