gems: drop webmock.

This commit is contained in:
evazion
2020-06-15 13:26:20 -05:00
committed by evazion
parent 26ad844bbe
commit f730951e7f
5 changed files with 6 additions and 16 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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