Sha256: 8056e68d1082cc88d08dbc116b7fbe347b9bef5d340213b573a161df0550b2c7
Contents?: true
Size: 734 Bytes
Versions: 3
Compression:
Stored size: 734 Bytes
Contents
module SpecSupport class HTTPMock MockError = Class.new(StandardError) def initialize @fakes = {} end def client :mock_client end def get(url) @fakes[url] or raise_mock_error! :get, url end def post(url, headers, body) @fakes[url] or raise_mock_error! :post, url end def fake_request(url, fixture = nil) @fakes[url] = fixture ? load_fixture(fixture) : '' end private def load_fixture(fixture) File.read Fixture.path(fixture) end def raise_mock_error!(method, url) raise MockError, "Unmocked HTTP #{method.to_s.upcase} request to #{url.inspect}" end end def http_mock @http_mock ||= HTTPMock.new end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sekken-0.3.0 | spec/support/http_mock.rb |
sekken-0.2.0 | spec/support/http_mock.rb |
sekken-0.1.0 | spec/support/http_mock.rb |