brew/Library/Homebrew/cask/test/support/fake_fetcher.rb

40 lines
609 B
Ruby
Raw Normal View History

2016-09-24 13:52:43 +02:00
module Hbc
class FakeFetcher
def self.fake_response_for(url, response)
@responses[url] = response
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def self.head(url)
@responses ||= {}
raise("no response faked for #{url.inspect}") unless @responses.key?(url)
@responses[url]
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def self.init
@responses = {}
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def self.clear
@responses = {}
end
2016-08-18 22:11:42 +03:00
end
end
module FakeFetcherHooks
def before_setup
super
Hbc::FakeFetcher.init
end
def after_teardown
super
Hbc::FakeFetcher.clear
end
end
2016-09-24 13:52:43 +02:00
module MiniTest
class Spec
include FakeFetcherHooks
end
2016-08-18 22:11:42 +03:00
end