source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/unit/matchers/hash_including_matcher_spec.rb
Ruby
mit
4,051
master
2,965
require 'spec_helper' module WebMock module Matchers describe HashIncludingMatcher do it "stringifies the given hash keys" do expect(HashIncludingMatcher.new(a: 1, b: 2)).to eq("a" => 1, "b" => 2) end it "sorts elements in the hash" do expect(HashIncludingMatcher.new(b: 2, a:...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/support/failures.rb
Ruby
mit
4,051
master
200
module Failures def fail() raise_error(RSpec::Expectations::ExpectationNotMetError) end def fail_with(message) raise_error(RSpec::Expectations::ExpectationNotMetError, message) end end
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/support/my_rack_app.rb
Ruby
mit
4,051
master
1,609
require 'rack' class MyRackApp class NonArrayResponse # The rack response body need not implement #join, # but it must implement #each. It need not be an Array. # ActionDispatch::Response, for example, exercises that fact. # See: http://rack.rubyforge.org/doc/SPEC.html def each(*args, &blk) ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/support/network_connection.rb
Ruby
mit
4,051
master
321
require 'timeout' require 'socket' module NetworkConnection def self.connect_to(host, port, timeout=10) Timeout.timeout(timeout) do TCPSocket.new(host, port) end end def self.is_network_available? begin self.connect_to("8.8.8.8", 53, 5) true rescue false end end end
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/support/webmock_server.rb
Ruby
mit
4,051
master
1,301
require 'webrick' require 'logger' require 'singleton' class WebMockServer include Singleton attr_reader :port, :started def host_with_port "localhost:#{port}" end def concurrent unless RUBY_PLATFORM =~ /java/ @pid = Process.fork do yield end else Thread.new { yield }...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/webmock_shared.rb
Ruby
mit
4,051
master
1,750
require 'spec_helper' require 'acceptance/shared/enabling_and_disabling_webmock' require 'acceptance/shared/returning_declared_responses' require 'acceptance/shared/callbacks' require 'acceptance/shared/request_expectations' require 'acceptance/shared/stubbing_requests' require 'acceptance/shared/allowing_and_disabling...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/async_http_client/async_http_client_spec_helper.rb
Ruby
mit
4,051
master
1,706
require 'ostruct' module AsyncHttpClientSpecHelper def http_request(method, url, options = {}, &block) endpoint = Async::HTTP::Endpoint.parse(url) path = endpoint.path path = path + "?" + options[:query] if options[:query] headers = (options[:headers] || {}).each_with_object([]) do |(k, v), o| ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/async_http_client/async_http_client_spec.rb
Ruby
mit
4,051
master
9,593
require 'spec_helper' require 'acceptance/webmock_shared' require_relative './async_http_client_spec_helper' unless RUBY_PLATFORM =~ /java/ require 'protocol/http/body/file' Async.logger.debug! if ENV['ASYNC_LOGGER_DEBUG'] describe 'Async::HTTP::Client' do include AsyncHttpClientSpecHelper include_con...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/excon/excon_spec.rb
Ruby
mit
4,051
master
2,691
require 'spec_helper' require 'acceptance/webmock_shared' require 'acceptance/excon/excon_spec_helper' describe "Excon" do include ExconSpecHelper include_context "with WebMock", :no_url_auth it 'should allow Excon requests to use query hash paramters' do stub_request(:get, "http://example.com/resource/?a=1...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/excon/excon_spec_helper.rb
Ruby
mit
4,051
master
1,468
require 'ostruct' module ExconSpecHelper def http_request(method, uri, options = {}, &block) Excon.defaults[:ssl_verify_peer] = false Excon.defaults[:ciphers] = 'DEFAULT' uri = Addressable::URI.heuristic_parse(uri) uri = uri.to_s.gsub(' ', '%20') excon_options = {} if basic_auth ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/curb/curb_spec.rb
Ruby
mit
4,051
master
18,047
require 'spec_helper' require 'acceptance/webmock_shared' unless RUBY_PLATFORM =~ /java/ require 'acceptance/curb/curb_spec_helper' shared_examples_for "Curb" do include CurbSpecHelper include_examples "with WebMock" describe "when doing PUTs" do it "should stub them" do stub_request(:...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/curb/curb_spec_helper.rb
Ruby
mit
4,051
master
3,314
require 'ostruct' module CurbSpecHelper def http_request(method, uri, options = {}, &block) uri = Addressable::URI.heuristic_parse(uri) body = options[:body] curl = curb_http_request(uri, method, body, options) status, response_headers = WebMock::HttpLibAdapters::CurbAdapter.parse_header_strin...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/http_rb/http_rb_spec_helper.rb
Ruby
mit
4,051
master
1,417
require "ostruct" module HttpRbSpecHelper def http_request(method, uri, options = {}) chain = HTTP if basic_auth = options.delete(:basic_auth) chain = chain.basic_auth(user: basic_auth[0], pass: basic_auth[1]) end ssl_ctx = OpenSSL::SSL::SSLContext.new ssl_ctx.verify_mode = OpenSSL::SSL::...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/http_rb/http_rb_spec.rb
Ruby
mit
4,051
master
3,813
require "spec_helper" require "acceptance/webmock_shared" require "acceptance/http_rb/http_rb_spec_helper" describe "HTTP.rb" do include HttpRbSpecHelper include_examples "with WebMock", :no_status_message context "streaming body" do let(:response) { HTTP.get "http://example.com" } before { stub_simple...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/allowing_and_disabling_net_connect.rb
Ruby
mit
4,051
master
13,611
shared_context "allowing and disabling net connect" do |*adapter_info| describe "when net connect" do describe "is allowed", net_connect: true do before(:each) do WebMock.allow_net_connect! end it "should make a real web request if request is not stubbed" do expect(http_request(...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/stubbing_requests.rb
Ruby
mit
4,051
master
33,349
shared_examples_for "stubbing requests" do |*adapter_info| describe "when requests are stubbed" do describe "based on uri" do it "should return stubbed response even if request have escaped parameters" do stub_request(:get, "www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").to_return(body: "abc") ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/request_expectations.rb
Ruby
mit
4,051
master
45,472
shared_context "request expectations" do |*adapter_info| describe "when request expectations are set" do describe "when net connect is not allowed" do before(:each) do WebMock.disable_net_connect! stub_request(:any, "http://www.example.com") stub_request(:any, "https://www.example.co...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/complex_cross_concern_behaviors.rb
Ruby
mit
4,051
master
1,334
shared_context "complex cross-concern behaviors" do |*adapter_info| it 'allows a response with multiple values for the same header to be recorded and played back exactly as-is' do WebMock.allow_net_connect! recorded_response = nil WebMock.after_request { |_,r| recorded_response = r } real_response = ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/enabling_and_disabling_webmock.rb
Ruby
mit
4,051
master
2,501
shared_context "enabled and disabled webmock" do |*adapter_info| describe "when webmock is disabled" do before(:each) do WebMock.disable! end after(:each) do WebMock.enable! end include_context "disabled WebMock" end describe "when webmock is enabled again" do before(:each) do...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/callbacks.rb
Ruby
mit
4,051
master
5,055
shared_context "callbacks" do |*adapter_info| describe "when after_request callback is declared" do before(:each) do @called = nil WebMock.reset_callbacks stub_request(:get, "http://www.example.com") end it "should not invoke callback unless request is made" do WebMock.after_reque...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/precedence_of_stubs.rb
Ruby
mit
4,051
master
692
shared_context "precedence of stubs" do |*adapter_info| describe "when choosing a matching request stub" do it "should use the last declared matching request stub" do stub_request(:get, "www.example.com").to_return(body: "abc") stub_request(:get, "www.example.com").to_return(body: "def") expect(...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/shared/returning_declared_responses.rb
Ruby
mit
4,051
master
18,653
class MyException < StandardError; end; class Responder def call(request) {body: request.body} end end shared_context "declared responses" do |*adapter_info| describe "when request stub declares that request should raise exception" do it "should raise exception" do stub_request(:get, "www.example....
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/patron/patron_spec_helper.rb
Ruby
mit
4,051
master
1,404
require 'ostruct' module PatronSpecHelper def http_request(method, uri, options = {}, &block) method = method.to_sym uri = Addressable::URI.heuristic_parse(uri) sess = Patron::Session.new sess.base_url = "#{uri.omit(:path, :query).normalize.to_s}".gsub(/\/$/,"") if options[:basic_auth] ses...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/patron/patron_spec.rb
Ruby
mit
4,051
master
4,027
require 'spec_helper' require 'acceptance/webmock_shared' unless RUBY_PLATFORM =~ /java/ require 'acceptance/patron/patron_spec_helper' require 'tmpdir' require 'fileutils' describe "Patron" do include PatronSpecHelper include_examples "with WebMock" describe "when custom functionality is used" ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb
Ruby
mit
4,051
master
1,501
require 'ostruct' module TyphoeusHydraSpecHelper class FakeTyphoeusHydraTimeoutError < StandardError; end class FakeTyphoeusHydraConnectError < StandardError; end def http_request(method, uri, options = {}, &block) uri = uri.gsub(" ", "%20") #typhoeus doesn't like spaces in the uri request_options = {...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
Ruby
mit
4,051
master
5,470
require 'spec_helper' require 'acceptance/webmock_shared' unless RUBY_PLATFORM =~ /java/ require 'acceptance/typhoeus/typhoeus_hydra_spec_helper' describe "Typhoeus::Hydra" do include TyphoeusHydraSpecHelper let(:hydra) { Typhoeus::Hydra.new } before do Typhoeus::Expectation.clear end ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/httpclient/httpclient_spec.rb
Ruby
mit
4,051
master
7,362
require 'spec_helper' require 'acceptance/webmock_shared' require 'ostruct' require 'acceptance/httpclient/httpclient_spec_helper' # FIXME: HTTPClient on JRuby seems to have ordering/concurrency issues with these tests describe "HTTPClient", if: !(RUBY_PLATFORM =~ /java/) do include HTTPClientSpecHelper before(:...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/httpclient/httpclient_spec_helper.rb
Ruby
mit
4,051
master
1,622
module HTTPClientSpecHelper class << self attr_accessor :async_mode end def http_request(method, uri, options = {}, &block) uri = Addressable::URI.heuristic_parse(uri) c = options.fetch(:client) { HTTPClient.new } c.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE c.reset_all if options...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/em_http_request/em_http_request_spec.rb
Ruby
mit
4,051
master
15,851
require 'spec_helper' require 'acceptance/webmock_shared' require 'ostruct' unless RUBY_PLATFORM =~ /java/ require 'acceptance/em_http_request/em_http_request_spec_helper' describe "EM::HttpRequest" do include EMHttpRequestSpecHelper include_context "with WebMock", :no_status_message #functionality ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/em_http_request/em_http_request_spec_helper.rb
Ruby
mit
4,051
master
1,784
module EMHttpRequestSpecHelper def failed EventMachine.stop fail end def http_request(method, uri, options = {}, &block) @http = nil head = options[:headers] || {} if options[:basic_auth] head.merge!('authorization' => options[:basic_auth]) end response = nil error = nil ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/net_http/net_http_spec_helper.rb
Ruby
mit
4,051
master
1,722
module NetHTTPSpecHelper def http_request(method, uri, options = {}, &block) begin uri = URI.parse(uri) rescue uri = Addressable::URI.heuristic_parse(uri) end response = nil clazz = Net::HTTP.const_get("#{method.to_s.capitalize}") req = clazz.new("#{uri.path}#{uri.query ? '?' : ''}...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/net_http/net_http_shared.rb
Ruby
mit
4,051
master
6,271
require 'set' shared_examples_for "Net::HTTP" do describe "when making real requests", net_connect: true do let(:port){ WebMockServer.instance.port } before(:each) do @http = Net::HTTP.new("localhost", port) end it "should return a Net::ReadAdapter from response.body when a real request is ma...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/net_http/real_net_http_spec.rb
Ruby
mit
4,051
master
473
require 'rubygems' require 'rspec' require 'net/http' require 'net/https' require 'stringio' require 'acceptance/net_http/net_http_shared' require 'support/webmock_server' describe "Real Net:HTTP without webmock", without_webmock: true do before(:all) do raise "WebMock has no access here!!!" if defined?(WebMock:...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/net_http/net_http_spec.rb
Ruby
mit
4,051
master
15,260
require 'spec_helper' require 'ostruct' require 'acceptance/webmock_shared' require 'acceptance/net_http/net_http_spec_helper' require 'acceptance/net_http/net_http_shared' include NetHTTPSpecHelper describe "Net:HTTP" do include_examples "with WebMock", :no_url_auth let(:port) { WebMockServer.instance.port } ...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/manticore/manticore_spec.rb
Ruby
mit
4,051
master
3,655
require 'spec_helper' require 'acceptance/webmock_shared' if RUBY_PLATFORM =~ /java/ require 'acceptance/manticore/manticore_spec_helper' describe "Manticore" do include ManticoreSpecHelper include_context "with WebMock", :no_status_message context "calling http methods on Manticore directly using M...
github
bblimke/webmock
https://github.com/bblimke/webmock
spec/acceptance/manticore/manticore_spec_helper.rb
Ruby
mit
4,051
master
858
module ManticoreSpecHelper def http_request(method, uri, options = {}) client = Manticore::Client.new if basic_auth = options[:basic_auth] options = options.merge(auth: {user: basic_auth[0], pass: basic_auth[1]}) end response = client.http(method, uri, options) OpenStruct.new({ body:...
github
bblimke/webmock
https://github.com/bblimke/webmock
minitest/webmock_spec.rb
Ruby
mit
4,051
master
2,293
require File.expand_path(File.dirname(__FILE__) + '/test_helper') describe "Webmock" do include HttpRequestTestHelper before do @stub_http = stub_http_request(:any, "http://www.example.com") @stub_https = stub_http_request(:any, "https://www.example.com") end it "should update assertion...
github
bblimke/webmock
https://github.com/bblimke/webmock
minitest/test_webmock.rb
Ruby
mit
4,051
master
285
require File.expand_path(File.dirname(__FILE__) + '/test_helper') require File.expand_path(File.dirname(__FILE__) + '/../test/shared_test') test_class = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase class MiniTestWebMock < test_class include SharedTest end
github
bblimke/webmock
https://github.com/bblimke/webmock
minitest/test_helper.rb
Ruby
mit
4,051
master
799
require 'rubygems' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require File.expand_path(File.dirname(__FILE__) + '/../test/http_request') gem 'minitest' require 'minitest/autorun' require 'webmock/minitest' test_class = defined?(Minitest::Test) ? Mi...
github
bblimke/webmock
https://github.com/bblimke/webmock
test/shared_test.rb
Ruby
mit
4,051
master
5,875
require File.expand_path(File.dirname(__FILE__) + '/http_request') module SharedTest include HttpRequestTestHelper def setup super @stub_http = stub_http_request(:any, "http://www.example.com") @stub_https = stub_http_request(:any, "https://www.example.com") end def test_assert_requested_with_stu...
github
bblimke/webmock
https://github.com/bblimke/webmock
test/test_webmock.rb
Ruby
mit
4,051
master
411
require File.expand_path(File.dirname(__FILE__) + '/test_helper') require File.expand_path(File.dirname(__FILE__) + '/shared_test') class TestWebMock < Test::Unit::TestCase include SharedTest def teardown # Ensure global Test::Unit teardown was called assert_empty WebMock::RequestRegistry.instance.request...
github
bblimke/webmock
https://github.com/bblimke/webmock
test/test_helper.rb
Ruby
mit
4,051
master
623
require 'rubygems' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'webmock/test_unit' require 'test/unit' class Test::Unit::TestCase AssertionFailedError = Test::Unit::AssertionFailedError rescue MiniTest::Assertion def assert_raise_with_mes...
github
bblimke/webmock
https://github.com/bblimke/webmock
test/http_request.rb
Ruby
mit
4,051
master
714
require 'ostruct' module HttpRequestTestHelper def http_request(method, uri, options = {}) begin uri = URI.parse(uri) rescue uri = Addressable::URI.heuristic_parse(uri) end response = nil clazz = ::Net::HTTP.const_get("#{method.to_s.capitalize}") req = clazz.new("#{uri.path}#{uri....
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock.rb
Ruby
mit
4,051
master
2,395
# frozen_string_literal: true require 'singleton' require 'addressable/uri' require 'addressable/template' require_relative 'webmock/deprecation' require_relative 'webmock/version' require_relative 'webmock/errors' require_relative 'webmock/util/query_mapper' require_relative 'webmock/util/uri' require_relative 'w...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_body_diff.rb
Ruby
mit
4,051
master
1,556
# frozen_string_literal: true require "hashdiff" require "json" module WebMock class RequestBodyDiff def initialize(request_signature, request_stub) @request_signature = request_signature @request_stub = request_stub end def body_diff return {} unless request_signature_diffable?...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_signature_snippet.rb
Ruby
mit
4,051
master
1,647
# frozen_string_literal: true require "pp" module WebMock class RequestSignatureSnippet attr_reader :request_signature, :request_stub def initialize(request_signature) @request_signature = request_signature @request_stub = RequestStub.from_request_signature(request_signature) end def ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/response.rb
Ruby
mit
4,051
master
4,251
# frozen_string_literal: true require "pathname" module WebMock class ResponseFactory def self.response_for(options) if options.respond_to?(:call) WebMock::DynamicResponse.new(options) else WebMock::Response.new(options) end end end class Response def initialize(o...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_pattern.rb
Ruby
mit
4,051
master
13,163
# frozen_string_literal: true module WebMock module RSpecMatcherDetector def rSpecHashIncludingMatcher?(matcher) matcher.class.name =~ /R?Spec::Mocks::ArgumentMatchers::HashIncludingMatcher/ end def rSpecHashExcludingMatcher?(matcher) matcher.class.name =~ /R?Spec::Mocks::ArgumentMatchers::...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/callback_registry.rb
Ruby
mit
4,051
master
846
# frozen_string_literal: true module WebMock class CallbackRegistry @@callbacks = [] def self.add_callback(options, block) @@callbacks << {options: options, block: block} end def self.callbacks @@callbacks end def self.invoke_callbacks(options, request_signature, response) ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/responses_sequence.rb
Ruby
mit
4,051
master
706
# frozen_string_literal: true module WebMock class ResponsesSequence attr_accessor :times_to_repeat def initialize(responses) @times_to_repeat = 1 @responses = responses @current_position = 0 end def end? @times_to_repeat == 0 end def next_response if @times...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/minitest.rb
Ruby
mit
4,051
master
1,051
# frozen_string_literal: true begin require 'minitest/test' test_class = Minitest::Test assertions = "assertions" rescue LoadError require "minitest/unit" test_class = MiniTest::Unit::TestCase assertions = "_assertions" end require 'webmock' WebMock.enable! test_class.class_eval do include WebMock::AP...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/errors.rb
Ruby
mit
4,051
master
505
# frozen_string_literal: true module WebMock class NetConnectNotAllowedError < Exception def initialize(request_signature) request_signature_snippet = RequestSignatureSnippet.new(request_signature) text = [ "Real HTTP connections are disabled. Unregistered request: #{request_signature}", ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/assertion_failure.rb
Ruby
mit
4,051
master
249
# frozen_string_literal: true module WebMock class AssertionFailure @error_class = RuntimeError class << self attr_accessor :error_class def failure(message) raise @error_class.new(message) end end end end
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_signature.rb
Ruby
mit
4,051
master
1,382
# frozen_string_literal: true module WebMock class RequestSignature attr_accessor :method, :uri, :body attr_reader :headers def initialize(method, uri, options = {}) self.method = method.to_sym self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri) assig...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/stub_request_snippet.rb
Ruby
mit
4,051
master
1,168
# frozen_string_literal: true module WebMock class StubRequestSnippet def initialize(request_stub) @request_stub = request_stub end def body_pattern request_pattern.body_pattern end def to_s(with_response = true) request_pattern = @request_stub.request_pattern string = "...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/stub_registry.rb
Ruby
mit
4,051
master
2,342
# frozen_string_literal: true module WebMock class StubRegistry include Singleton attr_accessor :request_stubs def initialize reset! end def global_stubs @global_stubs ||= Hash.new { |h, k| h[k] = [] } end def reset! self.request_stubs = [] end def register...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/api.rb
Ruby
mit
4,051
master
3,813
# frozen_string_literal: true module WebMock module API extend self def stub_request(method, uri) WebMock::StubRegistry.instance. register_request_stub(WebMock::RequestStub.new(method, uri)) end alias_method :stub_http_request, :stub_request def a_request(method, uri) WebMo...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_execution_verifier.rb
Ruby
mit
4,051
master
2,336
# frozen_string_literal: true module WebMock class RequestExecutionVerifier attr_accessor :request_pattern, :expected_times_executed, :times_executed, :at_least_times_executed, :at_most_times_executed def initialize(request_pattern = nil, expected_times_executed = nil, at_least_times_executed = nil, at_mos...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/webmock.rb
Ruby
mit
4,051
master
4,993
# frozen_string_literal: true module WebMock def self.included(clazz) WebMock::Deprecation.warning("include WebMock is deprecated. Please include WebMock::API instead") if clazz.instance_methods.map(&:to_s).include?('request') warn "WebMock#request was not included in #{clazz} to avoid name collision"...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_stub.rb
Ruby
mit
4,051
master
3,647
# frozen_string_literal: true module WebMock class RequestStub attr_accessor :request_pattern def initialize(method, uri) @request_pattern = RequestPattern.new(method, uri) @responses_sequences = [] self end def with(params = {}, &block) @request_pattern.with(params, &block...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/test_unit.rb
Ruby
mit
4,051
master
333
# frozen_string_literal: true require 'test/unit' require 'webmock' WebMock.enable! module Test module Unit class TestCase include WebMock::API teardown def teardown_with_webmock WebMock.reset! end end end end WebMock::AssertionFailure.error_class = Test::Unit::Assertio...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/config.rb
Ruby
mit
4,051
master
455
# frozen_string_literal: true module WebMock class Config include Singleton def initialize @show_stubbing_instructions = true @show_body_diff = true end attr_accessor :allow_net_connect attr_accessor :allow_localhost attr_accessor :allow attr_accessor :net_http_connect_on_st...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/rack_response.rb
Ruby
mit
4,051
master
1,890
# frozen_string_literal: true module WebMock class RackResponse < Response def initialize(app) @app = app end def evaluate(request) env = build_rack_env(request) status, headers, response = @app.call(env) Response.new( body: body_from_rack_response(response), he...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/request_registry.rb
Ruby
mit
4,051
master
853
# frozen_string_literal: true module WebMock class RequestRegistry include Singleton attr_accessor :requested_signatures def initialize reset! end def reset! self.requested_signatures = Util::HashCounter.new end def times_executed(request_pattern) self.requested_sig...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/rspec.rb
Ruby
mit
4,051
master
945
# frozen_string_literal: true require 'webmock' # RSpec 1.x and 2.x compatibility if defined?(RSpec::Expectations::ExpectationNotMetError) RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec elsif defined?(Spec) && defined?(Spec.configure) RSPEC_NAMESPACE = Spec RSPEC_CONFIGURER = Spec::Runner else begin require '...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb
Ruby
mit
4,051
master
360
# frozen_string_literal: true module WebMock class HttpLibAdapterRegistry include Singleton attr_accessor :http_lib_adapters def initialize @http_lib_adapters = {} end def register(lib, adapter) @http_lib_adapters[lib] = adapter end def each_adapter(&block) @http_lib...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/async_http_client_adapter.rb
Ruby
mit
4,051
master
6,966
# frozen_string_literal: true begin require 'async' require 'async/http' rescue LoadError # async-http not found end if defined?(Async::HTTP) module WebMock module HttpLibAdapters class AsyncHttpClientAdapter < HttpLibAdapter adapter_for :async_http_client OriginalAsyncHttpClient = ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/manticore_adapter.rb
Ruby
mit
4,051
master
5,302
# frozen_string_literal: true begin require 'manticore' rescue LoadError # manticore not found end if defined?(Manticore) module WebMock module HttpLibAdapters class ManticoreAdapter < HttpLibAdapter adapter_for :manticore OriginalManticoreClient = Manticore::Client def self....
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/net_http.rb
Ruby
mit
4,051
master
9,445
# frozen_string_literal: true require 'net/http' require 'net/https' require 'stringio' require File.join(File.dirname(__FILE__), 'net_http_response') module WebMock module HttpLibAdapters class NetHttpAdapter < HttpLibAdapter adapter_for :net_http OriginalNetHTTP = Net::HTTP unless const_defined?...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
Ruby
mit
4,051
master
6,307
# frozen_string_literal: true begin require 'typhoeus' rescue LoadError # typhoeus not found end if defined?(Typhoeus) WebMock::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.3.2').check_version! module WebMock module HttpLibAdapters class TyphoeusAdapter < HttpLibAdapter adapter_for ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/excon_adapter.rb
Ruby
mit
4,051
master
5,282
# frozen_string_literal: true begin require 'excon' rescue LoadError # excon not found end if defined?(Excon) WebMock::VersionChecker.new('Excon', Excon::VERSION, '0.27.5').check_version! module WebMock module HttpLibAdapters class ExconAdapter < HttpLibAdapter PARAMS_TO_DELETE = [:expects...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/httpclient_adapter.rb
Ruby
mit
4,051
master
8,609
# frozen_string_literal: true begin require 'httpclient' require 'jsonclient' # defined in 'httpclient' gem as well rescue LoadError # httpclient not found # or jsonclient not defined (in old versions of httclient gem) end if defined?(::HTTPClient) module WebMock module HttpLibAdapters class HTTP...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/net_http_response.rb
Ruby
mit
4,051
master
1,301
# frozen_string_literal: true # This code is entierly copied from VCR (http://github.com/myronmarston/vcr) by courtesy of Myron Marston # A Net::HTTP response that has already been read raises an IOError when #read_body # is called with a destination string or block. # # This causes a problem when VCR records a respo...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/curb_adapter.rb
Ruby
mit
4,051
master
10,129
# frozen_string_literal: true begin require 'curb' rescue LoadError # curb not found end if defined?(Curl) WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', '1.2.2', ['0.8.7']).check_version! module WebMock module HttpLibAdapters class CurbAdapter < HttpLibAdapter adapter_fo...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/em_http_request_adapter.rb
Ruby
mit
4,051
master
7,497
# frozen_string_literal: true begin require 'em-http-request' rescue LoadError # em-http-request not found end if defined?(EventMachine::HttpClient) module WebMock module HttpLibAdapters class EmHttpRequestAdapter < HttpLibAdapter adapter_for :em_http_request OriginalHttpClient = Even...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb_adapter.rb
Ruby
mit
4,051
master
782
# frozen_string_literal: true begin require "http" rescue LoadError # HTTP gem not found end if defined?(HTTP) && defined?(HTTP::VERSION) WebMock::VersionChecker.new("HTTP Gem", HTTP::VERSION, "0.6.0").check_version! module WebMock module HttpLibAdapters class HttpRbAdapter < HttpLibAdapter ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/patron_adapter.rb
Ruby
mit
4,051
master
4,782
# frozen_string_literal: true begin require 'patron' rescue LoadError # patron not found end if defined?(::Patron::Session) module WebMock module HttpLibAdapters class PatronAdapter < ::WebMock::HttpLibAdapter adapter_for :patron OriginalPatronSession = ::Patron::Session unless const_...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb/streamer.rb
Ruby
mit
4,051
master
932
# frozen_string_literal: true module HTTP class Response class Streamer def initialize(str, encoding: Encoding::BINARY) @io = StringIO.new str @encoding = encoding end def readpartial(size = nil, outbuf = nil) unless size if defined?(HTTP::Connection::BUFFER_S...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb/webmock.rb
Ruby
mit
4,051
master
2,089
# frozen_string_literal: true module HTTP class WebMockPerform def initialize(request, options, &perform) @request = request @options = options @perform = perform @request_signature = nil end def exec replay || perform || halt end def request_signature unless...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb/response.rb
Ruby
mit
4,051
master
3,219
# frozen_string_literal: true module HTTP class Response def to_webmock webmock_response = ::WebMock::Response.new webmock_response.status = [status.to_i, reason] webmock_response.body = body.to_s # This call is used to reset the body of the response to enable it to be streamed if n...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb/request.rb
Ruby
mit
4,051
master
634
# frozen_string_literal: true module HTTP class Request def webmock_signature request_body = nil if defined?(HTTP::Request::Body) request_body = String.new first_chunk_encoding = nil body.each do |part| request_body << part first_chunk_encoding ||= part.en...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/http_lib_adapters/http_rb/client.rb
Ruby
mit
4,051
master
392
# frozen_string_literal: true module HTTP class Client alias_method :__perform__, :perform def perform(request, options) return __perform__(request, options) unless webmock_enabled? WebMockPerform.new(request, options) { __perform__(request, options) }.exec end def webmock_enabled? ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/version_checker.rb
Ruby
mit
4,051
master
4,056
# frozen_string_literal: true # This code was created based on https://github.com/myronmarston/vcr/blob/master/lib/vcr/util/version_checker.rb # Thanks to @myronmarston # Copyright (c) 2010-2012 Myron Marston # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/uri.rb
Ruby
mit
4,051
master
3,716
# frozen_string_literal: true module WebMock module Util class URI module CharacterClasses USERINFO = Addressable::URI::CharacterClasses::UNRESERVED + Addressable::URI::CharacterClasses::SUB_DELIMS + "\\:" end ADDRESSABLE_URIS = Hash.new do |hash, key| hash[key] = Addressable...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/hash_counter.rb
Ruby
mit
4,051
master
779
# frozen_string_literal: true require 'thread' module WebMock module Util class HashCounter attr_accessor :hash def initialize self.hash = Hash.new(0) @order = {} @max = 0 @lock = ::Mutex.new end def put(key, num=1) @lock.synchronize do ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/query_mapper.rb
Ruby
mit
4,051
master
10,203
# frozen_string_literal: true module WebMock::Util class QueryMapper class << self #This class is based on Addressable::URI pre 2.3.0 ## # Converts the query component to a Hash value. # # @option [Symbol] notation # May be one of <code>:flat</code>, <code>:dot</code>, or ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/hash_keys_stringifier.rb
Ruby
mit
4,051
master
611
# frozen_string_literal: true module WebMock module Util class HashKeysStringifier def self.stringify_keys!(arg, options = {}) case arg when Array arg.map { |elem| options[:deep] ? stringify_keys!(elem, options) : elem } when Hash Hash[ ...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/hash_validator.rb
Ruby
mit
4,051
master
533
# frozen_string_literal: true module WebMock class HashValidator def initialize(hash) @hash = hash end #This code is based on https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/keys.rb def validate_keys(*valid_keys) valid_keys.flatten! @hash.e...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/headers.rb
Ruby
mit
4,051
master
2,075
# frozen_string_literal: true module WebMock module Util class Headers STANDARD_HEADER_DELIMITER = '-' NONSTANDARD_HEADER_DELIMITER = '_' JOIN = ', ' def self.normalize_headers(headers) return nil unless headers headers.each_with_object({}) do |(name, value), new_head...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/values_stringifier.rb
Ruby
mit
4,051
master
409
# frozen_string_literal: true class WebMock::Util::ValuesStringifier def self.stringify_values(value) case value when String, Numeric, TrueClass, FalseClass value.to_s when Hash Hash[ value.map do |k, v| [k, stringify_values(v)] end ] when Array value...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/parsers/xml.rb
Ruby
mit
4,051
master
340
require_relative "parse_error" require "crack/xml" module WebMock module Util module Parsers class XML def self.parse(xml) ::Crack::XML.parse(xml) rescue ::REXML::ParseException => e raise ParseError, "Invalid XML string: #{xml}, Error: #{e.inspect}" end en...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/util/parsers/json.rb
Ruby
mit
4,051
master
2,994
# frozen_string_literal: true # This is a copy of https://github.com/jnunemaker/crack/blob/master/lib/crack/json.rb # with date parsing removed # Copyright (c) 2004-2008 David Heinemeier Hansson # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/rspec/matchers.rb
Ruby
mit
4,051
master
632
# frozen_string_literal: true require 'webmock' require 'webmock/rspec/matchers/request_pattern_matcher' require 'webmock/rspec/matchers/webmock_matcher' module WebMock module Matchers def have_been_made WebMock::RequestPatternMatcher.new end def have_been_requested WebMock::RequestPatternM...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/rspec/matchers/request_pattern_matcher.rb
Ruby
mit
4,051
master
1,829
# frozen_string_literal: true module WebMock class RequestPatternMatcher def initialize @request_execution_verifier = RequestExecutionVerifier.new end def once @request_execution_verifier.expected_times_executed = 1 self end def twice @request_execution_verifier.expecte...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/rspec/matchers/webmock_matcher.rb
Ruby
mit
4,051
master
1,565
# frozen_string_literal: true module WebMock class WebMockMatcher def initialize(method, uri) @request_execution_verifier = RequestExecutionVerifier.new @request_execution_verifier.request_pattern = RequestPattern.new(method, uri) end def once @request_execution_verifier.expected_time...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/matchers/any_arg_matcher.rb
Ruby
mit
4,051
master
260
# frozen_string_literal: true module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::AnyArgMatcher class AnyArgMatcher def initialize(ignore) end def ==(other) true end end end end
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/matchers/hash_excluding_matcher.rb
Ruby
mit
4,051
master
485
# frozen_string_literal: true module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher # https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb class HashExcludingMatcher < HashArgumentMatcher def ==(actual) supe...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/matchers/hash_including_matcher.rb
Ruby
mit
4,051
master
526
# frozen_string_literal: true module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher # https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb class HashIncludingMatcher < HashArgumentMatcher def ==(actual) supe...
github
bblimke/webmock
https://github.com/bblimke/webmock
lib/webmock/matchers/hash_argument_matcher.rb
Ruby
mit
4,051
master
606
# frozen_string_literal: true module WebMock module Matchers # Base class for Hash matchers # https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb class HashArgumentMatcher def initialize(expected) @expected = Hash[WebMock::Util::HashKeysStringifier.stringif...
github
thoughtbot/suspenders
https://github.com/thoughtbot/suspenders
suspenders.gemspec
Ruby
mit
4,048
main
1,419
require_relative "lib/suspenders/version" Gem::Specification.new do |spec| spec.name = "suspenders" spec.version = Suspenders::VERSION spec.required_ruby_version = Suspenders::MINIMUM_RUBY_VERSION spec.authors = ["thoughtbot"] spec.email = ["support@thoughtbot.com"] spec.homepage = "http://github.com/thoug...