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
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/test/cached/reference/has_many_test.rb
test/cached/reference/has_many_test.rb
# frozen_string_literal: true require "test_helper" module IdentityCache module Cached module Reference class HasManyTest < IdentityCache::TestCase def setup super @reflection = reflect(AssociatedRecord, :deeply_associated_records) @has_many = HasMany.new(:deeply_asso...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/test/cached/reference/has_one_test.rb
test/cached/reference/has_one_test.rb
# frozen_string_literal: true require "test_helper" module IdentityCache module Cached module Reference class HasOneTest < IdentityCache::TestCase def setup super @reflection = reflect(AssociatedRecord, :deeply_associated) @has_one = HasOne.new(:deeply_associated, ref...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/performance/cache_runner.rb
performance/cache_runner.rb
# frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) require "active_record" require "active_support/core_ext" require "active_support/cache" require "identity_cache" require "memcached_store" require "active_support/cache/memcached_store" require File.dirname(__FILE__) + "/../tes...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/performance/cpu.rb
performance/cpu.rb
# frozen_string_literal: true require "rubygems" require "benchmark" require_relative "cache_runner" RUNS = 400 class ARCreator include ActiveRecordObjects end def run(obj) obj.prepare GC.start Benchmark.measure do obj.run end ensure obj.cleanup end def benchmark(runners, label_width = 0) Identi...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/performance/externals.rb
performance/externals.rb
# frozen_string_literal: true require "rubygems" require "benchmark" require "ruby-prof" require_relative "cache_runner" RUNS = 1000 RubyProf.measure_mode = RubyProf::CPU_TIME EXTERNALS = { "Memcache" => ["MemCache#set", "MemCache#get"], "Database" => ["Mysql2::Client#query"], } def run(obj) obj.pr...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/performance/profile.rb
performance/profile.rb
# frozen_string_literal: true require "rubygems" require "benchmark" require "stackprof" require_relative "cache_runner" RUNS = 1000 def run(obj, filename: nil) puts "#{obj.class.name}:" obj.prepare data = StackProf.run(mode: :cpu) do obj.run end StackProf::Report.new(data).print_text(false, 20) Fil...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache.rb
lib/identity_cache.rb
# frozen_string_literal: true require "active_record" require "active_support/core_ext/module/attribute_accessors" require "ar_transaction_changes" require "identity_cache/version" require "identity_cache/record_not_found" require "identity_cache/encoder" require "identity_cache/cache_key_loader" require "identity_ca...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/belongs_to_caching.rb
lib/identity_cache/belongs_to_caching.rb
# frozen_string_literal: true module IdentityCache module BelongsToCaching extend ActiveSupport::Concern included do |base| base.class_attribute(:cached_belongs_tos) base.cached_belongs_tos = {} end module ClassMethods def cache_belongs_to(association) ensure_base_model ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cache_key_loader.rb
lib/identity_cache/cache_key_loader.rb
# frozen_string_literal: true module IdentityCache # A generic cache key loader that supports different types of # cache fetchers, each of which can use their own cache key # format and have their own cache miss resolvers. # # Here is the interface of a cache fetcher in the # [ruby-signature](https://githu...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cache_key_generation.rb
lib/identity_cache/cache_key_generation.rb
# frozen_string_literal: true module IdentityCache module CacheKeyGeneration extend ActiveSupport::Concern DEFAULT_NAMESPACE = "IDC:#{CACHE_VERSION}:" class << self def schema_to_string(columns) columns.sort_by(&:name).map { |c| "#{c.name}:#{c.type}" }.join(",") end def denorm...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/without_primary_index.rb
lib/identity_cache/without_primary_index.rb
# frozen_string_literal: true module IdentityCache module WithoutPrimaryIndex extend ActiveSupport::Concern include ArTransactionChanges include IdentityCache::BelongsToCaching include IdentityCache::CacheKeyGeneration include IdentityCache::ConfigurationDSL include IdentityCache::QueryAPI ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/version.rb
lib/identity_cache/version.rb
# frozen_string_literal: true module IdentityCache VERSION = "1.6.3" CACHE_VERSION = 8 end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/parent_model_expiration.rb
lib/identity_cache/parent_model_expiration.rb
# frozen_string_literal: true module IdentityCache module ParentModelExpiration # :nodoc: extend ActiveSupport::Concern include ArTransactionChanges class << self def add_parent_expiry_hook(cached_association) name = cached_association.reflection.class_name.demodulize lazy_hooks[na...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/with_primary_index.rb
lib/identity_cache/with_primary_index.rb
# frozen_string_literal: true module IdentityCache module WithPrimaryIndex extend ActiveSupport::Concern include WithoutPrimaryIndex def expire_cache expired_primary_index = expire_primary_index super && expired_primary_index end # @api private def expire_primary_index # :nodo...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/query_api.rb
lib/identity_cache/query_api.rb
# frozen_string_literal: true module IdentityCache module QueryAPI extend ActiveSupport::Concern module ClassMethods # Prefetches cached associations on a collection of records def prefetch_associations(includes, records) Cached::Prefetcher.prefetch(self, includes, records) end ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/record_not_found.rb
lib/identity_cache/record_not_found.rb
# frozen_string_literal: true module IdentityCache class RecordNotFound < ActiveRecord::RecordNotFound end end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/expiry_hook.rb
lib/identity_cache/expiry_hook.rb
# frozen_string_literal: true module IdentityCache class ExpiryHook def initialize(cached_association) @cached_association = cached_association end def install cached_association.validate entry = [parent_class, only_on_foreign_key_change?] child_class.parent_expiration_entries[in...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/railtie.rb
lib/identity_cache/railtie.rb
# frozen_string_literal: true module IdentityCache class Railtie < Rails::Railtie initializer "identity_cache.setup" do |app| app.config.eager_load_namespaces << IdentityCache end end end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached.rb
lib/identity_cache/cached.rb
# frozen_string_literal: true module IdentityCache module Cached end private_constant :Cached end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/configuration_dsl.rb
lib/identity_cache/configuration_dsl.rb
# frozen_string_literal: true module IdentityCache module ConfigurationDSL extend ActiveSupport::Concern included do |base| base.class_attribute(:cache_indexes) base.class_attribute(:cached_has_manys) base.class_attribute(:cached_has_ones) base.cached_has_manys = {} base.cache...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/memoized_cache_proxy.rb
lib/identity_cache/memoized_cache_proxy.rb
# frozen_string_literal: true require "monitor" require "benchmark" module IdentityCache class MemoizedCacheProxy attr_reader :cache_fetcher def initialize(cache_adaptor = nil) self.cache_backend = cache_adaptor || Rails.cache @key_value_maps = Hash.new { |h, k| h[k] = {} } end def cac...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cache_invalidation.rb
lib/identity_cache/cache_invalidation.rb
# frozen_string_literal: true module IdentityCache module CacheInvalidation CACHE_KEY_NAMES = [:ids_variable_name, :id_variable_name, :records_variable_name] def reload(*) clear_cached_associations super end private def clear_cached_associations self.class.all_cached_associat...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cache_fetcher.rb
lib/identity_cache/cache_fetcher.rb
# frozen_string_literal: true require "securerandom" module IdentityCache class CacheFetcher attr_accessor :cache_backend EMPTY_HASH = {}.freeze class FillLock FILL_LOCKED = :fill_locked FAILED_CLIENT_ID = "fill_failed" class << self def from_cache(marker, client_id, data_ve...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cache_hash.rb
lib/identity_cache/cache_hash.rb
# frozen_string_literal: true # Use CityHash for fast hashing if it is available; use Digest::MD5 otherwise begin require "cityhash" rescue LoadError unless RUBY_PLATFORM == "java" warn(<<-NOTICE) ** Notice: CityHash was not loaded. ** For optimal performance, use of the cityhash gem is recommende...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/encoder.rb
lib/identity_cache/encoder.rb
# frozen_string_literal: true module IdentityCache module Encoder DEHYDRATE_EVENT = "dehydration.identity_cache" HYDRATE_EVENT = "hydration.identity_cache" class << self def encode(record) return unless record ActiveSupport::Notifications.instrument(DEHYDRATE_EVENT, class: recor...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/mem_cache_store_cas.rb
lib/identity_cache/mem_cache_store_cas.rb
# frozen_string_literal: true require "dalli/cas/client" unless Dalli::VERSION > "3" module IdentityCache module MemCacheStoreCAS def cas(name, options = nil) options = merged_options(options) key = normalize_key(name, options) rescue_error_with(false) do instrument(:cas, key, options...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/fallback_fetcher.rb
lib/identity_cache/fallback_fetcher.rb
# frozen_string_literal: true module IdentityCache class FallbackFetcher attr_accessor :cache_backend def initialize(cache_backend) @cache_backend = cache_backend end def write(key, value) @cache_backend.write(key, value) if IdentityCache.should_fill_cache? end def delete(key) ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/should_use_cache.rb
lib/identity_cache/should_use_cache.rb
# frozen_string_literal: true module IdentityCache module ShouldUseCache extend ActiveSupport::Concern module ClassMethods def should_use_cache? IdentityCache.should_use_cache? end end private def mark_as_loaded_by_idc @loaded_by_idc = true end def loaded_by_...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/load_strategy/load_request.rb
lib/identity_cache/load_strategy/load_request.rb
# frozen_string_literal: true module IdentityCache module LoadStrategy class LoadRequest attr_reader :db_keys def initialize(db_keys, callback) @db_keys = db_keys @callback = callback end def after_load(results) @callback.call(results) end end priv...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/load_strategy/multi_load_request.rb
lib/identity_cache/load_strategy/multi_load_request.rb
# frozen_string_literal: true module IdentityCache module LoadStrategy class MultiLoadRequest def initialize(load_requests) @load_requests = load_requests end def db_keys @load_requests.flat_map(&:db_keys).tap(&:uniq!) end def after_load(all_results) @load_...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/load_strategy/lazy.rb
lib/identity_cache/load_strategy/lazy.rb
# frozen_string_literal: true module IdentityCache module LoadStrategy class Lazy def initialize @pending_loads = {} end def load(cache_fetcher, db_key) load_multi(cache_fetcher, [db_key]) do |results| yield results.fetch(db_key) end nil end ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/load_strategy/eager.rb
lib/identity_cache/load_strategy/eager.rb
# frozen_string_literal: true module IdentityCache module LoadStrategy module Eager extend self def load(cache_fetcher, db_key) yield CacheKeyLoader.load(cache_fetcher, db_key) end def load_multi(cache_fetcher, db_keys) yield CacheKeyLoader.load_multi(cache_fetcher, db_k...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/attribute_by_one.rb
lib/identity_cache/cached/attribute_by_one.rb
# frozen_string_literal: true module IdentityCache module Cached class AttributeByOne < Attribute attr_reader :key_field def initialize(*) super @key_field = key_fields.first end def build cached_attribute = self model.define_singleton_method(:"fetch_#{f...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/embedded_fetching.rb
lib/identity_cache/cached/embedded_fetching.rb
# frozen_string_literal: true module IdentityCache module Cached module EmbeddedFetching private def fetch_embedded(records) fetch_embedded_async(LoadStrategy::Eager, records) {} end def fetch_embedded_async(load_strategy, records) return yield if embedded_fetched?(recor...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/attribute.rb
lib/identity_cache/cached/attribute.rb
# frozen_string_literal: true module IdentityCache module Cached # @abstract class Attribute attr_reader :model, :alias_name, :key_fields, :unique def initialize(model, attribute_or_proc, alias_name, key_fields, unique) @model = model if attribute_or_proc.is_a?(Proc) @a...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/primary_index.rb
lib/identity_cache/cached/primary_index.rb
# frozen_string_literal: true module IdentityCache module Cached class PrimaryIndex attr_reader :model def initialize(model) @model = model end def fetch(id, cache_fetcher_options) id = cast_id(id) return unless id record = if model.should_use_cache? ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/attribute_by_multi.rb
lib/identity_cache/cached/attribute_by_multi.rb
# frozen_string_literal: true module IdentityCache module Cached class AttributeByMulti < Attribute def build cached_attribute = self model.define_singleton_method(:"fetch_#{fetch_method_suffix}") do |*keys| raise_if_scoped cached_attribute.fetch(keys) end ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/prefetcher.rb
lib/identity_cache/cached/prefetcher.rb
# frozen_string_literal: true module IdentityCache module Cached module Prefetcher ASSOCIATION_FETCH_EVENT = "association_fetch.identity_cache" class << self def prefetch(klass, associations, records, load_strategy: LoadStrategy::Eager) return if (records = records.to_a).empty? ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/belongs_to.rb
lib/identity_cache/cached/belongs_to.rb
# frozen_string_literal: true module IdentityCache module Cached class BelongsTo < Association # :nodoc: attr_reader :records_variable_name def build reflection.active_record.class_eval(<<-RUBY, __FILE__, __LINE__ + 1) def #{cached_accessor_name} association_klass = ass...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/association.rb
lib/identity_cache/cached/association.rb
# frozen_string_literal: true module IdentityCache module Cached class Association # :nodoc: include EmbeddedFetching def initialize(name, reflection:) @name = name @reflection = reflection @cached_accessor_name = :"fetch_#{name}" @records_variable_name = :"@cached_#{...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/recursive/has_one.rb
lib/identity_cache/cached/recursive/has_one.rb
# frozen_string_literal: true module IdentityCache module Cached module Recursive class HasOne < Association # :nodoc: end end end end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/recursive/has_many.rb
lib/identity_cache/cached/recursive/has_many.rb
# frozen_string_literal: true module IdentityCache module Cached module Recursive class HasMany < Association # :nodoc: end end end end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/recursive/association.rb
lib/identity_cache/cached/recursive/association.rb
# frozen_string_literal: true module IdentityCache module Cached module Recursive class Association < Cached::Association # :nodoc: def initialize(name, reflection:) super @dehydrated_variable_name = :"@dehydrated_#{name}" end attr_reader :dehydrated_variable_na...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/reference/has_one.rb
lib/identity_cache/cached/reference/has_one.rb
# frozen_string_literal: true module IdentityCache module Cached module Reference class HasOne < Association # :nodoc: def initialize(name, reflection:) super @cached_id_name = "fetch_#{id_name}" @id_variable_name = :"@#{id_cached_reader_name}" end att...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/reference/has_many.rb
lib/identity_cache/cached/reference/has_many.rb
# frozen_string_literal: true module IdentityCache module Cached module Reference class HasMany < Association # :nodoc: def initialize(name, reflection:) super @cached_ids_name = "fetch_#{ids_name}" @ids_variable_name = :"@#{ids_cached_reader_name}" end ...
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
Shopify/identity_cache
https://github.com/Shopify/identity_cache/blob/460c68c333b3605273b1e1355f657a07e570ec8f/lib/identity_cache/cached/reference/association.rb
lib/identity_cache/cached/reference/association.rb
# frozen_string_literal: true module IdentityCache module Cached module Reference class Association < Cached::Association # :nodoc: def embedded_by_reference? true end def embedded_recursively? false end end end end end
ruby
MIT
460c68c333b3605273b1e1355f657a07e570ec8f
2026-01-04T15:59:24.839029Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/extconf.rb
extconf.rb
require "mkmf" $CPPFLAGS = "" dir_config("gl") dir_config("zlib") include_path = $CPPFLAGS.gsub("-I", "").strip libs = $LIBPATH.map { |path| "-L#{path}"}.join(" ").strip unless include_path.empty? ENV["CAPYBARA_WEBKIT_INCLUDE_PATH"] = include_path end unless libs.empty? ENV["CAPYBARA_WEBKIT_LIBS"] = libs end ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/driver_rendering_spec.rb
spec/driver_rendering_spec.rb
require 'spec_helper' require 'capybara/webkit/driver' require 'mini_magick' describe Capybara::Webkit::Driver, "rendering an image" do include AppRunner let(:driver) do driver_for_html(<<-HTML) <html> <body> <h1>Hello World</h1> </body> </html> HTML end before(:...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/driver_spec.rb
spec/driver_spec.rb
# -*- encoding: UTF-8 -*- require 'spec_helper' require 'capybara/webkit/driver' require 'base64' require 'self_signed_ssl_cert' describe Capybara::Webkit::Driver do include AppRunner def visit(path, driver=self.driver) driver.visit(url(path)) end def url(path) "#{AppRunner.app_host}#{path}" end ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
true
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/self_signed_ssl_cert.rb
spec/self_signed_ssl_cert.rb
require 'openssl' pem = <<-PEM_ENCODED -----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKW+grT6YW3gv79y P9JkQDtm3cDSUhAhd/TEyRBt/pSKz3pNSygsleBJl2d7g8k0fteec95a7YnYRKGH XhIpUOvl/3uaV2NVipqxwB+Z+0M+7HegxL3e4unaRFy9kf9/UXJzmuA9BTMLrm/w IoW17f+dz7BIFZhCvRurkrmvzraNAgMBAAECgYBv4uB3bYJx20N16Jk+3...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/configuration_spec.rb
spec/configuration_spec.rb
require "spec_helper" describe Capybara::Webkit::Configuration do it "returns a hash and then prevents future modification" do Capybara::Webkit.configure do |config| config.debug = true end result = Capybara::Webkit::Configuration.to_hash expect(result).to include(debug: true) expect { Ca...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/capybara_webkit_builder_spec.rb
spec/capybara_webkit_builder_spec.rb
require 'spec_helper' require 'capybara_webkit_builder' describe CapybaraWebkitBuilder do let(:builder) { CapybaraWebkitBuilder } it "will use the env variable for #make_bin" do with_env_vars("MAKE" => "fake_make") do expect(builder.make_bin).to eq "fake_make" end end it "will use the env varia...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/connection_spec.rb
spec/connection_spec.rb
require 'spec_helper' require 'capybara/webkit/connection' describe Capybara::Webkit::Connection do it "sets appropriate options on its socket" do socket = double("socket") server = double(:Server, start: nil, port: 123) allow(TCPSocket).to receive(:open).and_return(socket) if defined?(Socket::TCP_NO...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/cookie_jar_spec.rb
spec/cookie_jar_spec.rb
require 'spec_helper' require 'capybara/webkit/cookie_jar' describe Capybara::Webkit::CookieJar do let(:browser) { browser = double("Browser") allow(browser).to receive(:get_cookies) { [ "cookie1=1; domain=.example.org; path=/", "cookie1=2; domain=.example.org; path=/dir1/", "cookie1=...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/selenium_compatibility_spec.rb
spec/selenium_compatibility_spec.rb
require 'spec_helper' describe Capybara::Webkit, 'compatibility with selenium' do include AppRunner it 'generates the same events as selenium when filling out forms', selenium_compatibility: true do run_application_for_html(<<-HTML) <html><body> <form onsubmit="return false"> <label fo...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/server_spec.rb
spec/server_spec.rb
require "spec_helper" require "capybara/webkit/server" describe Capybara::Webkit::Connection do it "ensures the process ends when the parent process ends", skip_on_windows: true, skip_on_jruby: true do sleep 1 # Without this sleep popen3 hangs on OSX when running the tests - not really sure why read_io, writ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/errors_spec.rb
spec/errors_spec.rb
require 'spec_helper' describe Capybara::Webkit::JsonError do let(:error) { described_class.new '{"class": "ClickFailed", "message": "Error clicking this element"}' } subject { error.exception } it { should be_an_instance_of Capybara::Webkit::ClickFailed } it { expect(subject.message).to eq 'Error clicking ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/browser_spec.rb
spec/browser_spec.rb
require 'spec_helper' require 'self_signed_ssl_cert' require 'stringio' require 'capybara/webkit/driver' require 'socket' require 'base64' describe Capybara::Webkit::Browser do let(:server) { Capybara::Webkit::Server.new } let(:connection) { Capybara::Webkit::Connection.new(server: server) } let(:browser) { Cap...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/driver_resize_window_spec.rb
spec/driver_resize_window_spec.rb
require 'spec_helper' require 'capybara/webkit/driver' describe Capybara::Webkit::Driver, "#resize_window(width, height)" do include AppRunner let(:driver) do driver_for_html(<<-HTML) <html> <body> <h1 id="dimentions">UNKNOWN</h1> <script> window.onload = window....
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/spec_helper.rb
spec/spec_helper.rb
require 'rspec' require 'rbconfig' require 'capybara' PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze $LOAD_PATH << File.join(PROJECT_ROOT, 'lib') Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require(file) } require 'capybara/webkit' $webkit_server = Ca...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/node_spec.rb
spec/node_spec.rb
# -*- encoding: UTF-8 -*- require "spec_helper" require "capybara/webkit/driver" require "base64" require "self_signed_ssl_cert" describe Capybara::Webkit::Node do include AppRunner def visit(path, driver = self.driver) driver.visit(url(path)) end def url(path) "#{AppRunner.app_host}#{path}" end ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/support/app_runner.rb
spec/support/app_runner.rb
# Boots a single Capybara::Server for a Rack application that delegates to another, singleton Rack # application that can be configured for each spec. require 'sinatra/base' module AppRunner class << self attr_accessor :app, :app_host, :browser, :configuration end def self.boot app_container = lambda {...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/support/output_writer.rb
spec/support/output_writer.rb
shared_examples_for "output writer" do before do @read, @write = IO.pipe configure { |config| config.stderr = @write } fork_connection end let(:stderr) do @write.close @read.read end end
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/support/matchers/include_response.rb
spec/support/matchers/include_response.rb
RSpec::Matchers.define :include_response do |expected_response| read_timeout = 2 read_bytes = 4096 response = "" match do |read_io| found_response = false while !found_response && IO.select([read_io], nil, nil, read_timeout) do response += read_io.read_nonblock(read_bytes) found_response =...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/integration/session_spec.rb
spec/integration/session_spec.rb
# -*- encoding: UTF-8 -*- require 'spec_helper' require 'capybara/webkit' module TestSessions Webkit = Capybara::Session.new(:reusable_webkit, TestApp) end Capybara::SpecHelper.run_specs TestSessions::Webkit, "webkit", capybara_skip: [:download] describe Capybara::Session do include AppRunner include Capybara...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/spec/fixtures/exit_text.rb
spec/fixtures/exit_text.rb
require 'spec_helper' # require 'selenium-webdriver' RSpec.describe Capybara::Webkit::Driver do it "should exit with a zero exit status" do browser = Capybara::Webkit::Driver.new(TestApp).browser expect(true).to eq(true) end end
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara_webkit_builder.rb
lib/capybara_webkit_builder.rb
require 'etc' require "fileutils" require "rbconfig" require "shellwords" module CapybaraWebkitBuilder extend self SUCCESS_STATUS = 0 COMMAND_NOT_FOUND_STATUS = 127 def make_bin ENV['MAKE'] || 'make' end def qmake_bin ENV['QMAKE'] || default_qmake_binary end def default_qmake_binary cas...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara-webkit.rb
lib/capybara-webkit.rb
require "capybara/webkit"
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit.rb
lib/capybara/webkit.rb
require "capybara" module Capybara module Webkit def self.configure(&block) Capybara::Webkit::Configuration.modify(&block) end end end require "capybara/webkit/driver" require "capybara/webkit/configuration" Capybara.register_driver :webkit do |app| Capybara::Webkit::Driver.new(app, Capybara::Web...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/version.rb
lib/capybara/webkit/version.rb
module Capybara module Driver class Webkit VERSION = "1.15.1".freeze end end end
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/matchers.rb
lib/capybara/webkit/matchers.rb
module Capybara module Webkit module RspecMatchers RSpec::Matchers.define :have_errors do |expected| match do |actual| actual = resolve(actual) actual.error_messages.any? end #RSpec 2 compatability send(respond_to?(:failure_message) ? :failure_message : :...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/cookie_jar.rb
lib/capybara/webkit/cookie_jar.rb
require 'webrick/cookie' # A simple cookie jar implementation. # Does not take special cookie attributes # into account like expire, max-age, httponly, secure class Capybara::Webkit::CookieJar attr_reader :browser def initialize(browser) @browser = browser end def [](*args) cookie = find(*args) c...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/errors.rb
lib/capybara/webkit/errors.rb
module Capybara::Webkit class InvalidResponseError < StandardError end class NoResponseError < StandardError end class NodeNotAttachedError < Capybara::ElementNotFound end class ClickFailed < StandardError end class TimeoutError < Timeout::Error end class NoSuchWindowError < StandardError e...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/driver.rb
lib/capybara/webkit/driver.rb
require "capybara" require "capybara/webkit/version" require "capybara/webkit/node" require "capybara/webkit/connection" require "capybara/webkit/browser" require "capybara/webkit/cookie_jar" require "capybara/webkit/errors" require "capybara/webkit/server" module Capybara::Webkit class Driver < Capybara::Driver::Ba...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/browser.rb
lib/capybara/webkit/browser.rb
require "json" require "capybara/webkit/errors" module Capybara::Webkit class Browser def initialize(connection) @connection = connection apply_defaults end def authenticate(username, password) command("Authenticate", username, password) end def enable_logging command "E...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/node.rb
lib/capybara/webkit/node.rb
module Capybara::Webkit class Node < Capybara::Driver::Node def initialize(driver, base, browser) super(driver, base) @browser = browser end def visible_text text = invoke(:text).to_s if Capybara::VERSION.to_f < 3.0 Capybara::Helpers.normalize_whitespace(text) else ...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/configuration.rb
lib/capybara/webkit/configuration.rb
module Capybara module Webkit class Configuration class << self private def instance @instance ||= new end end def self.to_hash instance.freeze.to_hash end def self.modify if instance.frozen? raise "All configuration must...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/connection.rb
lib/capybara/webkit/connection.rb
require 'socket' require 'timeout' require 'thread' module Capybara::Webkit class Connection def initialize(options = {}) @socket = nil if options.has_key?(:socket_class) warn '[DEPRECATION] The Capybara::Webkit::Connection `socket_class` ' \ 'option is deprecated without replacemen...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
thoughtbot/capybara-webkit
https://github.com/thoughtbot/capybara-webkit/blob/f429d668568ff7349f5e23a085df7fcf1c431fa7/lib/capybara/webkit/server.rb
lib/capybara/webkit/server.rb
require "open3" require "thread" module Capybara module Webkit class Server SERVER_PATH = File.expand_path("../../../../bin/webkit_server", __FILE__) WEBKIT_SERVER_START_TIMEOUT = 15 attr_reader :port, :pid def initialize(options = {}) if options.has_key?(:stderr) @out...
ruby
MIT
f429d668568ff7349f5e23a085df7fcf1c431fa7
2026-01-04T15:59:20.890583Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/test_helper.rb
test/test_helper.rb
require "bundler/setup" Bundler.require(:default) require "minitest/autorun" # Add the test root directory to the default load path, regardless of where # tests are run from. $LOAD_PATH.unshift(File.dirname(__FILE__)) # Detect the source root directory. API_UMBRELLA_SRC_ROOT = File.expand_path("..", __dir__) if(!Fil...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/log_tail.rb
test/support/log_tail.rb
class LogTail def initialize(filename) @path = File.join($config["log_dir"], filename) if File.exist?(@path) File.open(@path) do |file| file.seek(0, IO::SEEK_END) @pos = file.pos end else @pos = 0 end end def read output = nil if File.exist?(@path) ...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/thread.rb
test/support/thread.rb
# Ensure that threads we use during tests raise errors, rather than silently # failing. Thread.abort_on_exception = true
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/capybara.rb
test/support/capybara.rb
require "capybara/minitest" require "capybara/shadowdom" require "capybara-screenshot/minitest" require "open3" require "support/api_umbrella_test_helpers/admin_auth" require "support/api_umbrella_test_helpers/capybara_codemirror" require "support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs" require "sup...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/ipv6.rb
test/support/ipv6.rb
IPV6_SUPPORT = File.exist?("/proc/net/if_inet6") && !File.empty?("/proc/net/if_inet6") class Minitest::Test private def skip_unless_ipv6_support unless IPV6_SUPPORT message = "WARNING: Skipping test_static_ipv6 due to lack of IPv6 support." warn(message) skip(message) end end end
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/ethon_debug.rb
test/support/ethon_debug.rb
module Ethon class Easy module Callbacks @@debug_callback_exclude_types = [] # Override Ethon's default debug callback # (https://github.com/typhoeus/ethon/blob/v0.9.1/lib/ethon/easy/callbacks.rb#L66-L73) # so it only captures the debug output and doesn't print it to the # screen. T...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/awesome_print.rb
test/support/awesome_print.rb
AwesomePrint.defaults = { :indent => -2, }
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/xml.rb
test/support/xml.rb
require "rexml/document"
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/database_cleaner.rb
test/support/database_cleaner.rb
# Clean the database using deletion. # # We can't use transactions, since we rely on the data we insert in the tests # being available to the remote test server, which won't share the transaction. # # We use deletion instead of truncation, since it seems to perform better for # our specific use-cases. We also need to b...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/csv.rb
test/support/csv.rb
require "csv"
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/test_namespaces.rb
test/support/test_namespaces.rb
# Define namespace modules for all the test classes. # # We pre-define all these here so that we can use the shorter, more succinct # single-line/non-nested syntax in all the test files. module Test module AdminUi module Login; end end module Apis module Admin module Stats; end end module ...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/retry.rb
test/support/retry.rb
# While not ideal, retry certain flaky tests in CI. if ENV["CI"] == "true" require "minitest/retry" module Minitest::Retry # Instead of relying on minitest-retry's various built-in options (like # `exceptions_to_retry` and `methods_to_retry`), override it's retry logic # method completely to allow for ...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/factory_bot.rb
test/support/factory_bot.rb
FactoryBot.find_definitions module FactoryBot # Either return the results of FactoryBot.attributes_for or # FactirlBot.build for a given factory, depending on what the current # factory strategy is. # # The use case for this is to be called for nested association factory data, # so that when attributes_for...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/reporter.rb
test/support/reporter.rb
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/pretty_diffs.rb
test/support/pretty_diffs.rb
class Minitest::Test # Override the method minitest uses for generating diffs to use # awesome_inspect. This provides easier to read diffs, particularly when # dealing with nested, complex hashes. def mu_pp(obj) obj.awesome_inspect({ :indent => -2, :index => false, :sort_keys => true, ...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb
test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb
module ApiUmbrellaTestHelpers module CapybaraCustomBootstrapInputs # For our custom radio/checkboxes, we need to click on the label, rather # than the input (since the input is technically hidden and only virtually # shown). The "automatic_label_click" option makes this work in most cases, # so we can...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/formatted_errors.rb
test/support/api_umbrella_test_helpers/formatted_errors.rb
module ApiUmbrellaTestHelpers module FormattedErrors private def assert_json_error(response, error_code = "API_KEY_MISSING") assert_response_code(403, response) assert_equal("application/json", response.headers["content-type"]) data = MultiJson.load(response.body) assert_equal(error_c...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/api_matching.rb
test/support/api_umbrella_test_helpers/api_matching.rb
module ApiUmbrellaTestHelpers module ApiMatching private def make_request_to_host(host, path, options = {}) Typhoeus.get("https://127.0.0.1:9081#{path}", http_options.deep_merge(options).deep_merge({ :headers => { "Host" => host, }, })) end def assert_backend_ma...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/admin_ui_login.rb
test/support/api_umbrella_test_helpers/admin_ui_login.rb
require "securerandom" require "support/api_umbrella_test_helpers/selenium" module ApiUmbrellaTestHelpers module AdminUiLogin include ApiUmbrellaTestHelpers::Selenium private def assert_login_permitted(login_button_text, admin) visit "/admin/" click_button(login_button_text) assert_li...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/rate_limits.rb
test/support/api_umbrella_test_helpers/rate_limits.rb
module ApiUmbrellaTestHelpers module RateLimits private def assert_api_key_rate_limit(path, limit, **options) assert_allows_up_to_limit_and_then_rejects(path, limit, **options) assert_counts_api_keys_separately(path, limit, **options) assert_rate_limit_headers(path, limit, **options) en...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false
NREL/api-umbrella
https://github.com/NREL/api-umbrella/blob/eac5a7c32d971c7f193179da3469d3cbd561d590/test/support/api_umbrella_test_helpers/setup.rb
test/support/api_umbrella_test_helpers/setup.rb
require "English" require "ipaddr" require "support/api_umbrella_test_helpers/admin_auth" require "support/api_umbrella_test_helpers/common_asserts" require "support/api_umbrella_test_helpers/shell" module ApiUmbrellaTestHelpers module Setup extend ActiveSupport::Concern include ApiUmbrellaTestHelpers::Admi...
ruby
MIT
eac5a7c32d971c7f193179da3469d3cbd561d590
2026-01-04T15:57:56.164132Z
false