repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/spec/javascript/test_controller.rb | spec/javascript/test_controller.rb | # frozen_string_literal: true
class TestController < ApplicationController
skip_before_action :verify_authenticity_token
def index
authorization.skip
prepend_view_path(test_path("support", "views"))
render(layout: false, locals: { js_files: })
end
def spec
authorization.skip
send_file(tes... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/lib/admin_constraint.rb | lib/admin_constraint.rb | # frozen_string_literal: true
class AdminConstraint
def matches?(request)
request.session.key?(:user_id) &&
User.find(request.session[:user_id]).admin?
end
end
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/application.rb | config/application.rb | # frozen_string_literal: true
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_ma... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/environment.rb | config/environment.rb | # frozen_string_literal: true
# Load the Rails application.
require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/puma.rb | config/puma.rb | # frozen_string_literal: true
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (wo... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/routes.rb | config/routes.rb | # frozen_string_literal: true
require_relative "../lib/admin_constraint"
Rails.application.routes.draw do
scope :admin, constraints: AdminConstraint.new do
mount GoodJob::Engine => "good_job"
resources :settings, only: [:index, :update]
get "/debug", to: "debug#index"
end
resource :profile, only: ... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/boot.rb | config/boot.rb | # frozen_string_literal: true
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/content_security_policy.rb | config/initializers/content_security_policy.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.configure... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/filter_parameter_logging.rb | config/initializers/filter_parameter_logging.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password)
# and filtered from the log file. Use this to limit dissemination of sensitive
# information. See the ActiveSupport::ParameterFilter documentation for
... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/good_job.rb | config/initializers/good_job.rb | # frozen_string_literal: true
GoodJob.preserve_job_records = false
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/session_store.rb | config/initializers/session_store.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
session_config = { key: "_stringer_session", expire_after: 2.weeks }
Rails.application.config.session_store(:cookie_store, **session_config)
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/feed_bag.rb | config/initializers/feed_bag.rb | # frozen_string_literal: true
Feedbag.logger = Rails.logger
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/inflections.rb | config/initializers/inflections.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflec... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/permissions_policy.rb | config/initializers/permissions_policy.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
# Rails.application.config.permissions_policy do |policy|
# policy.camera ... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/dotenv.rb | config/initializers/dotenv.rb | # frozen_string_literal: true
Dotenv.require_keys(
"SECRET_KEY_BASE",
"ENCRYPTION_PRIMARY_KEY",
"ENCRYPTION_DETERMINISTIC_KEY",
"ENCRYPTION_KEY_DERIVATION_SALT"
)
| ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/initializers/assets.rb | config/initializers/assets.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.image... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/environments/test.rb | config/environments/test.rb | # frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.applic... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/environments/development.rb | config/environments/development.rb | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eage... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
stringer-rss/stringer | https://github.com/stringer-rss/stringer/blob/9b7a95c9c5b8aaec6ab87359583e3ee49279422c/config/environments/production.rb | config/environments/production.rb | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better pe... | ruby | MIT | 9b7a95c9c5b8aaec6ab87359583e3ee49279422c | 2026-01-04T15:47:22.789280Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/minitest/test_webmock.rb | minitest/test_webmock.rb | 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
| ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/minitest/webmock_spec.rb | minitest/webmock_spec.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/minitest/test_helper.rb | minitest/test_helper.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/test/test_webmock.rb | test/test_webmock.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/test/shared_test.rb | test/shared_test.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/test/http_request.rb | test/http_request.rb | 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.... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/test/test_helper.rb | test/test_helper.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/quality_spec.rb | spec/quality_spec.rb | require "spec_helper"
# Borrowed from Bundler
# https://github.com/carlhuda/bundler/blob/1-0-stable/spec/quality_spec.rb
# Portions copyright (c) 2010 Andre Arko
# Portions copyright (c) 2009 Engine Yard
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software a... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/spec_helper.rb | spec/spec_helper.rb | require 'rubygems'
require 'httpclient'
unless RUBY_PLATFORM =~ /java/
require 'curb'
require 'em-http'
require 'patron'
require 'typhoeus'
end
if RUBY_PLATFORM =~ /java/
require 'manticore'
end
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
requ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/support/network_connection.rb | spec/support/network_connection.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/support/webmock_server.rb | spec/support/webmock_server.rb | 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 }... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/support/my_rack_app.rb | spec/support/my_rack_app.rb | 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)
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/support/failures.rb | spec/support/failures.rb | module Failures
def fail()
raise_error(RSpec::Expectations::ExpectationNotMetError)
end
def fail_with(message)
raise_error(RSpec::Expectations::ExpectationNotMetError, message)
end
end
| ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/webmock_shared.rb | spec/acceptance/webmock_shared.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/net_http/net_http_spec.rb | spec/acceptance/net_http/net_http_spec.rb | 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 }
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/net_http/net_http_spec_helper.rb | spec/acceptance/net_http/net_http_spec_helper.rb | 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 ? '?' : ''}... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/net_http/real_net_http_spec.rb | spec/acceptance/net_http/real_net_http_spec.rb | 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:... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/net_http/net_http_shared.rb | spec/acceptance/net_http/net_http_shared.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/excon/excon_spec_helper.rb | spec/acceptance/excon/excon_spec_helper.rb | 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 ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/excon/excon_spec.rb | spec/acceptance/excon/excon_spec.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/patron/patron_spec.rb | spec/acceptance/patron/patron_spec.rb | 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" ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/patron/patron_spec_helper.rb | spec/acceptance/patron/patron_spec_helper.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/curb/curb_spec.rb | spec/acceptance/curb/curb_spec.rb | 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(:... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/curb/curb_spec_helper.rb | spec/acceptance/curb/curb_spec_helper.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/httpclient/httpclient_spec.rb | spec/acceptance/httpclient/httpclient_spec.rb | 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(:... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/httpclient/httpclient_spec_helper.rb | spec/acceptance/httpclient/httpclient_spec_helper.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb | spec/acceptance/typhoeus/typhoeus_hydra_spec.rb | 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
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb | spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb | 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 = {... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/manticore/manticore_spec_helper.rb | spec/acceptance/manticore/manticore_spec_helper.rb | 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:... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/manticore/manticore_spec.rb | spec/acceptance/manticore/manticore_spec.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/returning_declared_responses.rb | spec/acceptance/shared/returning_declared_responses.rb | 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.... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/allowing_and_disabling_net_connect.rb | spec/acceptance/shared/allowing_and_disabling_net_connect.rb | 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(... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/stubbing_requests.rb | spec/acceptance/shared/stubbing_requests.rb | 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")
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | true |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/request_expectations.rb | spec/acceptance/shared/request_expectations.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | true |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/callbacks.rb | spec/acceptance/shared/callbacks.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/complex_cross_concern_behaviors.rb | spec/acceptance/shared/complex_cross_concern_behaviors.rb | 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 = ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/precedence_of_stubs.rb | spec/acceptance/shared/precedence_of_stubs.rb | 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(... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/shared/enabling_and_disabling_webmock.rb | spec/acceptance/shared/enabling_and_disabling_webmock.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/http_rb/http_rb_spec_helper.rb | spec/acceptance/http_rb/http_rb_spec_helper.rb | 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::... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/http_rb/http_rb_spec.rb | spec/acceptance/http_rb/http_rb_spec.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/em_http_request/em_http_request_spec.rb | spec/acceptance/em_http_request/em_http_request_spec.rb | 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 ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/em_http_request/em_http_request_spec_helper.rb | spec/acceptance/em_http_request/em_http_request_spec_helper.rb | 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
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/async_http_client/async_http_client_spec.rb | spec/acceptance/async_http_client/async_http_client_spec.rb | 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/acceptance/async_http_client/async_http_client_spec_helper.rb | spec/acceptance/async_http_client/async_http_client_spec_helper.rb | 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|
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/response_spec.rb | spec/unit/response_spec.rb | require 'spec_helper'
describe WebMock::ResponseFactory do
describe "response_for" do
it "should create response with options passed as arguments" do
options = {body: "abc", headers: {a: :b}}
expect(WebMock::Response).to receive(:new).with(options).and_return(@response = double(WebMock::Response))
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/stub_request_snippet_spec.rb | spec/unit/stub_request_snippet_spec.rb | require 'spec_helper'
describe WebMock::StubRequestSnippet do
describe "to_s" do
describe "GET" do
before(:each) do
@request_signature = WebMock::RequestSignature.new(:get, "www.example.com/?a=b&c=d", headers: {})
end
it "should print stub request snippet with url with params and metho... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/api_spec.rb | spec/unit/api_spec.rb | require 'spec_helper'
describe WebMock::API do
describe '#hash_including' do
subject { klass.new.hash_including(args) }
let(:args) { { data: :one } }
context 'when mixed into a class that does not define `hash_including`' do
let(:klass) do
Class.new do
include WebMock::API
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_registry_spec.rb | spec/unit/request_registry_spec.rb | require 'spec_helper'
describe WebMock::RequestRegistry do
before(:each) do
WebMock::RequestRegistry.instance.reset!
@request_pattern = WebMock::RequestPattern.new(:get, "www.example.com")
@request_signature = WebMock::RequestSignature.new(:get, "www.example.com")
end
describe "reset!" do
befor... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_signature_snippet_spec.rb | spec/unit/request_signature_snippet_spec.rb | require "spec_helper"
RSpec.describe WebMock::RequestSignatureSnippet do
it("is real"){expect{subject}.not_to(raise_error)}
subject { WebMock::RequestSignatureSnippet.new(request_signature) }
let(:uri) { "http://example.com" }
let(:method) { "GET" }
let(:request_signature) { WebMock::RequestSignature.new(... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/rack_response_spec.rb | spec/unit/rack_response_spec.rb | require 'spec_helper'
describe WebMock::RackResponse do
before :each do
@rack_response = WebMock::RackResponse.new(MyRackApp)
end
it "should hook up to a rack appliance" do
request = WebMock::RequestSignature.new(:get, 'www.example.com')
response = @rack_response.evaluate(request)
expect(respon... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_execution_verifier_spec.rb | spec/unit/request_execution_verifier_spec.rb | require 'spec_helper'
describe WebMock::RequestExecutionVerifier do
before(:each) do
@verifier = WebMock::RequestExecutionVerifier.new
@request_pattern = double(WebMock::RequestPattern, to_s: "www.example.com")
@verifier.request_pattern = @request_pattern
allow(WebMock::RequestRegistry.instance).to r... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_signature_spec.rb | spec/unit/request_signature_spec.rb | require 'spec_helper'
describe WebMock::RequestSignature do
describe "initialization" do
it "assign the uri to be the normalized uri" do
expect(WebMock::Util::URI).to receive(:normalize_uri).and_return("www.example.kom")
signature = WebMock::RequestSignature.new(:get, "www.example.com")
expec... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/webmock_spec.rb | spec/unit/webmock_spec.rb | require 'spec_helper'
describe "WebMock" do
describe ".version" do
it "should report version" do
expect(WebMock.version).to eq(WebMock::VERSION)
end
it "should not require safe_yaml" do
expect(defined?SafeYAML).to eq(nil)
end
it "should alias enable_net_connect! to allow_net_connec... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_pattern_spec.rb | spec/unit/request_pattern_spec.rb | require 'spec_helper'
describe WebMock::RequestPattern do
describe "describing itself" do
it "should report string describing itself" do
expect(WebMock::RequestPattern.new(:get, "www.example.com",
body: "abc", headers: {'A' => 'a', 'B' => 'b'}).to_s).to eq(
"GET http://www.example.com/ with ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | true |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_body_diff_spec.rb | spec/unit/request_body_diff_spec.rb | require 'spec_helper'
RSpec.describe WebMock::RequestBodyDiff do
subject { WebMock::RequestBodyDiff.new(request_signature, request_stub) }
let(:uri) { "http://example.com" }
let(:method) { "GET" }
let(:request_stub) { WebMock::RequestStub.new(method, uri) }
let(:request_signature) { WebMock::RequestSignatu... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/request_stub_spec.rb | spec/unit/request_stub_spec.rb | require 'spec_helper'
describe WebMock::RequestStub do
before(:each) do
@request_stub = WebMock::RequestStub.new(:get, "www.example.com")
end
it "should have request pattern with method and uri" do
expect(@request_stub.request_pattern.to_s).to eq("GET http://www.example.com/")
end
it "should have ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/errors_spec.rb | spec/unit/errors_spec.rb | require 'spec_helper'
describe "errors" do
describe WebMock::NetConnectNotAllowedError do
describe "message" do
it "should have message with request signature and snippet" do
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
allow(WebMock::StubRequestS... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/stub_registry_spec.rb | spec/unit/stub_registry_spec.rb | require 'spec_helper'
describe WebMock::StubRegistry do
before(:each) do
WebMock::StubRegistry.instance.reset!
@request_pattern = WebMock::RequestPattern.new(:get, "www.example.com")
@request_signature = WebMock::RequestSignature.new(:get, "www.example.com")
@request_stub = WebMock::RequestStub.new(... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/hash_keys_stringifier_spec.rb | spec/unit/util/hash_keys_stringifier_spec.rb | require 'spec_helper'
describe WebMock::Util::HashKeysStringifier do
it "should recursively stringify all symbol keys" do
hash = {
a: {
b: [
{
c: [{d: "1"}]
}
]
}
}
stringified = {
'a' => {
'b' => [
{
'c' => ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/query_mapper_spec.rb | spec/unit/util/query_mapper_spec.rb | require 'spec_helper'
describe WebMock::Util::QueryMapper do
subject { described_class }
context '#query_to_values' do
it 'should raise on invalid notation' do
query = 'a=&b=c'
expect { subject.query_to_values(query, {notation: 'foo'}) }.to raise_error(
ArgumentError,
'Invalid nota... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/headers_spec.rb | spec/unit/util/headers_spec.rb | require 'spec_helper'
describe WebMock::Util::Headers do
it "should decode_userinfo_from_header handles basic auth" do
authorization_header = "Basic dXNlcm5hbWU6c2VjcmV0"
userinfo = WebMock::Util::Headers.decode_userinfo_from_header(authorization_header)
expect(userinfo).to eq("username:secret")
end
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/version_checker_spec.rb | spec/unit/util/version_checker_spec.rb | require 'spec_helper'
module WebMock
describe VersionChecker do
it 'prints a warning if the major version is too low' do
checker = VersionChecker.new('foo', '0.7.3', '1.0.0', '1.1')
expect(Kernel).to receive(:warn).with("\e[31mYou are using foo 0.7.3. WebMock supports version >= 1.0.0, < 1.2.\e[0m")
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/uri_spec.rb | spec/unit/util/uri_spec.rb | require 'spec_helper'
URIS_WITHOUT_PATH_OR_PARAMS =
[
"www.example.com",
"www.example.com/",
"www.example.com:80",
"www.example.com:80/",
"http://www.example.com",
"http://www.example.com/",
"http://www.example.com:80",
"http://www.example.com:80/"
].sort
URIS_WITHOUT_PATH_BUT_WITH_PARAMS =
[
"www.e... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/hash_counter_spec.rb | spec/unit/util/hash_counter_spec.rb | require 'spec_helper'
describe WebMock::Util::HashCounter do
it "should return 0 for non existing key" do
expect(WebMock::Util::HashCounter.new.get(:abc)).to eq(0)
end
it "should increase the returned value on every put with the same key" do
counter = WebMock::Util::HashCounter.new
counter.put(:abc... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/util/parsers/json_spec.rb | spec/unit/util/parsers/json_spec.rb | require 'spec_helper'
describe WebMock::Util::Parsers::JSON do
describe ".parse" do
it "should parse json without parsing dates" do
expect(described_class.parse("\"a\":\"2011-01-01\"")).to eq(
{"a" => "2011-01-01"}
)
end
it "can parse json with multibyte characters" do
expect(d... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/matchers/hash_excluding_matcher_spec.rb | spec/unit/matchers/hash_excluding_matcher_spec.rb | require 'spec_helper'
module WebMock
module Matchers
describe HashExcludingMatcher do
it 'stringifies the given hash keys' do
expect(HashExcludingMatcher.new(a: 1, b: 2)).not_to eq('a' => 1, 'b' => 2)
end
it 'sorts elements in the hash' do
expect(HashExcludingMatcher.new(b: 2, ... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/matchers/hash_including_matcher_spec.rb | spec/unit/matchers/hash_including_matcher_spec.rb | 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:... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb | spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb | require 'spec_helper'
describe WebMock::HttpLibAdapterRegistry do
describe "each_adapter" do
it "should yield block over each adapter" do
class MyAdapter < WebMock::HttpLibAdapter; end
WebMock::HttpLibAdapterRegistry.instance.register(:my_lib, MyAdapter)
adapters = []
WebMock::HttpLibAdap... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb | spec/unit/http_lib_adapters/http_lib_adapter_spec.rb | require 'spec_helper'
describe WebMock::HttpLibAdapter do
describe "adapter_for" do
it "should add adapter to adapter registry" do
class MyAdapter < WebMock::HttpLibAdapter; end
expect(WebMock::HttpLibAdapterRegistry.instance).
to receive(:register).with(:my_lib, MyAdapter)
MyAdapter.ad... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock.rb | lib/webmock.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/request_body_diff.rb | lib/webmock/request_body_diff.rb | # 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?... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/cucumber.rb | lib/webmock/cucumber.rb | # frozen_string_literal: true
require 'webmock'
require 'webmock/rspec/matchers'
WebMock.enable!
World(WebMock::API, WebMock::Matchers)
After do
WebMock.reset!
end
| ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/request_execution_verifier.rb | lib/webmock/request_execution_verifier.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/deprecation.rb | lib/webmock/deprecation.rb | # frozen_string_literal: true
module WebMock
class Deprecation
class << self
def warning(message)
warn "WebMock deprecation warning: #{message}"
end
end
end
end
| ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/version.rb | lib/webmock/version.rb | # frozen_string_literal: true
module WebMock
VERSION = '3.26.1' unless defined?(::WebMock::VERSION)
end
| ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/request_signature.rb | lib/webmock/request_signature.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/errors.rb | lib/webmock/errors.rb | # 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}",
... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/test_unit.rb | lib/webmock/test_unit.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/stub_request_snippet.rb | lib/webmock/stub_request_snippet.rb | # 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 = "... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/responses_sequence.rb | lib/webmock/responses_sequence.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
bblimke/webmock | https://github.com/bblimke/webmock/blob/8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca/lib/webmock/response.rb | lib/webmock/response.rb | # 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... | ruby | MIT | 8c7cb8a968b90bf44c69fbda75cc184a5bfc89ca | 2026-01-04T15:47:36.658111Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.