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 |
|---|---|---|---|---|---|---|---|---|
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/schema.rb | examples/meta/rails-erd/schema.rb | ActiveRecord::Schema.define do
create_table "domains", :force => true do |t|
t.string :name
end
create_table "entities", :force => true do |t|
t.references :domain, :null => false
t.string :name, :null => false
t.boolean :specialized
end
create_table "relationships", :force => true do |t|
... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/relationship.rb | examples/meta/rails-erd/models/relationship.rb | class Relationship < ActiveRecord::Base
belongs_to :domain
belongs_to :source_entity, :class_name => "Entity"
belongs_to :destination_entity, :class_name => "Entity"
has_one :cardinality
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/cardinality.rb | examples/meta/rails-erd/models/cardinality.rb | class Cardinality < ActiveRecord::Base
belongs_to :relationship
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/specialization.rb | examples/meta/rails-erd/models/specialization.rb | class Specialization < ActiveRecord::Base
belongs_to :domain
belongs_to :generalized_entity, :class_name => "Entity"
belongs_to :specialized_entity, :class_name => "Entity"
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/entity.rb | examples/meta/rails-erd/models/entity.rb | class Entity < ActiveRecord::Base
belongs_to :domain
has_many :properties
has_many :outgoing_relationships, :class_name => "Relationship", :foreign_key => :source_entity_id
has_many :incoming_relationships, :class_name => "Relationship", :foreign_key => :destination_entity_id
validates_presence_of :properties... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/domain.rb | examples/meta/rails-erd/models/domain.rb | class Domain < ActiveRecord::Base
has_many :entities
has_many :relationships
has_many :specializations
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/examples/meta/rails-erd/models/property.rb | examples/meta/rails-erd/models/property.rb | class Property < ActiveRecord::Base
belongs_to :entity
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd.rb | lib/rails_erd.rb | require "active_support/ordered_options"
require "rails_erd/railtie" if defined? Rails
require "rails_erd/config"
# Welcome to the API documentation of Rails ERD. If you wish to extend or
# customise the output that is generated by Rails ERD, you have come to the
# right place.
#
# == Creating custom output
#
# If you... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails-erd.rb | lib/rails-erd.rb | require "rails_erd"
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/diagram.rb | lib/rails_erd/diagram.rb | require "rails_erd/domain"
module RailsERD
# This class is an abstract class that will process a domain model and
# allows easy creation of diagrams. To implement a new diagram type, derive
# from this class and override +process_entity+, +process_relationship+,
# and (optionally) +save+.
#
# As an example... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/version.rb | lib/rails_erd/version.rb | module RailsERD
VERSION = "1.7.2"
BANNER = "RailsERD #{VERSION}"
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain.rb | lib/rails_erd/domain.rb | require "rails_erd"
require "rails_erd/domain/attribute"
require "rails_erd/domain/entity"
require "rails_erd/domain/relationship"
require "rails_erd/domain/specialization"
module RailsERD
# The domain describes your Rails domain model. This class is the starting
# point to get information about your models.
#
... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/railtie.rb | lib/rails_erd/railtie.rb | module RailsERD
# Rails ERD integrates with Rails 3. If you add it to your +Gemfile+, you
# will gain a Rake task called +erd+, which you can use to generate diagrams
# of your domain model.
class Railtie < Rails::Railtie
rake_tasks do
load "rails_erd/tasks.rake"
end
end
end
| ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/cli.rb | lib/rails_erd/cli.rb | require "rails_erd"
require "choice"
Choice.options do
separator ""
separator "Diagram options:"
option :generator do
long "--generator=Generator"
desc "Generator to use (graphviz or mermaid). Defaults to graphviz."
end
option :title do
long "--title=TITLE"
desc "Replace default diagram tit... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/config.rb | lib/rails_erd/config.rb | require "yaml"
module RailsERD
class Config
USER_WIDE_CONFIG_FILE = File.expand_path(".erdconfig", ENV["HOME"])
CURRENT_CONFIG_FILE = File.expand_path(".erdconfig", Dir.pwd)
attr_reader :options
def self.load(extra_config_file=nil)
new.load extra_config_file
end
def initialize
... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/diagram/mermaid.rb | lib/rails_erd/diagram/mermaid.rb | # encoding: utf-8
require "rails_erd/diagram"
require "erb"
module RailsERD
class Diagram
class Mermaid < Diagram
attr_accessor :graph
setup do
self.graph = ["classDiagram"]
# hard code to RL to make it easier to view diagrams from GitHub
self.graph << "\tdirection RL"
... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/diagram/graphviz.rb | lib/rails_erd/diagram/graphviz.rb | # encoding: utf-8
require "rails_erd/diagram"
require "graphviz"
require "erb"
# Fix bad RegEx test in Ruby-Graphviz.
GraphViz::Types::LblString.class_eval do
def output # @private :nodoc:
if /^<.*>$/m =~ @data
@data
else
@data.to_s.inspect.gsub("\\\\", "\\")
end
end
alias_method :to_gv, ... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain/relationship.rb | lib/rails_erd/domain/relationship.rb | require "set"
require "active_support/core_ext/module/delegation"
require "rails_erd/domain/relationship/cardinality"
module RailsERD
class Domain
# Describes a relationship between two entities. A relationship is detected
# based on Active Record associations. One relationship may represent more
# than ... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain/specialization.rb | lib/rails_erd/domain/specialization.rb | module RailsERD
class Domain
# Describes the specialization of an entity. Specialized entities correspond
# to inheritance or polymorphism. In Rails, specialization is referred to
# as single table inheritance, while generalization is referred to as
# polymorphism or abstract classes.
class Specia... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain/entity.rb | lib/rails_erd/domain/entity.rb | module RailsERD
class Domain
# Entities represent your Active Record models. Entities may be connected
# to other entities.
class Entity
class << self
def from_models(domain, models) # @private :nodoc:
(concrete_from_models(domain, models) + abstract_from_models(domain, models)).so... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain/attribute.rb | lib/rails_erd/domain/attribute.rb | # encoding: utf-8
#--
module RailsERD
class Domain
# Describes an entity's attribute. Attributes correspond directly to
# database columns.
class Attribute
TIMESTAMP_NAMES = %w{created_at created_on updated_at updated_on} # @private :nodoc:
class << self
def from_model(domain, model)... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/domain/relationship/cardinality.rb | lib/rails_erd/domain/relationship/cardinality.rb | module RailsERD
class Domain
class Relationship
class Cardinality
extend Inspectable
inspection_attributes :source_range, :destination_range
N = Infinity = 1.0/0 # And beyond.
CLASSES = {
[1, 1] => :one_to_one,
[1, N] => :one_to_many,
[N, 1] =>... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
voormedia/rails-erd | https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/generators/erd/install_generator.rb | lib/generators/erd/install_generator.rb | module Erd
module Generators
class InstallGenerator < Rails::Generators::Base
desc "Copy rails-erd rakefiles for automatic graphic generation"
source_root File.expand_path('../templates', __FILE__)
# copy rake tasks
def copy_tasks
template "auto_generate_diagram.rake", "lib/tasks/... | ruby | MIT | 7c66258b6818c47b4d878c2ad7ff6decebdf834a | 2026-01-04T15:47:24.368951Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/scripts/scripty.rb | scripts/scripty.rb | # frozen_string_literal: true
require 'pathname'
# A few functions useful in scripts
module Scripty
ROOT = Pathname.new(`git rev-parse --show-toplevel`.chomp)
module_function
# Ask for confirmation and do
def confirm_to(action)
print %(Do you want to #{action}? (y/n)> )
yield if gets.chomp.start_wit... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/scripts/update_top100.rb | scripts/update_top100.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'net/http'
require_relative 'scripty'
include Scripty # rubocop:disable Style/MixinUsage
USERS_URL_FMT = 'https://api.github.com/repos/ddnexus/pagy/contributors?page=%s'
COMMITS_URL_FMT = 'https://github.com/ddnexus/pagy/commits?author=%s'
IM... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/scripts/update_retype_head.rb | scripts/update_retype_head.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative 'scripty'
include Scripty # rubocop:disable Style/MixinUsage
# Prompt for the old version tag
require_relative '../gem/lib/pagy'
# Insert the latest ai-widget in the retype head
replace_section_in_file('docs/_includes/head.html', 'ai_widget', <<~HTM... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/scripts/bump.rb | scripts/bump.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
# Update the files related to version changes
require 'tempfile'
require_relative 'scripty'
require_relative '../gem/apps/index'
include Scripty # rubocop:disable Style/MixinUsage
# Abort if the working tree is dirty
abort('Working tree dirty!') unless `git status --... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
$LOAD_PATH.unshift __dir__
$LOAD_PATH.unshift File.expand_path('../gem/lib', __dir__)
require 'simplecov' unless ENV['SKIP_COVERAGE']
require 'pagy'
require 'minitest'
require 'minitest/spec'
Minitest.load :holdify
require 'minitest/autorun'
require 'minitest/mock'
require 'helpers/mi... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy_test.rb | test/pagy_test.rb | # frozen_string_literal: true
require_relative 'test_helper'
describe Pagy do
it 'has version' do
_(Pagy::VERSION).wont_be_nil
end
it 'has root' do
_(Pagy::ROOT).must_be_kind_of Pathname
end
it 'has default' do
_(Pagy::DEFAULT).must_be_kind_of Hash
_(Pagy::DEFAULT[:limit]).must_equal 20
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/mocks/app.rb | test/mocks/app.rb | # frozen_string_literal: true
require 'active_support/core_ext/hash/indifferent_access'
require 'groupdate'
require 'rack'
require 'uri'
class MockApp
include Pagy::Method
public :pagy # make public for testing
attr_reader :request, :params
# Initializer for a Rack::Request with defaults for test
def ini... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/mocks/searchkick.rb | test/mocks/searchkick.rb | # frozen_string_literal: true
require 'pagy/classes/offset/search'
module MockSearchkick
RESULTS = { 'a' => ('a-1'..'a-1000').to_a,
'b' => ('b-1'..'b-1000').to_a }.freeze
class Results
attr_reader :options
def initialize(query, options = {}, &block)
query = 'a' if query == '*' # t... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/mocks/meilisearch.rb | test/mocks/meilisearch.rb | # frozen_string_literal: true
require 'pagy/classes/offset/search'
module MockMeilisearch
RESULTS = { 'a' => ('a-1'..'a-1000').to_a,
'b' => ('b-1'..'b-1000').to_a }.freeze
class Results
attr_reader :options, :term
def initialize(term, options = {})
@term = term
@options = op... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/mocks/elasticsearch_rails.rb | test/mocks/elasticsearch_rails.rb | # frozen_string_literal: true
require 'pagy/classes/offset/search'
module MockElasticsearchRails
RESULTS = { 'a' => ('a-1'..'a-1000').to_a,
'b' => ('b-1'..'b-1000').to_a }.freeze
# Simulates a DSL object that responds to to_hash
class DslSearch
def initialize(hash)
@hash = hash
end
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/helpers/url_assertions.rb | test/helpers/url_assertions.rb | # frozen_string_literal: true
require 'uri'
module Minitest
module Assertions
def assert_url_equal(expected, actual, msg = nil)
normalize = lambda do |url_str|
u = URI(url_str)
if u.query
sorted = URI.decode_www_form(u.query).sort
u.query = URI.encode_www_form(sorted)
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/helpers/test_case.rb | test/helpers/test_case.rb | # frozen_string_literal: true
require 'minitest/autorun'
class Pagy
class TestCase < Minitest::Spec
def teardown
Pagy::I18n.locale = 'en' # reset to default
super
end
end
end
Minitest::Spec.register_spec_type(/.*/, Pagy::TestCase)
| ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/helpers/minitest_backtraces.rb | test/helpers/minitest_backtraces.rb | # frozen_string_literal: true
# /usr/local/lib/ruby/gems/3.4.0/gems/minitest-5.25.4/lib/minitest.rb
module Minitest
class UnexpectedError
module AvoidBacktraceMangling
def message # :nodoc:
bt = Minitest.filter_backtrace(backtrace)
.map { |p| p.sub(%r{^#{Dir.pwd}/}, '') }
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/helpers/models.rb | test/helpers/models.rb | # frozen_string_literal: true
require 'active_record'
require 'sequel'
require 'sqlite3'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
Time.zone = 'Etc/UTC'
Sequel.default_timezone = 'Etc/UTC'
DB = Sequel.connect(adapter: 'sqlite', database: ':memory:')
ActiveRecord::Migration.su... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/version_test.rb | test/pagy/version_test.rb | # frozen_string_literal: true
require_relative '../test_helper'
# Load PagyApps::INDEX
# Using Pagy::ROOT to locate the file robustly regardless of test file location
require Pagy::ROOT.join('apps/index').to_s
describe 'Version match' do
let(:version) { Pagy::VERSION }
let(:major) { version.split('.')[0] }... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/cli_test.rb | test/pagy/cli_test.rb | # frozen_string_literal: true
require_relative '../test_helper'
require 'pagy/cli'
describe Pagy::CLI do
let(:cli) { Pagy::CLI.new }
# Stub side-effects: setup_gems
before do
cli.define_singleton_method(:setup_gems) { |_| true }
end
describe 'Options' do
it 'shows help with no args' do
# Cap... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/searcher_test.rb | test/pagy/modules/searcher_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/searcher'
describe Pagy::Searcher do
let(:searcher) { Pagy::Searcher }
# Mock Request object
let(:mock_request_class) do
Struct.new(:page, :limit) do
def resolve_page = page
def resolve_limit = limit
end
end
let(... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/b64_test.rb | test/pagy/modules/b64_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/b64'
describe Pagy::B64 do
let(:b64) { Pagy::B64 }
describe 'standard methods' do
it 'encodes and decodes simple strings' do
str = 'Simple String'
# 'm0' should not add newlines
encoded = b64.encode(str)
_(encod... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/console_test.rb | test/pagy/modules/console_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/console'
# Create a mock class to simulate including the Pagy::Console module
class MockContext
include Pagy::Console
end
describe 'Pagy::Console' do
before do
@mock_context = MockContext.new
end
describe 'params' do
it 'retur... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/abilities/shiftable_test.rb | test/pagy/modules/abilities/shiftable_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Offset::Shiftable do
let(:shiftable_class) do
Class.new do
include Pagy::Offset::Shiftable
attr_accessor :page, :last, :previous, :next
def run
assign_previous_and_next
end
end
end
let(:mock) { shiftabl... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/abilities/linkable_test.rb | test/pagy/modules/abilities/linkable_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Linkable do
describe 'QueryUtils' do
let(:utils) { Pagy::Linkable::QueryUtils }
it 'escapes strings' do
_(utils.escape('a b')).must_equal 'a+b'
_(utils.escape('/?&')).must_equal '%2F%3F%26'
end
it 'builds simple queries... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/abilities/countable_test.rb | test/pagy/modules/abilities/countable_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/abilities/countable'
describe Pagy::Countable do
let(:countable) { Pagy::Countable }
it 'counts arrays using size' do
_(countable.get_count([1, 2, 3, 4], {})).must_equal 4
end
describe 'Sequel Dataset Logic' do
# Use the exist... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/abilities/configurable_test.rb | test/pagy/modules/abilities/configurable_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'fileutils'
require 'pathname'
require 'i18n'
require 'pagy/toolbox/helpers/info_tag' # Required for the integration test
describe Pagy::Configurable do
describe 'sync_javascript' do
let(:destination) { Dir.mktmpdir }
let(:all_files) { %w[pagy.mjs ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/abilities/rangeable_test.rb | test/pagy/modules/abilities/rangeable_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Offset::Rangeable do
# Use an anonymous class to test the mixin without namespace pollution
let(:rangeable_class) do
Class.new do
include Pagy::Offset::Rangeable
attr_reader :options, :last, :page, :empty_vars_assigned
def ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/locales_test.rb | test/pagy/modules/i18n/locales_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'yaml'
describe 'locales' do
# Define the expected keys for each pluralization rule
let(:counts) do
{ 'Arabic' => %w[zero one two few many other],
'EastSlavic' => %w[one few many other],
'OneOther' => %w[one other],
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/i18n_test.rb | test/pagy/modules/i18n/i18n_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'fileutils'
# Mock P11n class for testing custom dictionaries
module Pagy::I18n::P11n # rubocop:disable Style/ClassAndModuleChildren
module TestRule
def self.plural_for(count)
case count
when 0 then 'zero'
when 1 then 'one'
else... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/east_slavic_test.rb | test/pagy/modules/i18n/p11n/east_slavic_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::EastSlavic do
let(:rule) { Pagy::I18n::P11n::EastSlavic }
it 'returns :one for numbers ending in 1 (except 11)' do
[1, 21, 31, 41, 101, 1001].each do |n|
_(rule.plural_for(n)).must_equal :one, "Failed for #{n}"
end
end... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/polish_test.rb | test/pagy/modules/i18n/p11n/polish_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::Polish do
let(:rule) { Pagy::I18n::P11n::Polish }
it 'returns :one for 1' do
_(rule.plural_for(1)).must_equal :one
end
it 'returns :few for 2-4 (excluding teens 12-14)' do
# 2, 3, 4, 22, 23, 24, 102...
[2, 3, 4, 22, 2... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/west_slavic_test.rb | test/pagy/modules/i18n/p11n/west_slavic_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::WestSlavic do
let(:rule) { Pagy::I18n::P11n::WestSlavic }
it 'returns :one for 1' do
_(rule.plural_for(1)).must_equal :one
end
it 'returns :few for 2, 3, 4' do
[2, 3, 4].each do |n|
_(rule.plural_for(n)).must_equal ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/arabic_test.rb | test/pagy/modules/i18n/p11n/arabic_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::Arabic do
let(:rule) { Pagy::I18n::P11n::Arabic }
it 'returns :zero for 0' do
_(rule.plural_for(0)).must_equal :zero
end
it 'returns :one for 1' do
_(rule.plural_for(1)).must_equal :one
end
it 'returns :two for 2' do... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/one_upto_two_other_test.rb | test/pagy/modules/i18n/p11n/one_upto_two_other_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::OneUptoTwoOther do
let(:rule) { Pagy::I18n::P11n::OneUptoTwoOther }
it 'returns :one for [0, 2)' do
[0, 0.5, 1, 1.99].each do |n|
_(rule.plural_for(n)).must_equal :one, "Failed for #{n}"
end
end
it 'returns :other f... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/one_other_test.rb | test/pagy/modules/i18n/p11n/one_other_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::OneOther do
let(:rule) { Pagy::I18n::P11n::OneOther }
it 'returns :one for 1' do
_(rule.plural_for(1)).must_equal :one
end
it 'returns :other for 0' do
_(rule.plural_for(0)).must_equal :other
end
it 'returns :other f... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/modules/i18n/p11n/other_test.rb | test/pagy/modules/i18n/p11n/other_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::I18n::P11n::Other do
let(:rule) { Pagy::I18n::P11n::Other }
it 'always returns :other' do
[0, 1, 2, 5, 10, 100, -1, 1.5].each do |n|
_(rule.plural_for(n)).must_equal :other
end
end
end
| ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/info_tag_test.rb | test/pagy/toolbox/helpers/info_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/info_tag'
describe 'Pagy#info_tag' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :count, :page, :last, :in, :from, :to
def initialize(vars = {})
@count = vars[:count]
@page = vars[:page]
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/anchor_tags_test.rb | test/pagy/toolbox/helpers/anchor_tags_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/anchor_tags'
describe 'Pagy anchor_tags' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :previous, :next
# Renamed 'next' argument to 'next_page' to avoid keyword collision
def initialize(previous: nil,... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/input_nav_js_test.rb | test/pagy/toolbox/helpers/input_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/input_nav_js'
describe 'Pagy#input_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :last
def initialize(page: 1, last: 10)
@page = page
@last = last
end
# Mock depen... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/page_url_test.rb | test/pagy/toolbox/helpers/page_url_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/page_url'
describe 'Pagy#page_url' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :previous, :next, :last
def initialize(vars = {})
@page = vars[:page]
@previous = vars[:previous]
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/limit_tag_js_test.rb | test/pagy/toolbox/helpers/limit_tag_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/limit_tag_js'
describe 'Pagy#limit_tag_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :limit, :from, :options
def initialize(limit: 20, from: 1, options: {})
@limit = limit
@from = fr... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/urls_hash_test.rb | test/pagy/toolbox/helpers/urls_hash_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/urls_hash'
describe 'Pagy#urls_hash' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :previous, :next, :count, :last
def initialize(vars = {})
@previous = vars[:previous]
@next = vars[:next... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/series_nav_js_test.rb | test/pagy/toolbox/helpers/series_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/series_nav_js'
describe 'Pagy#series_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_reader :wrap_args
# Mock dependencies
def a_lambda(**)
->(page, text = nil, **_opts) { "LINK(#{page},#{text})" ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/data_hash_test.rb | test/pagy/toolbox/helpers/data_hash_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/data_hash'
describe 'Pagy#data_hash' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :count, :page, :limit, :last, :in, :from, :to, :previous, :next, :options
def initialize(vars = {})
@options = vars... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/headers_hash_test.rb | test/pagy/toolbox/helpers/headers_hash_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/headers_hash'
describe 'Pagy#headers_hash' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :limit, :last, :count, :options
def initialize(vars = {})
@options = vars[:options] || {}
@page... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/loader_test.rb | test/pagy/toolbox/helpers/loader_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Loader do
let(:loader) { Pagy::Loader }
it 'defines public methods' do
# From paths[:public] in source
public_methods = %i[page_url data_hash headers_hash urls_hash next_tag previous_tag
input_nav_js info_tag limit... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/series_nav_test.rb | test/pagy/toolbox/helpers/series_nav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/series_nav'
describe 'Pagy#series_nav' do
let(:pagy_class) do
Class.new(Pagy) do
# Mock dependencies
def series(**)
[1, '2', :gap]
end
def previous_tag(_lambda)
# MUST return a mutable stri... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/data_pagy_attributes_test.rb | test/pagy/toolbox/helpers/support/data_pagy_attributes_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/data_pagy_attribute'
require 'json'
# Try to load Oj for the test if available
begin
require 'oj'
rescue LoadError
# Proceed without Oj
end
describe 'Pagy#data_pagy_attribute' do
let(:pagy_class) do
Class.new(Pagy) do... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/wrap_series_nav_test.rb | test/pagy/toolbox/helpers/support/wrap_series_nav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/wrap_series_nav'
describe 'Pagy#wrap_series_nav' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :update
def initialize(keynav: false)
@keynav = keynav
@update = ['update_info']
e... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/wrap_series_nav_is_test.rb | test/pagy/toolbox/helpers/support/wrap_series_nav_is_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/wrap_series_nav_js'
describe 'Pagy#wrap_series_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :options, :update
def initialize(options = {})
@options = options
@update = ['upda... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/nav_aria_label_attribute_test.rb | test/pagy/toolbox/helpers/support/nav_aria_label_attribute_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/nav_aria_label_attribute'
describe 'Pagy#nav_aria_label_attribute' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :last
def initialize(last: 10)
@last = last
end
public :nav_aria_... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/wrap_input_nav_js_test.rb | test/pagy/toolbox/helpers/support/wrap_input_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/wrap_input_nav_js'
describe 'Pagy#wrap_input_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :update
def initialize(keynav: false)
@keynav = keynav
@update = ['update_info']
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/a_lambda_test.rb | test/pagy/toolbox/helpers/support/a_lambda_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/a_lambda'
describe 'Pagy#a_lambda' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :previous, :next
def initialize(options = {})
@options = options
@previous = nil
@next = ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/support/series_test.rb | test/pagy/toolbox/helpers/support/series_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/support/series'
describe 'Pagy#series' do
# Mock class to expose series logic
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :last
def initialize(page: 1, last: 1, **options)
@page = page
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bootstrap/input_nav_js_test.rb | test/pagy/toolbox/helpers/bootstrap/input_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bootstrap/input_nav_js'
describe 'Pagy#bootstrap_input_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :last
def initialize(page: 1, last: 10)
@page = page
@last = last
end... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bootstrap/series_nav_js_test.rb | test/pagy/toolbox/helpers/bootstrap/series_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bootstrap/series_nav_js'
describe 'Pagy#bootstrap_series_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_reader :wrap_args
# Mock dependencies
def a_lambda(**)
->(page, text = nil, classes: nil, *... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bootstrap/previous_next_html_test.rb | test/pagy/toolbox/helpers/bootstrap/previous_next_html_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bootstrap/previous_next_html'
describe 'Pagy#bootstrap_html_for' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :previous, :next
def initialize(previous: nil, next_page: nil)
@previous = previous
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bootstrap/series_nav_test.rb | test/pagy/toolbox/helpers/bootstrap/series_nav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bootstrap/series_nav'
describe 'Pagy#bootstrap_series_nav' do
let(:pagy_class) do
Class.new(Pagy) do
# Mock dependencies
def series(**)
[1, '2', :gap]
end
def a_lambda(**)
->(page, classes:... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bulma/input_nav_js_test.rb | test/pagy/toolbox/helpers/bulma/input_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bulma/input_nav_js'
describe 'Pagy#bulma_input_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :page, :last
def initialize(page: 1, last: 10)
@page = page
@last = last
end
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bulma/series_nav_js_test.rb | test/pagy/toolbox/helpers/bulma/series_nav_js_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bulma/series_nav_js'
describe 'Pagy#bulma_series_nav_js' do
let(:pagy_class) do
Class.new(Pagy) do
attr_reader :wrap_args
# Mock dependencies
def a_lambda(**)
->(page, text = nil, classes: nil, **_opts) ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bulma/previous_next_html_test.rb | test/pagy/toolbox/helpers/bulma/previous_next_html_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bulma/previous_next_html'
describe 'Pagy#bulma_html_for' do
let(:pagy_class) do
Class.new(Pagy) do
attr_accessor :previous, :next
def initialize(previous: nil, next_page: nil)
@previous = previous
@nex... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/helpers/bulma/series_nav_test.rb | test/pagy/toolbox/helpers/bulma/series_nav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/helpers/bulma/series_nav'
describe 'Pagy#bulma_series_nav' do
let(:pagy_class) do
Class.new(Pagy) do
# Mock dependencies
def series(**)
[1, '2', :gap]
end
def a_lambda(**)
->(page, text = nil, clas... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/meilisearch_test.rb | test/pagy/toolbox/paginators/meilisearch_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/paginators/meilisearch'
require 'mocks/app'
require 'mocks/meilisearch'
describe 'Pagy::MeilisearchPaginator' do
let(:app) { MockApp.new }
describe '#paginate' do
describe 'Active Mode (pagy_search)' do
it 'paginates with default... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/calendar_test.rb | test/pagy/toolbox/paginators/calendar_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/paginators/calendar'
require 'mocks/app'
describe 'Pagy::CalendarPaginator' do
let(:collection) { Event.all }
# Period covering the seeded events (2021-10-21 to 2023-11-13)
let(:period) { [Time.zone.local(2021, 10, 21), Time.zone.local(20... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/keyset_test.rb | test/pagy/toolbox/paginators/keyset_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
describe 'Pagy::KeysetPaginator' do
# We test via the public API provided by the App/Controller mixin (MockApp)
# which delegates to KeysetPaginator when the first argument is :keyset.
describe 'with ActiveRecord' do
let(:collection) {... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/offset_test.rb | test/pagy/toolbox/paginators/offset_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
describe Pagy::OffsetPaginator do
# We test via the public API provided by the App/Controller mixin (MockApp)
# which delegates to OffsetPaginator.
let(:collection) { (1..20).to_a }
describe 'with Array' do
it 'paginates array' do
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/method_test.rb | test/pagy/toolbox/paginators/method_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
describe 'Pagy::Method' do
let(:collection) { Pet.all }
describe '#pagy (Offset default)' do
it 'paginates with defaults' do
# MockApp defaults to params: { page: 3 }
app = MockApp.new
pagy, records = app.pagy(collectio... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/elasticsearch_rails_test.rb | test/pagy/toolbox/paginators/elasticsearch_rails_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/paginators/elasticsearch_rails'
require 'mocks/app'
require 'mocks/elasticsearch_rails'
describe 'Pagy::ElasticsearchRailsPaginator' do
let(:app) { MockApp.new }
describe '#paginate' do
describe 'Active Mode (pagy_search)' do
it ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/countish_test.rb | test/pagy/toolbox/paginators/countish_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
describe 'Pagy::CountishPaginator' do
let(:collection) { Pet.all }
let(:paginator) { Pagy::CountishPaginator }
describe 'with ActiveRecord' do
it 'paginates with defaults (recount)' do
# No page param -> Page 1, Count calculated ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/countless_test.rb | test/pagy/toolbox/paginators/countless_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
describe 'Pagy::CountlessPaginator' do
let(:collection) { Pet.all }
describe 'with ActiveRecord' do
it 'paginates with defaults' do
# MockApp default params: { page: 3 }. Rack converts 3 to "3".
# options[:page] becomes "3" (... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/keynav_test.rb | test/pagy/toolbox/paginators/keynav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'mocks/app'
require 'pagy/modules/b64'
describe 'Pagy::KeynavJsPaginator' do
let(:collection) { Pet.order(:id) }
it 'paginates with defaults (page 1)' do
app = MockApp.new(params: {})
pagy, records = app.pagy(:keynav_js, collection, limit: 10)
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/toolbox/paginators/searchkick_test.rb | test/pagy/toolbox/paginators/searchkick_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/toolbox/paginators/searchkick'
require 'mocks/app'
require 'mocks/searchkick'
describe 'Pagy::SearchkickPaginator' do
let(:app) { MockApp.new }
describe '#paginate' do
describe 'Active Mode (pagy_search)' do
it 'paginates with defaults' ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/request_test.rb | test/pagy/classes/request_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/classes/request'
describe Pagy::Request do
let(:default_options) { { page_key: 'page', limit_key: 'limit' } }
describe 'initialization' do
it 'handles Hash request' do
req_hash = { base_url: 'http://example.com', path: '/foo', params: { ... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/exceptions_test.rb | test/pagy/classes/exceptions_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::OptionError do
it 'inherits from ArgumentError' do
_(Pagy::OptionError.superclass).must_equal ArgumentError
end
it 'initializes with pagy, option, description, and value' do
pagy_mock = Object.new
error = Pagy::OptionError.new(pagy_... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/keyset/keyset_test.rb | test/pagy/classes/keyset/keyset_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/b64'
describe "Pagy Keyset" do
[Pet, PetSequel].each do |model|
describe "Pagy Keyset with #{model}" do
describe 'initialize' do
it 'raises TypeError on wrong set type' do
_ { Pagy::Keyset.new(10) }.must_raise Type... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/keyset/keynav_test.rb | test/pagy/classes/keyset/keynav_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/modules/b64'
describe "Pagy::Keyset::Keynav" do
[Pet, PetSequel].each do |model|
describe "with #{model}" do
let(:ordered_set) { model.order(:id) }
describe 'initialization' do
it 'handles empty collection' do
# Key... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/keyset/adapters/active_record_test.rb | test/pagy/classes/keyset/adapters/active_record_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/classes/keyset/adapters/active_record'
describe Pagy::Keyset::Adapters::ActiveRecord do
# Host class to mix in the adapter
let(:adapter_host) do
Class.new do
include Pagy::Keyset::Adapters::ActiveRecord
attr_accessor :set, :keyset
... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/keyset/adapters/sequel_test.rb | test/pagy/classes/keyset/adapters/sequel_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'pagy/classes/keyset/adapters/sequel'
describe Pagy::Keyset::Adapters::Sequel do
# Host class to mix in the adapter
let(:adapter_host) do
Class.new do
include Pagy::Keyset::Adapters::Sequel
attr_accessor :set, :keyset
def initiali... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/offset/offset_test.rb | test/pagy/classes/offset/offset_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Offset do
let(:pagy_class) { Pagy::Offset }
describe 'initialization' do
it 'initializes with defaults' do
pagy = pagy_class.new(count: 100)
_(pagy.page).must_equal 1
_(pagy.limit).must_equal 20
_(pagy.last).must_equal... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
ddnexus/pagy | https://github.com/ddnexus/pagy/blob/fe1f35863e3bad60ef8731e298c7cb38af4e7af6/test/pagy/classes/offset/search_test.rb | test/pagy/classes/offset/search_test.rb | # frozen_string_literal: true
require 'test_helper'
describe Pagy::Search do
describe 'Arguments' do
it 'collects method calls via method_missing' do
args = Pagy::Search::Arguments.new
args.foo
args.bar(1, 2)
# Array#push appends arguments
# .foo -> method_missing(:foo) -> push(:f... | ruby | MIT | fe1f35863e3bad60ef8731e298c7cb38af4e7af6 | 2026-01-04T15:44:39.884044Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.