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
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list.rb
lib/acts_as_list.rb
# frozen_string_literal: true require "acts_as_list/active_record/acts/list" require "acts_as_list/active_record/acts/position_column_method_definer" require "acts_as_list/active_record/acts/scope_method_definer" require "acts_as_list/active_record/acts/top_of_list_method_definer" require "acts_as_list/active_record/a...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/version.rb
lib/acts_as_list/version.rb
# frozen_string_literal: true module ActiveRecord module Acts module List VERSION = '1.2.6' end end end
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/position_column_method_definer.rb
lib/acts_as_list/active_record/acts/position_column_method_definer.rb
# frozen_string_literal: true require_relative './with_connection' module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc: def self.call(caller_class, position_column, touch_on_update) define_class_methods(caller_class, position_column, touch_on_update) define_instance_methods(caller_class, po...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/active_record.rb
lib/acts_as_list/active_record/acts/active_record.rb
# frozen_string_literal: true ActiveSupport.on_load :active_record do extend ActiveRecord::Acts::List::ClassMethods end
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/add_new_at_method_definer.rb
lib/acts_as_list/active_record/acts/add_new_at_method_definer.rb
# frozen_string_literal: true module ActiveRecord::Acts::List::AddNewAtMethodDefiner #:nodoc: def self.call(caller_class, add_new_at) caller_class.class_eval do define_method :add_new_at do add_new_at end end end end
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/no_update.rb
lib/acts_as_list/active_record/acts/no_update.rb
# frozen_string_literal: true module ActiveRecord module Acts module List module NoUpdate def self.included(base) base.extend ClassMethods end class ArrayTypeError < ArgumentError def initialize super("The first argument must be an array") ...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/callback_definer.rb
lib/acts_as_list/active_record/acts/callback_definer.rb
# frozen_string_literal: true module ActiveRecord::Acts::List::CallbackDefiner #:nodoc: def self.call(caller_class, add_new_at) caller_class.class_eval do before_validation :check_top_position, unless: :act_as_list_no_update? before_destroy :reload, unless: Proc.new { new_record? || destroyed_via_sc...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/aux_method_definer.rb
lib/acts_as_list/active_record/acts/aux_method_definer.rb
# frozen_string_literal: true module ActiveRecord::Acts::List::AuxMethodDefiner #:nodoc: def self.call(caller_class) caller_class.class_eval do define_method :acts_as_list_class do caller_class end end end end
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/scope_method_definer.rb
lib/acts_as_list/active_record/acts/scope_method_definer.rb
# frozen_string_literal: true require "active_support/inflector" module ActiveRecord::Acts::List::ScopeMethodDefiner #:nodoc: def self.call(caller_class, scope) scope = idify(caller_class, scope) if scope.is_a?(Symbol) caller_class.class_eval do define_method :scope_name do scope end ...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb
lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb
# frozen_string_literal: true require_relative './with_connection' module ActiveRecord::Acts::List::SequentialUpdatesMethodDefiner #:nodoc: def self.call(caller_class, column, sequential_updates_option) caller_class.class_eval do define_method :sequential_updates? do return @sequential_updates if ...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/list.rb
lib/acts_as_list/active_record/acts/list.rb
# frozen_string_literal: true require_relative './with_connection' module ActiveRecord module Acts #:nodoc: module List #:nodoc: module ClassMethods # Configuration options are: # # * +column+ - specifies the column name to use for keeping the position integer (default: +position+...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/top_of_list_method_definer.rb
lib/acts_as_list/active_record/acts/top_of_list_method_definer.rb
# frozen_string_literal: true module ActiveRecord::Acts::List::TopOfListMethodDefiner #:nodoc: def self.call(caller_class, top_of_list) caller_class.class_eval do define_singleton_method :acts_as_list_top do top_of_list.to_i end define_method :acts_as_list_top do top_of_list.to...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
brendon/acts_as_list
https://github.com/brendon/acts_as_list/blob/c105e17152142040813c11873e77891c82ec6069/lib/acts_as_list/active_record/acts/with_connection.rb
lib/acts_as_list/active_record/acts/with_connection.rb
# frozen_string_literal: true module ActiveRecord module Acts module List class WithConnection def initialize(recipient) @recipient = recipient end attr_reader :recipient def call if recipient.respond_to?(:with_connection) recipient.with_con...
ruby
MIT
c105e17152142040813c11873e77891c82ec6069
2026-01-04T15:58:42.362067Z
false
CombineCommunity/rxswift-to-combine-cheatsheet
https://github.com/CombineCommunity/rxswift-to-combine-cheatsheet/blob/edd5f0673f44b9a1981a250da0eca6d14e2c0af9/generate.rb
generate.rb
#!/usr/bin/env ruby system("csv2md > /dev/null 2>&1") unless $?.exitstatus == 0 print "Missing dependencies. Want to run `bundle install`? [Y/n]: " answer = gets.chop.downcase.strip system("bundle install") if answer == "y" end require 'commonmarker' require 'imgkit' require 'colorize' require 'csv' ...
ruby
MIT
edd5f0673f44b9a1981a250da0eca6d14e2c0af9
2026-01-04T15:58:24.516540Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/app/model/knock/auth_token.rb
app/model/knock/auth_token.rb
require "jwt" module Knock class AuthToken attr_reader :token attr_reader :payload attr_reader :entity_class_name def initialize(payload: {}, token: nil, verify_options: {}, entity_class_name: nil) @entity_class_name = entity_class_name if token.present? @payload, _ = JWT.decode ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/app/controllers/knock/auth_token_controller.rb
app/controllers/knock/auth_token_controller.rb
require_dependency "knock/application_controller" module Knock class AuthTokenController < ApplicationController before_action :authenticate def create render json: auth_token, status: :created end private def authenticate unless entity.present? && entity.authenticate(auth_params[:...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/app/controllers/knock/application_controller.rb
app/controllers/knock/application_controller.rb
module Knock class ApplicationController < ActionController::API rescue_from Knock.not_found_exception_class_name, with: :not_found private def not_found head :not_found end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/knock_test.rb
test/knock_test.rb
require 'test_helper' class KnockTest < ActiveSupport::TestCase test 'setup block yields self' do Knock.setup do |config| assert_equal Knock, config end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/test_helper.rb
test/test_helper.rb
require 'simplecov' require 'bcrypt' SimpleCov.start # Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] ActiveRecord::Migrator.migra...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/support/generators_test_helper.rb
test/support/generators_test_helper.rb
module GeneratorsTestHelper def copy_routes routes = File.expand_path("../../dummy/config/routes.rb", __FILE__) destination = File.join(destination_root, "config") FileUtils.mkdir_p(destination) FileUtils.cp routes, destination end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/model/knock/auth_token_test.rb
test/model/knock/auth_token_test.rb
require 'test_helper' require 'jwt' require 'timecop' module Knock class AuthTokenTest < ActiveSupport::TestCase setup do key = Knock.token_secret_signature_key.call @token = JWT.encode({ sub: '1' }, key, 'HS256') end test "verify algorithm" do Knock.token_signature_algorithm = 'RS256'...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/helpers/application_helper.rb
test/dummy/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/admin_protected_controller.rb
test/dummy/app/controllers/admin_protected_controller.rb
class AdminProtectedController < ApplicationController before_action :authenticate_admin def index head :ok end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/current_users_controller.rb
test/dummy/app/controllers/current_users_controller.rb
class CurrentUsersController < ApplicationController def show if current_user head :ok else head :not_found end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/protected_resources_controller.rb
test/dummy/app/controllers/protected_resources_controller.rb
class ProtectedResourcesController < ApplicationController before_action :authenticate_user def index head :ok end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/vendor_token_controller.rb
test/dummy/app/controllers/vendor_token_controller.rb
class VendorTokenController < Knock::AuthTokenController end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/custom_unauthorized_entity_controller.rb
test/dummy/app/controllers/custom_unauthorized_entity_controller.rb
class CustomUnauthorizedEntityController < ApplicationController before_action :authenticate_user def index head :ok end private def unauthorized_entity(entity) head :not_found end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/composite_name_entity_protected_controller.rb
test/dummy/app/controllers/composite_name_entity_protected_controller.rb
class CompositeNameEntityProtectedController < ApplicationController before_action :authenticate_composite_name_entity def index head :ok end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/admin_token_controller.rb
test/dummy/app/controllers/admin_token_controller.rb
class AdminTokenController < Knock::AuthTokenController end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/guest_protected_controller.rb
test/dummy/app/controllers/guest_protected_controller.rb
class GuestProtectedController < ApplicationController before_action :authenticate_guest def index head :ok end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/application_controller.rb
test/dummy/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session include Knock::Authenticable end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/vendor_protected_controller.rb
test/dummy/app/controllers/vendor_protected_controller.rb
class VendorProtectedController < ApplicationController before_action :authenticate_vendor, only: [:index] before_action :some_missing_method, only: [:show] def index head :ok end def show end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/controllers/v1/test_namespaced_controller.rb
test/dummy/app/controllers/v1/test_namespaced_controller.rb
module V1 class TestNamespacedController < ApplicationController before_action :authenticate_v1_user def index head :ok end private def authenticate_v1_user authenticate_for V1::User end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/composite_name_entity.rb
test/dummy/app/models/composite_name_entity.rb
class CompositeNameEntity < ActiveRecord::Base has_secure_password end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/vendor.rb
test/dummy/app/models/vendor.rb
class Vendor < ActiveRecord::Base has_secure_password end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/guest.rb
test/dummy/app/models/guest.rb
class Guest def self.from_token_payload _payload # This is to simulate the use of `find_or_create` # on an AR model, regardless of the payload content new end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/admin.rb
test/dummy/app/models/admin.rb
class Admin < ActiveRecord::Base has_secure_password def self.from_token_request request email = request.params["auth"] && request.params["auth"]["email"] self.find_by email: email end def self.from_token_payload payload self.find payload["sub"] end def to_token_payload {sub: id} end en...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/user.rb
test/dummy/app/models/user.rb
class User < ActiveRecord::Base has_secure_password end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/app/models/v1/user.rb
test/dummy/app/models/v1/user.rb
module V1 class User < ActiveRecord::Base has_secure_password end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/schema.rb
test/dummy/db/schema.rb
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # dat...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/migrate/20160522051816_create_vendors.rb
test/dummy/db/migrate/20160522051816_create_vendors.rb
class CreateVendors < ActiveRecord::Migration[4.2] def change create_table :vendors do |t| t.string :email t.string :password_digest t.timestamps null: false end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/migrate/20160519075733_create_admins.rb
test/dummy/db/migrate/20160519075733_create_admins.rb
class CreateAdmins < ActiveRecord::Migration[4.2] def change create_table :admins do |t| t.string :email t.string :password_digest t.timestamps null: false end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/migrate/20150713101607_create_users.rb
test/dummy/db/migrate/20150713101607_create_users.rb
class CreateUsers < ActiveRecord::Migration[4.2] def change create_table :users do |t| t.string :email, unique: true, null: false t.string :password_digest, null: false t.timestamps null: false end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/migrate/20161127203222_create_v1_users.rb
test/dummy/db/migrate/20161127203222_create_v1_users.rb
class CreateV1Users < ActiveRecord::Migration[4.2] def change create_table :v1_users do |t| t.string :email, unique: true, null: false t.string :password_digest, null: false t.timestamps null: false end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/db/migrate/20160522181712_create_composite_name_entities.rb
test/dummy/db/migrate/20160522181712_create_composite_name_entities.rb
class CreateCompositeNameEntities < ActiveRecord::Migration[4.2] def change create_table :composite_name_entities do |t| t.string :email t.string :password_digest t.timestamps null: false end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/guest_protected_controller_test.rb
test/dummy/test/controllers/guest_protected_controller_test.rb
require 'test_helper' class GuestProtectedControllerTest < ActionController::TestCase def setup @token = Knock::AuthToken.new(payload: { sub: "1" }).token end def authenticate token: @token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}" end test "responds with unauthorized when no token is ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/admin_protected_controller_test.rb
test/dummy/test/controllers/admin_protected_controller_test.rb
require 'test_helper' class AdminProtectedControllerTest < ActionController::TestCase def valid_auth @admin = admins(:one) @token = Knock::AuthToken.new(payload: { sub: @admin.id }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}" end def invalid_token_auth @token = 'eyJhbGciOiJIUzI...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/vendor_token_controller_test.rb
test/dummy/test/controllers/vendor_token_controller_test.rb
require 'test_helper' class VendorTokenControllerTest < ActionController::TestCase def setup @vendor = vendors(:one) end test "responds with 404 if user does not exist" do post :create, params: {auth: { email: 'wrong@example.net', password: '' }} assert_response :not_found end test "responds wi...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/protected_resources_controller_test.rb
test/dummy/test/controllers/protected_resources_controller_test.rb
require 'test_helper' class ProtectedResourcesControllerTest < ActionController::TestCase def setup @user = users(:one) @token = Knock::AuthToken.new(payload: { sub: @user.id }).token end def authenticate token: @token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}" end test "responds wi...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/admin_token_controller_test.rb
test/dummy/test/controllers/admin_token_controller_test.rb
require 'test_helper' class AdminTokenControllerTest < ActionController::TestCase def setup @admin = admins(:one) end test "responds with 404 if user does not exist" do post :create, params: {auth: { email: 'wrong@example.net', password: '' }} assert_response :not_found end test "responds with ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb
test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb
require 'test_helper' class CompositeNameEntityProtectedControllerTest < ActionController::TestCase def valid_auth @composite_name_entity = composite_name_entities(:one) @token = Knock::AuthToken.new(payload: { sub: @composite_name_entity.id }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/current_users_controller_test.rb
test/dummy/test/controllers/current_users_controller_test.rb
require 'test_helper' class CurrentUsersControllerTest < ActionController::TestCase setup do @user = users(:one) @token = Knock::AuthToken.new(payload: { sub: @user.id }).token end def authenticate token: @token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}" end test "responds with 404 ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/vendor_protected_controller_test.rb
test/dummy/test/controllers/vendor_protected_controller_test.rb
require 'test_helper' class VendorProtectedControllerTest < ActionController::TestCase def valid_auth @vendor = vendors(:one) @token = Knock::AuthToken.new(payload: { sub: @vendor.id }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}" end def invalid_token_auth @token = 'eyJhbGciOiJ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/custom_unauthorized_entity_controller_test.rb
test/dummy/test/controllers/custom_unauthorized_entity_controller_test.rb
require 'test_helper' class CustomUnauthorizedEntityControllerTest < ActionController::TestCase def valid_auth @user = users(:one) @token = Knock::AuthToken.new(payload: { sub: @user.id }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}" end def invalid_token_auth @token = 'eyJhbGci...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/controllers/v1/test_namespaced_controller_test.rb
test/dummy/test/controllers/v1/test_namespaced_controller_test.rb
require 'test_helper' # require 'timecop' module Knock class TestNamespacedControllerTest < ActionDispatch::IntegrationTest setup do @user = V1::User.first end test "allow namespaced models" do token = Knock::AuthToken.new(payload: { sub: @user.id }).token get v1_test_namespaced_index...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/models/user_test.rb
test/dummy/test/models/user_test.rb
require 'test_helper' class UserTest < ActiveSupport::TestCase end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/models/vendor_test.rb
test/dummy/test/models/vendor_test.rb
require 'test_helper' class VendorTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/test/models/admin_test.rb
test/dummy/test/models/admin_test.rb
require 'test_helper' class AdminTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/application.rb
test/dummy/config/application.rb
require File.expand_path("../boot", __FILE__) require "rails" require "active_model/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "action_cable/engine" require "sprockets/railtie" Bundler.require(*Rails.groups) requir...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/environment.rb
test/dummy/config/environment.rb
# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize!
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/routes.rb
test/dummy/config/routes.rb
Rails.application.routes.draw do post 'admin_token' => 'admin_token#create' post 'vendor_token' => 'vendor_token#create' resource :current_user resources :admin_protected resources :composite_name_entity_protected resources :custom_unauthorized_entity resources :guest_protected resources :protected_re...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/boot.rb
test/dummy/config/boot.rb
# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/filter_parameter_logging.rb
test/dummy/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/session_store.rb
test/dummy/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_dummy_session'
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/wrap_parameters.rb
test/dummy/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters f...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/knock.rb
test/dummy/config/initializers/knock.rb
Knock.setup do |config| config.token_signature_algorithm = 'HS256' config.token_secret_signature_key = -> { Rails.application.secret_key_base } config.token_public_key = nil config.token_audience = nil config.not_found_exception_class_name = 'ActiveRecord::RecordNotFound' end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/inflections.rb
test/dummy/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflec...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/cookies_serializer.rb
test/dummy/config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/assets.rb
test/dummy/config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/backtrace_silencers.rb
test/dummy/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/initializers/mime_types.rb
test/dummy/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/environments/test.rb
test/dummy/config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/environments/development.rb
test/dummy/config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/dummy/config/environments/production.rb
test/dummy/config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/test/unit/knock/authenticable/getter_name_test.rb
test/unit/knock/authenticable/getter_name_test.rb
require "test_helper" module Knock module Authenticable class GetterNameTest < ActiveSupport::TestCase test "check simple model names" do getter_name = GetterName.new("Test").cleared assert_equal getter_name, "current_test" end test "check pascal cased names" do getter_...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock.rb
lib/knock.rb
require "knock/engine" module Knock # How long before a token is expired. If nil is provided, # token will last forever. mattr_accessor :token_lifetime self.token_lifetime = 1.day # Configure the audience claim to identify the recipients that the token # is intended for. mattr_accessor :token_audience ...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock/version.rb
lib/knock/version.rb
# frozen_string_literal: true module Knock class Version VERSION = "2.2.0" end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock/authenticable.rb
lib/knock/authenticable.rb
# frozen_string_literal: true module Knock # Include this module in your controller to enable authentication # for your endpoint. # # e.g. # Calling `authenticate_user` will try to find a valid `User` based on # the token payload. module Authenticable def authenticate_for(entity_class) getter_n...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock/tokenizable.rb
lib/knock/tokenizable.rb
# frozen_string_literal: true module Knock # Include this module in your entity class (e.g. User) # for token serialization and deserialization. module Tokenizable def self.included(base) base.extends ClassMethods end module ClassMethods def from_token_payload(payload) find(payloa...
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock/engine.rb
lib/knock/engine.rb
module Knock class Engine < ::Rails::Engine paths.add "lib", eager_load: true isolate_namespace Knock end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/lib/knock/authenticable/getter_name.rb
lib/knock/authenticable/getter_name.rb
module Knock module Authenticable class GetterName attr_reader :entity_class def initialize(entity_class) @entity_class = entity_class end def cleared "current_#{entity_class.to_s.gsub('::', '').underscore}" end end end end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
nsarno/knock
https://github.com/nsarno/knock/blob/8e8b3e8d29eccb83a83ea2449e006250f025632a/config/routes.rb
config/routes.rb
Knock::Engine.routes.draw do post 'auth_token' => 'auth_token#create' end
ruby
MIT
8e8b3e8d29eccb83a83ea2449e006250f025632a
2026-01-04T15:58:43.752763Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/profile_one.rb
repository/benchmarks/profile_one.rb
# frozen_string_literal: true require_relative 'setup' require_relative 'seed' require 'hotch' Hotch() do COUNT.times do |i| user_repo[i + 1] end end
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/setup.rb
repository/benchmarks/setup.rb
# frozen_string_literal: true require 'bundler' Bundler.require require 'benchmark/ips' require 'sequel' require 'rom-sql' require 'rom-repository' require 'active_record' require 'logger' require 'hotch' begin require 'byebug' rescue LoadError # ignore end require_relative 'gc_suite' def benchmark(title) pu...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/seed.rb
repository/benchmarks/seed.rb
# frozen_string_literal: true USER_SEED = COUNT.times.map { |i| { id: i + 1, name: "User #{i + 1}", email: "email_#{i}@domain.com", age: i * 10 } } TASK_SEED = USER_SEED.map { |user| 3.times.map do |i| { user_id: user[:id], title: "Task #{i + 1}" } end }.flatten def seed hr puts "SEEDING #...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/basic.rb
repository/benchmarks/basic.rb
# frozen_string_literal: true require_relative 'setup' benchmark('creating a user') do |x| x.report('rom-repository') do user_repo.create(name: 'Jane', email: 'jane@doe.org', age: 21) end x.report('rom-repository with a changeset') do changeset = user_repo.users.changeset(:create, name: 'Jane', email: ...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/gc_suite.rb
repository/benchmarks/gc_suite.rb
# frozen_string_literal: true # Enable and start GC before each job run. Disable GC afterwards. # # Inspired by https://www.omniref.com/ruby/2.2.1/symbols/Benchmark/bm?#annotation=4095926&line=182 class GCSuite def warming(*) run_gc end def running(*) run_gc end def warmup_stats(*); end def add_...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/benchmarks/command_vs_changeset.rb
repository/benchmarks/command_vs_changeset.rb
# frozen_string_literal: true require_relative 'setup' benchmark('create command vs changeset') do |x| x.report('command') do users.command(:create).call(name: 'Jane', email: 'jane@doe.org', age: 21) end x.report('changeset') do users.changeset(:create, name: 'Jane', email: 'jane@doe.org', age: 21).com...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/spec_helper.rb
repository/spec/spec_helper.rb
# frozen_string_literal: true require 'pathname' require 'tempfile' SPEC_ROOT = Pathname(__FILE__).dirname if ENV['COVERAGE'] == 'true' require 'codacy-coverage' Codacy::Reporter.start(partial: true) end require 'warning' Warning.ignore(/sequel/) Warning.ignore(/mysql2/) Warning.ignore(/rspec-core/) Warning.ig...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/support/mapper_registry.rb
repository/spec/support/mapper_registry.rb
# frozen_string_literal: true module MapperRegistry def mapper_for(relation) relation.mapper end end
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/dependency_injection_spec.rb
repository/spec/integration/dependency_injection_spec.rb
# frozen_string_literal: true RSpec.describe 'Repository with additional dependencies injected' do let(:configuration) { ROM::Configuration.new(default: [:sql, DB_URI], memory: [:memory]) } let(:rom) { ROM.container(configuration) } describe 'keyword constructor params' do describe 'direct injection ...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/combine_spec.rb
repository/spec/integration/combine_spec.rb
# frozen_string_literal: true # frozen_string_literals: true require_relative '../shared/database' require_relative '../shared/relations' require_relative '../shared/seeds' RSpec.describe ROM::Relation, '#combine' do include_context 'database' include_context 'relations' include_context 'seeds' subject(:com...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/repository_spec.rb
repository/spec/integration/repository_spec.rb
# frozen_string_literal: true RSpec.describe 'ROM repository' do include_context 'database' include_context 'relations' include_context 'repo' include_context 'structs' include_context 'seeds' it 'loads a single relation' do expect(repo.all_users.to_a).to match_array([jane, joe]) end it 'can be u...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/root_repository_spec.rb
repository/spec/integration/root_repository_spec.rb
# frozen_string_literal: true RSpec.describe ROM::Repository::Root do subject(:repo) do klass.new(rom) end let(:klass) do Class.new(ROM::Repository[:users]) end include_context 'database' include_context 'relations' describe '.[]' do it 'creates a pre-configured root repo class' do k...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/command_macros_spec.rb
repository/spec/integration/command_macros_spec.rb
# frozen_string_literal: true require 'rom-changeset' RSpec.describe ROM::Repository, '.command' do include_context 'database' include_context 'relations' it 'allows configuring a create command' do repo = Class.new(ROM::Repository[:users]) do commands :create end.new(rom) user = repo.create...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/multi_adapter_spec.rb
repository/spec/integration/multi_adapter_spec.rb
# frozen_string_literal: true RSpec.describe 'Repository with multi-adapters configuration' do let(:configuration) { ROM::Configuration.new(default: [:sql, DB_URI], memory: [:memory]) } let(:sql_conn) { configuration.gateways[:default].connection } let(:rom) { ROM.container(configuration) } let(:users...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/plugin_spec.rb
repository/spec/integration/plugin_spec.rb
# frozen_string_literal: true RSpec.describe 'repository plugin' do include_context 'database' include_context 'relations' include_context 'seeds' include_context 'repo' let(:nullify_plugin) do Module.new do def self.apply(target, **) target.prepend(self) end def prepare_relat...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/integration/typed_structs_spec.rb
repository/spec/integration/typed_structs_spec.rb
# frozen_string_literal: true RSpec.describe 'ROM repository with typed structs' do subject(:repo) do Class.new(ROM::Repository[:books]) { commands :create }.new(rom) end include_context 'database' include_context 'seeds' context 'typed projections' do before do configuration.relation(:books)...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/unit/session_spec.rb
repository/spec/unit/session_spec.rb
# frozen_string_literal: true RSpec.describe ROM::Session do subject(:session) do ROM::Session.new(repo) end let(:repo) { instance_double(ROM::Repository) } let(:create_changeset) { instance_double(ROM::Changeset::Create, relation: relation) } let(:delete_changeset) { instance_double(ROM::Changeset::Del...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false
rom-rb/rom
https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/unit/repository/inspect_spec.rb
repository/spec/unit/repository/inspect_spec.rb
# frozen_string_literal: true RSpec.describe ROM::Repository, '#inspect' do subject(:repo) do Class.new(ROM::Repository) do def self.to_s 'UserRepo' end end.new(rom) end include_context 'database' include_context 'relations' specify do expect(repo.inspect).to eql('#<UserRepo...
ruby
MIT
ac5d6618f36b0c48525fa48b7f6c774e0d1d2860
2026-01-04T15:58:11.374901Z
false