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 | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/wallet_spec.rb | Ruby | mit | 237 | main | 1,544 | require 'rspec'
require_relative 'wallet'
RSpec.describe Wallet do
it 'starts at zero' do
wallet = Wallet.new
expect(wallet.cents).to eq(0)
end
xit 'can add pennies' do
wallet = Wallet.new
wallet << :penny
expect(wallet.cents).to eq(1)
3.times { wallet << :penny }
expect(wallet.ce... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/water_spec.rb | Ruby | mit | 237 | main | 375 | require 'rspec'
require_relative 'water'
RSpec.describe Water do
it 'is at room temperature' do
water = Water.new
expect(water.temperature).to eq(295) # Measured in Kelvin
end
xit 'can be heated' do
water = Water.new
water.heat
expect(water.temperature).to eq(296)
20.times { water.hea... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/baby_spec.rb | Ruby | mit | 237 | main | 262 | require 'rspec'
require_relative 'baby'
RSpec.describe Baby do
it 'is tired' do
baby = Baby.new
expect(baby.tired?).to be true
end
it 'is not tired after a nap' do
baby = Baby.new
baby.nap
expect(baby.tired?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/teeth_spec.rb | Ruby | mit | 237 | main | 291 | require 'rspec'
require_relative 'teeth'
RSpec.describe Teeth do
it 'isnt clean by default' do
teeth = Teeth.new
expect(teeth.clean?).to be false
end
xit 'are clean after brushing them' do
teeth = Teeth.new
teeth.brush
expect(teeth.clean?).to be true
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/santa_spec.rb | Ruby | mit | 237 | main | 442 | require 'rspec'
require_relative 'santa'
RSpec.describe Santa do
it 'fits down the chimney' do
santa = Santa.new
expect(santa.fits?).to be true
end
xit 'does not fit down the chimney if he eats too many cookies' do
santa = Santa.new
santa.eats_cookies
expect(santa.fits?).to be true
sa... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/student_spec.rb | Ruby | mit | 237 | main | 1,143 | require 'rspec'
require_relative 'student'
RSpec.describe Student do
it 'has a mediocre grade' do
student = Student.new
expect(student.grade).to eq('C')
end
xit 'can improve its grade' do
student = Student.new
student.study
expect(student.grade).to eq('B')
student.study
expect(stu... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/tire_spec.rb | Ruby | mit | 237 | main | 276 | require 'rspec'
require_relative 'tire'
RSpec.describe Tire do
it 'does not start out flat' do
tire = Tire.new
expect(tire.flat?).to be false
end
xit 'can have a blowout' do
tire = Tire.new
tire.blow_out
expect(tire.flat?).to be true
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/apple_spec.rb | Ruby | mit | 237 | main | 391 | require 'rspec'
require_relative 'apple'
RSpec.describe Apple do
it 'is not ripe when created' do
apple = Apple.new
expect(apple.ripe?).to be false
end
it 'is not ripe until it is three weeks old' do
apple = Apple.new
2.times { apple.wait_a_week }
expect(apple.ripe?).to be false
1.tim... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/money_spec.rb | Ruby | mit | 237 | main | 326 | require 'rspec'
require_relative 'money'
RSpec.describe Money do
it 'starts at zero' do
money = Money.new
expect(money.amount).to eq(0)
end
xit 'can earn money' do
money = Money.new
money.earn(20)
expect(money.amount).to eq(20)
money.earn(13)
expect(money.amount).to eq(33)
end... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/milk_bottle_spec.rb | Ruby | mit | 237 | main | 294 | require 'rspec'
require_relative 'milk_bottle'
RSpec.describe MilkBottle do
it 'starts off as full' do
bottle = MilkBottle.new
expect(bottle.full?).to be true
end
xit 'spills milk' do
bottle = MilkBottle.new
bottle.spill
expect(bottle.full?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/person_spec.rb | Ruby | mit | 237 | main | 360 | require 'rspec'
require_relative 'person'
RSpec.describe Person do
it 'is zero years old when born' do
person = Person.new
expect(person.age).to eq(0)
end
xit 'gets older' do
person = Person.new
person.happy_birthday
expect(person.age).to eq(1)
32.times { person.happy_birthday }
... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/beers_spec.rb | Ruby | mit | 237 | main | 671 | require 'rspec'
require_relative 'beers'
RSpec.describe Beers do
it 'starts at 99' do
beers = Beers.new
expect(beers.inventory).to eq(99)
end
it 'decreases inventory' do
beers = Beers.new
beers.take_one_down_and_pass_it_around
expect(beers.inventory).to eq(98)
53.times { beers.take_on... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/dog_spec.rb | Ruby | mit | 237 | main | 236 | require 'rspec'
require_relative 'dog'
RSpec.describe Dog do
it 'is hungry' do
dog = Dog.new
expect(dog.hungry?).to be true
end
xit 'eats' do
dog = Dog.new
dog.eat
expect(dog.hungry?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/appointments_spec.rb | Ruby | mit | 237 | main | 618 | require 'rspec'
require_relative 'appointments'
RSpec.describe Appointments do
it 'has no appointments' do
slots = Appointments.new
expect(slots.earliest).to be_nil
end
it 'has an earliest one' do
slots = Appointments.new
t1 = Time.new(2014, 3, 14, 4, 30)
slots.at(t1)
expect(slots.ear... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/catalog_spec.rb | Ruby | mit | 237 | main | 593 | require 'rspec'
require_relative 'product'
require_relative 'catalog'
RSpec.describe Catalog do
it 'starts with no products' do
catalog = Catalog.new
expect(catalog.cheapest).to be_nil
end
it 'has a cheapest of one' do
catalog = Catalog.new
catalog << Product.new('scissors', 8)
expect(catalo... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/adult_spec.rb | Ruby | mit | 237 | main | 448 | require 'rspec'
require_relative 'adult'
RSpec.describe Adult do
it 'does not get drunk too easily' do
adult = Adult.new
adult.consume_an_alcoholic_beverage
expect(adult.sober?).to be true
adult.consume_an_alcoholic_beverage
expect(adult.sober?).to be true
adult.consume_an_alcoholic_bevera... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/cupcakes_spec.rb | Ruby | mit | 237 | main | 672 | require 'rspec'
require_relative 'cupcake'
require_relative 'cupcakes'
RSpec.describe Cupcakes do
it 'has no sweetest when there are no cupcakes' do
cupcakes = Cupcakes.new
expect(cupcakes.sweetest).to be_nil
end
it 'has a sweetest with one cupcake' do
cupcakes = Cupcakes.new
cupcakes << Cupcake... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/clock_spec.rb | Ruby | mit | 237 | main | 451 | require 'rspec'
require_relative 'clock'
RSpec.describe Clock do
it 'starts at 6' do
clock = Clock.new
expect(clock.time).to eq(6)
end
it 'measures the passage of time' do
clock = Clock.new
clock.wait
expect(clock.time).to eq(7)
3.times { clock.wait }
expect(clock.time).to eq(10)
... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/floor_spec.rb | Ruby | mit | 237 | main | 287 | require 'rspec'
require_relative 'floor'
RSpec.describe Floor do
it 'is dirty by default' do
floor = Floor.new
expect(floor.dirty?).to be true
end
xit 'is clean after it is washed' do
floor = Floor.new
floor.wash
expect(floor.dirty?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/music_spec.rb | Ruby | mit | 237 | main | 288 | require 'rspec'
require_relative 'music'
RSpec.describe Music do
it 'is not loud' do
music = Music.new
expect(music.loud?).to be false
end
xit 'is loud after turning up the volume' do
music = Music.new
music.turn_up
expect(music.loud?).to be true
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/clearance_spec.rb | Ruby | mit | 237 | main | 784 | require 'rspec'
require_relative 'clearance'
require_relative 'item'
RSpec.describe Clearance do
it 'has no items on clearance' do
clearance = Clearance.new
expect(clearance.best_deal).to be_nil
end
it 'has highest percent off one item' do
clearance = Clearance.new
# the discount here is a price... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/door_spec.rb | Ruby | mit | 237 | main | 261 | require 'rspec'
require_relative 'door'
RSpec.describe Door do
it 'is locked' do
door = Door.new
expect(door.locked?).to be true
end
xit 'unlocks the door' do
door = Door.new
door.unlock
expect(door.locked?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/leather_chair_spec.rb | Ruby | mit | 237 | main | 334 | require 'rspec'
require_relative 'leather_chair'
RSpec.describe LeatherChair do
it 'is not faded' do
chair = LeatherChair.new
expect(chair.faded?).to be false
end
xit 'becomes faded when exposed to sunlight' do
chair = LeatherChair.new
chair.expose_to_sunlight
expect(chair.faded?).to be t... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/kid_spec.rb | Ruby | mit | 237 | main | 685 | require 'rspec'
require_relative 'kid'
RSpec.describe Kid do
it 'has not eaten sugar' do
kid = Kid.new
expect(kid.grams_of_sugar_eaten).to eq(0)
end
xit 'gets 5 grams from eating candy' do
kid = Kid.new
kid.eat_candy
expect(kid.grams_of_sugar_eaten).to eq(5)
5.times { kid.eat_candy }... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/pills_spec.rb | Ruby | mit | 237 | main | 276 | require 'rspec'
require_relative 'pills'
RSpec.describe Pills do
it 'bottle starts with 60 pills' do
pills = Pills.new
expect(pills.count).to eq(60)
end
xit 'it pops a pill' do
pills = Pills.new
pills.pop
expect(pills.count).to eq(59)
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/light_spec.rb | Ruby | mit | 237 | main | 259 | require 'rspec'
require_relative 'light'
RSpec.describe Light do
it 'is off' do
light = Light.new
expect(light.on?).to be false
end
it 'can be turned on' do
light = Light.new
light.turn_on
expect(light.on?).to be true
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/yak_spec.rb | Ruby | mit | 237 | main | 245 | require 'rspec'
require_relative 'yak'
RSpec.describe Yak do
it 'is hairy' do
yak = Yak.new
expect(yak.hairy?).to be true
end
xit 'can be shaved' do
yak = Yak.new
yak.shave
expect(yak.hairy?).to be false
end
end |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/children_spec.rb | Ruby | mit | 237 | main | 580 | require 'rspec'
require_relative 'child'
require_relative 'children'
RSpec.describe Children do
it 'has no eldest' do
children = Children.new
expect(children.eldest).to be_nil
end
it 'has one eldest' do
children = Children.new
children << Child.new('Sarah', 5)
expect(children.eldest.name).... |
github | turingschool-examples/ruby-exercises | https://github.com/turingschool-examples/ruby-exercises | command-query/exercises/roll_call_spec.rb | Ruby | mit | 237 | main | 523 | require 'rspec'
require_relative 'roll_call'
RSpec.describe RollCall do
it 'has no names' do
roll_call = RollCall.new
expect(roll_call.longest_name).to be nil
end
xit 'has a longest of one' do
roll_call = RollCall.new
roll_call << 'Oda'
expect(roll_call.longest_name).to eq('Oda')
end
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | Rakefile | Ruby | apache-2.0 | 237 | master | 2,786 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rdoc/task"
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs = %w[lib test]
t.pattern = "test/**/*_test.rb"
t.warning = false
end
desc "integration tests for third party modules"
Rake::TestTask.new(:integration_tests) do |t|
t.libs = %... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | httpx.gemspec | Ruby | apache-2.0 | 237 | master | 1,292 | # frozen_string_literal: true
require_relative "lib/httpx/version"
Gem::Specification.new do |gem|
gem.name = "httpx"
gem.version = HTTPX::VERSION
gem.platform = Gem::Platform::RUBY
gem.authors = ["Tiago Cardoso"]
gem.email = ["cardoso_tiago@hotmail.com"]
gem.description... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | Gemfile | Ruby | apache-2.0 | 237 | master | 1,747 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "rake", "~> 13"
gem "rdoc" if RUBY_VERSION >= "4.0.0"
group :test do
if RUBY_VERSION >= "3.2.0"
gem "datadog", "~> 2.0", platform: :mri
else
gem "ddtrace"
end
gem "http-form_data", ">= 2.0.0"
gem "minitest"
gem "minitest-pro... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/headers_test.rb | Ruby | apache-2.0 | 237 | master | 2,000 | # frozen_string_literal: true
require_relative "test_helper"
class HeadersTest < Minitest::Test
include HTTPX
def test_headers_clone
h1 = Headers.new
h2 = h1.clone
h2.instance_variables.each do |ivar|
assert !h1.instance_variable_get(ivar).nil?
assert !h1.instance_variable_get(ivar).equal... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/altsvc_test.rb | Ruby | apache-2.0 | 237 | master | 2,702 | # frozen_string_literal: true
require_relative "test_helper"
class AltSvcTest < Minitest::Test
include HTTPX
def test_altsvc_cache
assert AltSvc.cached_altsvc("http://www.example-altsvc-cache.com").empty?
AltSvc.cached_altsvc_set("http://www.example-altsvc-cache.com", { "origin" => "http://alt.example-al... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/aws_sigv4_test.rb | Ruby | apache-2.0 | 237 | master | 5,366 | # frozen_string_literal: true
require_relative "test_helper"
class HTTPXAwsSigv4Test < Minitest::Test
include ResponseHelpers
def test_plugin_aws_sigv4_canonical_query
r1 = sigv4_session.build_request("GET", "http://domain.com?b=c&a=b")
assert r1.canonical_query == "a=b&b=c"
r2 = sigv4_session.build_... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/content_digest_test.rb | Ruby | apache-2.0 | 237 | master | 3,431 | # frozen_string_literal: true
require_relative "test_helper"
class HTTPXContentDigestTest < Minitest::Test
def test_plugin_content_digest_default_request
request = HTTPX.plugin(:content_digest)
.build_request(
"POST",
"http://domain.com",
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/response_cache_file_store_test.rb | Ruby | apache-2.0 | 237 | master | 937 | # frozen_string_literal: true
require_relative "test_helper"
require "httpx/plugins/response_cache/file_store"
class ResponseCacheFileStoreTest < Minitest::Test
include ResponseCacheStoreTests
def test_internal_store_set
request = make_request("GET", "http://store-set/")
assert !File.exist?(store.dir.joi... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/response_test.rb | Ruby | apache-2.0 | 237 | master | 12,139 | # frozen_string_literal: true
require_relative "test_helper"
class ResponseTest < Minitest::Test
include HTTPX
include ResponseHelpers
if RUBY_VERSION >= "2.7.0"
begin
eval("case 1; in 1 ;then true; end") # rubocop:disable Style/EvalWithLocation
require_relative "extensions/response_pattern_mat... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/http_test.rb | Ruby | apache-2.0 | 237 | master | 6,067 | # frozen_string_literal: true
require_relative "test_helper"
class HTTPTest < Minitest::Test
include HTTPHelpers
include Requests
include Head
include Get
include Compression
include ChunkedGet
include WithBody
include WithChunkedBody
include Multipart
include Headers
include ResponseBody
incl... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/pool_test.rb | Ruby | apache-2.0 | 237 | master | 4,576 | # frozen_string_literal: true
require_relative "test_helper"
class PoolTest < Minitest::Test
include HTTPHelpers
include HTTPX
using URIExtensions
class ExtPool < Pool
attr_reader :connections, :origin_counters, :connections_counter
end
def test_pool_max_connections
responses = []
q = Queue... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/https_test.rb | Ruby | apache-2.0 | 237 | master | 9,404 | # frozen_string_literal: true
require_relative "test_helper"
class HTTPSTest < Minitest::Test
include HTTPHelpers
include Requests
include Get
include Compression
include Head
include WithBody
include Multipart
include Headers
include ResponseBody
include IO
include Callbacks
include Errors if... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/chainable_test.rb | Ruby | apache-2.0 | 237 | master | 682 | # frozen_string_literal: true
require_relative "test_helper"
class ChainableTest < Minitest::Test
def test_respond_to_mapping_to_options
assert !HTTPX.respond_to?(:with_potatoes)
assert HTTPX.respond_to?(:with_ssl)
assert HTTPX.respond_to?(:with_headers)
assert !HTTPX.respond_to?(:with_cookies)
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/error_response_test.rb | Ruby | apache-2.0 | 237 | master | 1,606 | # frozen_string_literal: true
require_relative "test_helper"
class ErrorResponseTest < Minitest::Test
include HTTPX
def test_error_response_finished?
r1 = make_error_response(RuntimeError.new("wow"))
assert r1.finished?
end
def test_error_response_error
error = RuntimeError.new("wow")
r1 = m... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/test_resolver_cache_memory_test.rb | Ruby | apache-2.0 | 237 | master | 351 | # frozen_string_literal: true
require_relative "test_helper"
class ResolverCacheMemoryTest < Minitest::Test
include HTTPX
include ResolverCacheHelpers
private
def cache
@cache ||= Resolver::Cache::Memory.new.tap do |cache|
cache.singleton_class.class_eval do
attr_reader :lookups, :hostnam... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/request_test.rb | Ruby | apache-2.0 | 237 | master | 3,914 | # frozen_string_literal: true
require_relative "test_helper"
class RequestTest < Minitest::Test
include HTTPX
def test_request_unsupported_body
ex = assert_raises(HTTPX::Error) { make_request("POST", "http://example.com/", body: Object.new) }
assert ex.message.include?("cannot determine size of body")
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/response_cache_store_test.rb | Ruby | apache-2.0 | 237 | master | 1,261 | # frozen_string_literal: true
require_relative "test_helper"
require "httpx/plugins/response_cache/store"
class ResponseCacheStoreTest < Minitest::Test
include ResponseCacheStoreTests
def test_internal_store_set
internal_store = store.instance_variable_get(:@store)
request = make_request("GET", "http://... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/session_test.rb | Ruby | apache-2.0 | 237 | master | 13,051 | # frozen_string_literal: true
require_relative "test_helper"
class SessionTest < Minitest::Test
include HTTPHelpers
include ConnectTimeoutHelpers
def test_session_block
yielded = nil
HTTPX::Session.new do |cli|
yielded = cli
end
assert yielded.is_a?(HTTPX::Session), "session should have b... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/test_helper.rb | Ruby | apache-2.0 | 237 | master | 1,292 | # frozen_string_literal: true
GC.auto_compact = true if !defined?(MimeMagic) && GC.respond_to?(:auto_compact=) # https://github.com/mimemagicrb/mimemagic/issues/166
if ENV.key?("CI")
require "simplecov"
coverage_key = ENV.fetch("COVERAGE_KEY", "#{RUBY_ENGINE}-#{RUBY_VERSION}")
SimpleCov.command_name coverage_ke... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/proxy_test.rb | Ruby | apache-2.0 | 237 | master | 1,483 | # frozen_string_literal: true
require_relative "test_helper"
require "httpx/plugins/proxy"
class ProxyTest < Minitest::Test
include HTTPHelpers
include HTTPX
def test_parameters_equality
params = parameters(username: "user", password: "pass")
assert params == parameters(username: "user", password: "pas... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/cookie_jar_test.rb | Ruby | apache-2.0 | 237 | master | 8,163 | # frozen_string_literal: true
require_relative "test_helper"
class CookieJarTest < Minitest::Test
def test_plugin_cookies_make_jar
session = HTTPX.plugin(:cookies)
assert session.make_jar.is_a?(HTTPX::Plugins::Cookies::Jar)
cookie = HTTPX::Plugins::Cookies::Cookie.new("a", "b")
assert session.make_j... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/options_test.rb | Ruby | apache-2.0 | 237 | master | 8,690 | # frozen_string_literal: true
require_relative "test_helper"
class OptionsTest < Minitest::Test
include HTTPX
def test_options_unknown
ex = assert_raises(Error) { Options.new(foo: "bar") }
assert ex.message == "unknown option: foo", ex.message
end
def test_options_no_method_error_during_validation
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/parser_test.rb | Ruby | apache-2.0 | 237 | master | 1,813 | # frozen_string_literal: true
require_relative "test_helper"
class HTTP1ParserTest < Minitest::Test
class RequestObserver
include HTTPX
attr_reader :response, :parser
def initialize
@parser = Parser::HTTP1.new(self)
end
def on_headers(h)
headers = Headers.new(h)
@response = ... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/io/tcp_test.rb | Ruby | apache-2.0 | 237 | master | 2,315 | # frozen_string_literal: true
require "tempfile"
require_relative "../test_helper"
class TCPTest < Minitest::Test
include HTTPX
def test_tcp_ip_index_rebalance_on_new_addresses
origin = URI("http://example.com")
options = Options.new
tcp_class = Class.new(TCP) do
attr_accessor :ip_index
en... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/io/unix_test.rb | Ruby | apache-2.0 | 237 | master | 2,614 | # frozen_string_literal: true
require "tempfile"
require_relative "../test_helper"
class UnixTest < Minitest::Test
include HTTPHelpers
using HTTPX::URIExtensions
unless RUBY_ENGINE == "jruby"
def test_unix_session
on_unix_server(__method__) do |path|
HTTPX.with(transport: "unix", addresses: ... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/adapters/faraday_test.rb | Ruby | apache-2.0 | 237 | master | 8,502 | # frozen_string_literal: true
require_relative "../test_helper"
require "faraday"
require "faraday/multipart"
require "forwardable"
require "httpx/adapters/faraday"
require_relative "../support/http_helpers"
class FaradayTest < Minitest::Test
extend Forwardable
include HTTPHelpers
include FaradayHelpers
inclu... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/response_cache_store_tests.rb | Ruby | apache-2.0 | 237 | master | 7,440 | # frozen_string_literal: true
module ResponseCacheStoreTests
include HTTPX
def test_store_cache
request = make_request("GET", "http://store-cache/")
response = cached_response(request)
cached_response = store.get(request)
assert cached_response.headers == response.headers
assert cached_respon... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/session_with_mock_response.rb | Ruby | apache-2.0 | 237 | master | 827 | # frozen_string_literal: true
module SessionWithMockResponse
module OptionsMethods
def option_mock_status(status)
status
end
def option_mock_headers(headers)
headers
end
end
module ResponseMethods
attr_writer :status
end
module InstanceMethods
def initialize(*)
su... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/http_helpers.rb | Ruby | apache-2.0 | 237 | master | 709 | # frozen_string_literal: true
require_relative "assertion_helpers"
module HTTPHelpers
include ResponseHelpers
private
def build_uri(suffix = "/", uri_origin = origin)
"#{uri_origin}#{suffix || "/"}"
end
def json_body(response)
raise response.error if response.is_a?(HTTPX::ErrorResponse)
JSON... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/grpc_helpers.rb | Ruby | apache-2.0 | 237 | master | 5,509 | # frozen_string_literal: true
begin
require "grpc"
require "logging"
# A test message
class EchoMsg
attr_reader :msg
def initialize(msg: "")
@msg = msg
end
def self.marshal(o)
o.msg
end
def self.unmarshal(msg)
EchoMsg.new(msg: msg)
end
end
# a test service... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/resolver_cache_helpers.rb | Ruby | apache-2.0 | 237 | master | 2,672 | # frozen_string_literal: true
module ResolverCacheHelpers
def test_cache_api
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
assert_ips nil, cache.get("test.com")
dns_entry = { "data" => "::2", "TTL" => now + 2, "name" => "test.com" }
cache.set("test.com", Socket::AF_INET6, [dns_entry])
ass... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/thread_backtraces.rb | Ruby | apache-2.0 | 237 | master | 254 | # frozen_string_literal: true
Signal.trap("USR2") do
warn "starting..."
Thread.list.each do |thread|
warn "Thread TID-#{(thread.object_id ^ Process.pid).to_s(36)} #{thread.name}"
warn thread.backtrace || "<no backtrace available>"
end
end |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/minitest_extensions.rb | Ruby | apache-2.0 | 237 | master | 1,766 | # frozen_string_literal: true
module MinitestExtensions
module TimeoutForTest
# our own subclass so we never confused different timeouts
class TestTimeout < Timeout::Error
end
def run(*)
::Timeout.timeout(60 * 5, TestTimeout) { super }
end
end
module FirstFailedTestInThread
def se... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/proxy_retry.rb | Ruby | apache-2.0 | 237 | master | 352 | # frozen_string_literal: true
module ProxyRetry
def run(*)
return super unless name.include?("_proxy")
result = nil
3.times.each do |_i|
result = super
break if result.passed?
self.failures = []
self.assertions = 0
end
result
end
end
Minitest::Test.prepend(ProxyRetry)... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/test_fiber_scheduler.rb | Ruby | apache-2.0 | 237 | master | 6,385 | # frozen_string_literal: true
module FiberSchedulerTestHelpers
class TestFiberScheduler
def initialize(fiber = Fiber.current)
@fiber = fiber
@readable = Hash.new { |hs, k| hs[k] = [] }
@writable = Hash.new { |hs, k| hs[k] = [] }
@waiting = {}
@lock = Thread::Mutex.new
@blocki... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/websocket_test_plugin.rb | Ruby | apache-2.0 | 237 | master | 3,685 | # frozen_string_literal: true
require "forwardable"
require "websocket/driver"
# have to roll our own, as the default client bundles its own
# HTTP client handshake logic
class WSDriver < WebSocket::Driver::Hybi
include WebSocket
def initialize(*, opts)
h = opts.delete(:headers)
super
@headers = h
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/assertion_helpers.rb | Ruby | apache-2.0 | 237 | master | 5,389 | # frozen_string_literal: true
module ResponseHelpers
private
if RUBY_ENGINE == "jruby" || RUBY_ENGINE == "truffleruby"
def can_run_ractor_tests?
false
end
else
def can_run_ractor_tests?
defined?(Ractor) && Ractor.method_defined?(:value)
end
end
def verify_status(response, expect... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/session_with_pool.rb | Ruby | apache-2.0 | 237 | master | 1,929 | # frozen_string_literal: true
module SessionWithPool
module PoolMethods
attr_reader :resolvers, :connections, :connections_counter
end
module InstanceMethods
attr_reader :pool, :connections_exausted, :connection_count, :ping_count, :pong_count, :resolvers, :connections
def initialize(*)
@conn... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/resolver_helpers.rb | Ruby | apache-2.0 | 237 | master | 5,630 | # frozen_string_literal: true
require "ipaddr"
module ResolverApiHelpers
include HTTPX
def test_resolver_api
assert resolver.respond_to?(:<<)
assert resolver.respond_to?(:closed?)
assert resolver.respond_to?(:empty?)
end
def test_append_localhost
ips = [IPAddr.new("127.0.0.1"), IPAddr.new(":... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/request_inspector.rb | Ruby | apache-2.0 | 237 | master | 851 | # frozen_string_literal: true
module RequestInspector
module InstanceMethods
attr_reader :calls, :total_requests, :total_responses
def initialize(*args)
super
# we're comparing against max-retries + 1, because the calls increment will happen
# also in the last call, where the request is no... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/proxy_response_detector.rb | Ruby | apache-2.0 | 237 | master | 421 | # frozen_string_literal: true
module ProxyResponseDetector
module RequestMethods
attr_writer :proxied
def proxied?
@proxied
end
end
module ResponseMethods
def proxied?
@request.proxied?
end
end
module ConnectionMethods
def send(request)
return super unless @option... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/session_with_frame_delay.rb | Ruby | apache-2.0 | 237 | master | 305 | # frozen_string_literal: true
#
# This module is used only to test frame errors for HTTP/2. It targets the settings timeout of
# nghttp2.org, which is known as being 10 seconnds.
#
module SessionWithFrameDelay
module ConnectionMethods
def send_pending
sleep(11)
super
end
end
end |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/proxy_helper.rb | Ruby | apache-2.0 | 237 | master | 2,718 | # frozen_string_literal: true
require "uri"
require "net/http"
require "oga"
module ProxyHelper
private
def socks4_proxy
Array(ENV["HTTPX_SOCKS4_PROXY"] || begin
socks_proxies_list.select { |_, _, version, https| version == "Socks4" && https }
.map { |ip, port, _, _| "socks4://#... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/connect_timeout_helpers.rb | Ruby | apache-2.0 | 237 | master | 668 | # frozen_string_literal: true
module ConnectTimeoutHelpers
# 9090 drops SYN packets for connect timeout tests, make sure there's a server binding there.
CONNECT_TIMEOUT_PORT_MUTEX = Thread::Mutex.new
CONNECT_TIMEOUT_PORT = ENV.fetch("CONNECT_TIMEOUT_PORT", 9090).to_i
def start_connect_timeout_tcp_server
C... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/faraday_helpers.rb | Ruby | apache-2.0 | 237 | master | 1,380 | # frozen_string_literal: true
module FaradayHelpers
private
# extra options to pass when building the adapter
def adapter_options
[]
end
def faraday_connection(options = {}, &optional_connection_config_blk)
return @faraday_connection if defined?(@faraday_connection)
builder_block = proc do |b|... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/coalescing.rb | Ruby | apache-2.0 | 237 | master | 2,975 | # frozen_string_literal: true
module Requests
module Coalescing
def test_connection_coalescing
coalesced_origin = "https://#{ENV["HTTPBIN_COALESCING_HOST"]}"
HTTPX.plugin(SessionWithPool).wrap do |http|
response1 = http.get(origin)
verify_status(response1, 200)
response2 = htt... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/chunked_get.rb | Ruby | apache-2.0 | 237 | master | 1,007 | # frozen_string_literal: true
module Requests
module ChunkedGet
def test_http_chunked_get
uri = build_uri("/stream-bytes/30?chunk_size=5")
response = HTTPX.get(uri)
verify_status(response, 200)
verify_header(response.headers, "transfer-encoding", "chunked")
verify_body_length(respon... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/head.rb | Ruby | apache-2.0 | 237 | master | 238 | # frozen_string_literal: true
module Requests
module Head
def test_http_head
uri = build_uri("/get")
response = HTTPX.head(uri)
verify_status(response, 200)
verify_body_length(response, 0)
end
end
end |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/response_body.rb | Ruby | apache-2.0 | 237 | master | 2,021 | # frozen_string_literal: true
module Requests
module ResponseBody
def test_http_response_copy_to_file
file = Tempfile.new(%w[cat .jpeg])
uri = build_uri("/image")
response = HTTPX.get(uri, headers: { "accept" => "image/jpeg" })
verify_status(response, 200)
verify_header(response.hea... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/compression.rb | Ruby | apache-2.0 | 237 | master | 4,808 | # frozen_string_literal: true
module Requests
module Compression
def test_compression_accepts
url = "https://github.com"
response = HTTPX.get(url)
skip if response == 429
verify_status(response, 200)
assert response.body.encodings == %w[gzip], "response should be sent with gzip enc... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/callbacks.rb | Ruby | apache-2.0 | 237 | master | 4,219 | # frozen_string_literal: true
require "resolv"
require "httpx/plugins/callbacks"
module Requests
using HTTPX::URIExtensions
module Callbacks
def test_callbacks_connection_opened
uri = URI(build_uri("/get"))
origin = ip = nil
opened = 0
response = HTTPX.plugin(SessionWithPool).plugin(:... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/headers.rb | Ruby | apache-2.0 | 237 | master | 696 | # frozen_string_literal: true
module Requests
module Headers
def test_http_headers
uri = build_uri("/headers")
response = HTTPX.get(uri)
body = json_body(response)
assert body.key?("headers"), "no headers"
assert body["headers"]["Accept"] == "*/*", "unexpected accept"
respons... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/multipart.rb | Ruby | apache-2.0 | 237 | master | 11,601 | # frozen_string_literal: true
require "http/form_data"
module Requests
module Multipart
%w[post put patch delete].each do |meth|
define_method :"test_multipart_urlencoded_#{meth}" do
uri = build_uri("/#{meth}")
response = HTTPX.send(meth, uri, form: { "foo" => "bar" })
verify_statu... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/resolvers.rb | Ruby | apache-2.0 | 237 | master | 21,003 | # frozen_string_literal: true
module Requests
module Resolvers
using HTTPX::URIExtensions
ResolverTimeoutPlugin = Module.new do
self::ResolverNativeMethods = Module.new do
def dread
@io.read(16_384, "".b)
super
end
end
self::ResolverHTTPSMethods = Modu... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/io.rb | Ruby | apache-2.0 | 237 | master | 1,165 | # frozen_string_literal: true
module Requests
module IO
using HTTPX::URIExtensions
def test_http_io
io = origin_io
uri = build_uri("/get")
response = HTTPX.get(uri, io: io)
verify_status(response, 200)
verify_body_length(response)
assert !io.closed?, "io should have been ... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/with_body.rb | Ruby | apache-2.0 | 237 | master | 9,608 | # frozen_string_literal: true
module Requests
module WithBody
%w[post put patch delete].each do |meth|
define_method :"test_#{meth}_query_params" do
uri = build_uri("/#{meth}")
response = HTTPX.send(meth, uri, params: { "q" => "this is a test" })
verify_status(response, 200)
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/with_chunked_body.rb | Ruby | apache-2.0 | 237 | master | 1,877 | # frozen_string_literal: true
module Requests
module WithChunkedBody
%w[post put patch delete].each do |meth|
define_method :"test_#{meth}_chunked_body_params" do
uri = build_uri("/#{meth}")
response = HTTPX.with_headers("transfer-encoding" => "chunked")
.send(meth, ... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/errors.rb | Ruby | apache-2.0 | 237 | master | 5,823 | # frozen_string_literal: true
module Requests
module Errors
def test_errors_invalid_uri
exc = assert_raises { HTTPX.get("/get") }
assert exc.message.include?("invalid URI: /get")
exc = assert_raises { HTTPX.get("http:/smth/get") }
assert exc.message.include?("invalid URI: http:/smth/get")... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/altsvc.rb | Ruby | apache-2.0 | 237 | master | 716 | # frozen_string_literal: true
module Requests
module AltSvc
def test_altsvc_get
altsvc_host = ENV["HTTPBIN_ALTSVC_HOST"]
altsvc_origin = origin(altsvc_host)
HTTPX.plugin(SessionWithPool).wrap do |http|
altsvc_uri = build_uri("/get", altsvc_origin)
res1, res2 = http.get(altsvc_u... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/get.rb | Ruby | apache-2.0 | 237 | master | 3,945 | # frozen_string_literal: true
require "time"
module Requests
using HTTPX::URIExtensions
module Get
def test_http_get
uri = build_uri("/get")
response = HTTPX.get(uri)
verify_status(response, 200)
verify_body_length(response)
return unless can_run_ractor_tests?
response2 ... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/tracing.rb | Ruby | apache-2.0 | 237 | master | 2,674 | # frozen_string_literal: true
module Requests
module Plugins
module Tracing
def test_plugin_tracing_request_callbacks
http = HTTPX.plugin(:tracing, tracer: test_tracer)
uri = build_uri("/get")
request = http.build_request("GET", uri)
response = http.request(request)
... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/circuit_breaker.rb | Ruby | apache-2.0 | 237 | master | 5,656 | # frozen_string_literal: true
module Requests
module Plugins
module CircuitBreaker
using HTTPX::URIExtensions
def test_plugin_circuit_breaker_lifecycles
return unless origin.start_with?("http://")
unknown_uri = "http://www.qwwqjqwdjqiwdj.com"
session = HTTPX.plugin(:circuit... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/persistent.rb | Ruby | apache-2.0 | 237 | master | 12,851 | # frozen_string_literal: true
module Requests
module Plugins
module Persistent
def test_persistent
uri = build_uri("/get")
non_persistent_session = HTTPX.plugin(SessionWithPool)
response = non_persistent_session.get(uri)
verify_status(response, 200)
assert non_persi... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/rate_limiter.rb | Ruby | apache-2.0 | 237 | master | 2,668 | # frozen_string_literal: true
module Requests
module Plugins
module RateLimiter
def test_plugin_rate_limiter_429
rate_limiter_session = HTTPX.plugin(RequestInspector)
.plugin(SessionWithMockResponse, mock_status: 429)
.plugin(:... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/response_cache.rb | Ruby | apache-2.0 | 237 | master | 3,820 | # frozen_string_literal: true
require "securerandom"
module Requests
module Plugins
module ResponseCache
def test_plugin_response_cache_options
cache_client = HTTPX.plugin(:response_cache, response_cache_store: :store)
assert cache_client.class.default_options.response_cache_store.is_a?(HT... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/oauth.rb | Ruby | apache-2.0 | 237 | master | 9,910 | # frozen_string_literal: true
module Requests
module Plugins
module OAuth
def test_plugin_oauth_oauth_session
with_oauth_metadata do |server|
# from options
oauth_session = HTTPX.plugin(:oauth).with_oauth_options(
issuer: server.origin,
client_id: "CLIENT... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/stream_bidi.rb | Ruby | apache-2.0 | 237 | master | 9,977 | # frozen_string_literal: true
module Requests
module Plugins
module StreamBidi
def test_plugin_stream_bidi
uri = build_uri("/get")
session = HTTPX.plugin(:stream_bidi)
response = session.get(uri)
verify_status(response, 200)
end
def test_plugin_stream_bidi_does_... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/query.rb | Ruby | apache-2.0 | 237 | master | 1,132 | # frozen_string_literal: true
module Requests
module Plugins
module Query
QUERY_FAILED_STATUS_CODE = ENV.key?("CI") ? 501 : 405
def test_plugin_query
session = HTTPX.plugin(:query)
assert session.respond_to?(:query)
uri = build_uri("/get")
response = session.query(u... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/grpc.rb | Ruby | apache-2.0 | 237 | master | 7,172 | # frozen_string_literal: true
module Requests
module Plugins
module GRPC
include GRPCHelpers
def test_plugin_grpc_stub_rpc_defines_snake_case_methods
server_port = run_rpc(TestService)
grpc = grpc_plugin
# build service
stub = grpc.build_stub("localhost:#{server_port... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/proxy.rb | Ruby | apache-2.0 | 237 | master | 11,967 | # frozen_string_literal: true
require "resolv"
module Requests
module Plugins
module Proxy
include ProxyHelper
using HTTPX::URIExtensions
RESOLVER = Resolv::DNS.new
def test_plugin_no_proxy_defined
http = HTTPX.plugin(:proxy)
uri = build_uri("/get")
res = http.... |
github | HoneyryderChuck/httpx | https://github.com/HoneyryderChuck/httpx | test/support/requests/plugins/ssrf_filter.rb | Ruby | apache-2.0 | 237 | master | 1,951 | # frozen_string_literal: true
module Requests
module Plugins
module SsrfFilter
def test_plugin_ssrf_filter_allows
uri = "#{scheme}nghttp2.org"
session = HTTPX.plugin(:ssrf_filter)
response = session.get(uri)
verify_status(response, 200)
end
def test_plugin_ssrf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.