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 |
|---|---|---|---|---|---|---|---|---|
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/unit/repository/session_spec.rb | repository/spec/unit/repository/session_spec.rb | # frozen_string_literal: true
require 'rom-changeset'
RSpec.describe ROM::Repository, '#session' do
subject(:repo) do
Class.new(ROM::Repository).new(rom)
end
include_context 'database'
include_context 'relations'
describe 'with :create command' do
let(:user_changeset) do
users.changeset(:cre... | 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/class_interface_spec.rb | repository/spec/unit/repository/class_interface_spec.rb | # frozen_string_literal: true
require 'rom/repository'
RSpec.describe ROM::Repository, '.new' do
include_context 'database'
subject(:repo_class) do
Class.new(ROM::Repository[:users])
end
it 'includes a relation reader module on a single instance' do
reader_modules = repo_class.new(rom).class.ancesto... | 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/transaction_spec.rb | repository/spec/unit/repository/transaction_spec.rb | # frozen_string_literal: true
require 'rom-changeset'
RSpec.describe ROM::Repository, '#transaction' do
let(:user_repo) do
Class.new(ROM::Repository[:users]) { commands :create, update: :by_pk }.new(rom)
end
let(:task_repo) do
Class.new(ROM::Repository[:tasks]) { commands :create, :update }.new(rom)
... | 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/class_interface/root_builder_spec.rb | repository/spec/unit/repository/class_interface/root_builder_spec.rb | # frozen_string_literal: true
require 'rom/repository'
RSpec.describe ROM::Repository, '.[]' do
subject(:repo) do
Class.new(ROM::Repository)
end
let(:relation) { :users }
it 'creates a preconfigured ROM::Repository:Root class' do
expect(repo[relation].root).to be(relation)
end
it 'caches the cl... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/seeds.rb | repository/spec/shared/seeds.rb | # frozen_string_literal: true
RSpec.shared_context 'seeds' do
before do
jane_id = conn[:users].insert name: 'Jane'
joe_id = conn[:users].insert name: 'Joe'
conn[:tasks].insert user_id: joe_id, title: 'Joe Task'
task_id = conn[:tasks].insert user_id: jane_id, title: 'Jane Task'
conn[:tags].inser... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/plugins.rb | repository/spec/shared/plugins.rb | # frozen_string_literal: true
RSpec.shared_context 'plugins' do
before do
module Test
class WrappingInput
def initialize(input)
@input = input || Hash
end
end
module Timestamps
class InputWithTimestamp < WrappingInput
def [](value)
v = @i... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/relations.rb | repository/spec/shared/relations.rb | # frozen_string_literal: true
RSpec.shared_context 'relations' do
let(:users) { rom.relations[:users] }
let(:tasks) { rom.relations[:tasks] }
let(:tags) { rom.relations[:tags] }
let(:posts) { rom.relations[:posts] }
let(:books) { rom.relations[:books] }
let(:labels) { rom.relations[:labels] }
before do
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/models.rb | repository/spec/shared/models.rb | # frozen_string_literal: true
RSpec.shared_context 'models' do
let(:user_model) { Test::Models::User }
let(:task_model) { Test::Models::Task }
let(:tag_model) { Test::Models::Tag }
before do
module Test
module Models
class User
include Dry::Equalizer(:id, :name)
attr_rea... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/mappers.rb | repository/spec/shared/mappers.rb | # frozen_string_literal: true
RSpec.shared_context 'mappers' do
let(:user_mappers) { users.mappers[:user] }
let(:task_mappers) { tasks.mappers[:task] }
let(:tag_mappers) { tags.mappers[:tag] }
before do
configuration.mappers do
define(:users) do
model Test::Models::User
register_as :... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/structs.rb | repository/spec/shared/structs.rb | # frozen_string_literal: true
RSpec.shared_context 'structs' do
let(:user_struct) do
repo.users.mapper.model
end
let(:task_struct) do
repo.tasks.mapper.model
end
let(:tag_struct) do
repo.tags.mapper.model
end
let(:post_struct) do
repo.posts.mapper.model
end
let(:label_struct) do
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/repo.rb | repository/spec/shared/repo.rb | # frozen_string_literal: true
RSpec.shared_context('repo') do
include_context 'models'
include_context 'mappers'
let(:repo) { repo_class.new(rom) }
let(:repo_class) do
Class.new(ROM::Repository[:users]) do
def find_users(criteria)
users.find(criteria)
end
def all_users
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/spec/shared/database.rb | repository/spec/shared/database.rb | # frozen_string_literal: true
RSpec.shared_context 'database setup' do
let(:configuration) { ROM::Configuration.new(:sql, DB_URI) }
let(:conn) { configuration.gateways[:default].connection }
let(:rom) { ROM.container(configuration) }
before do
conn.loggers << LOGGER
end
end
RSpec.shared_context 'data... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/examples/sql.rb | repository/examples/sql.rb | # frozen_string_literal: true
require 'rom-repository'
conf = ROM::Configuration.new(:sql, 'sqlite::memory')
migration = conf.gateways[:default].migration do
change do
create_table(:users) do
primary_key :id
column :name, String, null: false
column :email, String, null: false
end
end
en... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/examples/upsert.rb | repository/examples/upsert.rb | # frozen_string_literal: true
require 'rom'
require 'rom/repository'
require 'rom/changeset'
conf = ROM::Configuration.new(:sql, 'postgres://localhost/rom_example')
migration = conf.gateways[:default].migration do
change do
create_table?(:books) do
primary_key :id
column :title, String, null: false... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom-repository.rb | repository/lib/rom-repository.rb | # frozen_string_literal: true
require 'rom/core'
require 'rom/repository'
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository.rb | repository/lib/rom/repository.rb | # frozen_string_literal: true
require 'rom/initializer'
require 'rom/struct'
require 'rom/container'
require 'rom/repository/class_interface'
require 'rom/repository/session'
ROM::Plugins.register(:repository, adapter: false)
module ROM
# Abstract repository class to inherit from
#
# A repository provides acce... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository/session.rb | repository/lib/rom/repository/session.rb | # frozen_string_literal: true
module ROM
# TODO: finish this in 1.1.0
#
# @api private
class Session
include Dry::Equalizer(:queue, :status)
attr_reader :repo
attr_reader :queue
attr_reader :status
def initialize(repo)
@repo = repo
@status = :pending
initialize_queue!
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository/version.rb | repository/lib/rom/repository/version.rb | # frozen_string_literal: true
module ROM
class Repository
VERSION = '5.4.3'
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository/root.rb | repository/lib/rom/repository/root.rb | # frozen_string_literal: true
module ROM
class Repository
# A specialized repository type dedicated to work with a root relation
#
# This repository type builds commands and aggregates for its root relation
#
# @example
# class UserRepo < ROM::Repository[:users]
# commands :create, ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository/relation_reader.rb | repository/lib/rom/repository/relation_reader.rb | # frozen_string_literal: true
module ROM
class Repository
# @api private
class RelationReader < ::Module
def self.added_to?(klass)
klass < InstanceMethods
end
module InstanceMethods
extend ::Dry::Core::Deprecations[:'rom-repository']
private
# @api public
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/repository/lib/rom/repository/class_interface.rb | repository/lib/rom/repository/class_interface.rb | # frozen_string_literal: true
require 'rom/repository/relation_reader'
module ROM
class Repository
# Class-level APIs for repositories
#
# @api public
module ClassInterface
# Create a root-repository class and set its root relation
#
# @example
# # where :users is the relat... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'tempfile'
SPEC_ROOT = root = Pathname(__FILE__).dirname
if ENV['COVERAGE'] == 'true'
require 'codacy-coverage'
Codacy::Reporter.start(partial: true)
end
require 'rom/core'
Dir[root.join('support/*.rb').to_s].each do |f|
require f
end
Dir[root.join('shared/*.rb').to_s].... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/spec/integration/setup_spec.rb | spec/integration/setup_spec.rb | # frozen_string_literal: true
require 'rom/memory'
RSpec.describe 'Setting up rom suite' do
subject(:rom) do
ROM.container(:memory) do |config|
config.register_relation(Test::Users)
end
end
before do
class Test::Users < ROM::Relation[:memory]
schema(:users) do
attribute :id, Typ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/spec/integration/gateways/gateway_params_spec.rb | spec/integration/gateways/gateway_params_spec.rb | # frozen_string_literal: true
RSpec.describe 'Gateways / keyword arguments' do
before do
@adapter = Module.new
class @adapter::Gateway
extend ROM::Initializer
param :param
option :option
end
ROM.register_adapter(:my_adapter, @adapter)
end
specify do
gw = @adapter::Gateway.... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/spec_helper.rb | changeset/spec/spec_helper.rb | # frozen_string_literal: true
require 'pathname'
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.ignore(/__FILE__/)
Wa... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/integration/command_options_spec.rb | changeset/spec/integration/command_options_spec.rb | # frozen_string_literal: true
RSpec.describe 'changeset plugin' do
subject(:changeset) do
books.changeset(changeset_class).data(title: 'Hello World')
end
let(:changeset_class) do
Class.new(ROM::Changeset::Create) do
command_options input: -> tuple { tuple.merge(updated_at: Time.now) }
comman... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/integration/plugin_spec.rb | changeset/spec/integration/plugin_spec.rb | # frozen_string_literal: true
RSpec.describe 'changeset plugin' do
subject(:changeset) do
books.changeset(changeset_class).data(title: 'Hello World')
end
let(:changeset_class) do
Class.new(ROM::Changeset::Create) do
use :auto_touch
end
end
include_context 'database'
include_context 'rel... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/integration/changeset_spec.rb | changeset/spec/integration/changeset_spec.rb | # frozen_string_literal: true
RSpec.describe 'Using changesets' do
include_context 'database'
include_context 'relations'
before do
module Test
class User < Dry::Struct
attribute :id, Dry::Types['strict.integer']
attribute :name, Dry::Types['strict.string']
end
end
confi... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/pipe_registry_spec.rb | changeset/spec/unit/pipe_registry_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset::PipeRegistry do
describe '.add_timestamps' do
context 'input has no timestamps' do
let(:data) { Hash(name: 'John') }
it 'adds timestamps to hash' do
expect(described_class.add_timestamps(data)[:name]).to eq('John')
expect(... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/update_spec.rb | changeset/spec/unit/update_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset::Update do
include_context 'database'
include_context 'relations'
subject(:changeset) do
users.by_pk(jane[:id]).changeset(:update, data)
end
let(:data) do
{ name: 'Jane Doe' }
end
let!(:jane) do
users.command(:create).call(name: '... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/pipe_spec.rb | changeset/spec/unit/pipe_spec.rb | # frozen_string_literal: true
require 'rom/changeset/pipe'
RSpec.describe ROM::Changeset::Pipe do
context 'with default processor and options' do
subject(:pipe) do
Class.new(ROM::Changeset::Pipe).new
end
it 'sets up identity as the default processor' do
expect(pipe.call(foo: 'bar')).to eql(... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/delete_spec.rb | changeset/spec/unit/delete_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset::Delete do
include_context 'database'
include_context 'relations'
describe ROM::Changeset::Delete do
let(:changeset) do
users.by_pk(user[:id]).changeset(:delete)
end
let(:relation) do
users.by_pk(user[:id])
end
let(:us... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/associate_spec.rb | changeset/spec/unit/associate_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset, '#associate' do
include_context 'database setup'
let(:people) do
rom.relations[:people].with(auto_struct: true)
end
let(:todos) do
rom.relations[:todos].with(auto_struct: true)
end
let(:projects) do
rom.relations[:projects].with(au... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/create_spec.rb | changeset/spec/unit/create_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset::Create do
include_context 'database'
include_context 'relations'
context 'with a hash' do
let(:changeset) do
users.changeset(:create, name: 'Jane')
end
it 'has data' do
expect(changeset.to_h).to eql(name: 'Jane')
end
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/map_spec.rb | changeset/spec/unit/map_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Changeset, '.map' do
context 'single mapping with transaction DSL' do
subject(:changeset) do
Class.new(ROM::Changeset::Create[:users]) do
map do
unwrap :address
rename_keys street: :address_street, city: :address_city, country: :... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/unit/changeset_spec.rb | changeset/spec/unit/changeset_spec.rb | # frozen_string_literal: true
require 'ostruct'
RSpec.describe ROM::Changeset do
let(:jane) { { id: 2, name: 'Jane' } }
let(:relation) { double(ROM::Relation, name: :users) }
describe '.[]' do
it 'returns a changeset preconfigured for a specific relation' do
klass = ROM::Changeset::Create[:users]
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/seeds.rb | changeset/spec/shared/seeds.rb | # frozen_string_literal: true
RSpec.shared_context 'seeds' do
before do
jane_id = conn[:users].insert name: 'Jane'
joe_id = conn[:users].insert name: 'Joe'
conn[:tasks].insert user_id: joe_id, title: 'Joe Task'
task_id = conn[:tasks].insert user_id: jane_id, title: 'Jane Task'
conn[:tags].inser... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/plugins.rb | changeset/spec/shared/plugins.rb | # frozen_string_literal: true
RSpec.shared_context 'plugins' do
before do
module Test
class WrappingInput
def initialize(input)
@input = input || Hash
end
end
module Timestamps
class InputWithTimestamp < WrappingInput
def [](value)
v = @i... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/relations.rb | changeset/spec/shared/relations.rb | # frozen_string_literal: true
RSpec.shared_context 'relations' do
let(:users) { rom.relations[:users].with(auto_struct: true) }
let(:tasks) { rom.relations[:tasks].with(auto_struct: true) }
let(:tags) { rom.relations[:tags].with(auto_struct: true) }
let(:posts) { rom.relations[:posts].with(auto_struct: true) }... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/models.rb | changeset/spec/shared/models.rb | # frozen_string_literal: true
RSpec.shared_context 'models' do
let(:user_model) { Test::Models::User }
let(:task_model) { Test::Models::Task }
let(:tag_model) { Test::Models::Tag }
before do
module Test
module Models
class User
include Dry::Equalizer(:id, :name)
attr_rea... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/mappers.rb | changeset/spec/shared/mappers.rb | # frozen_string_literal: true
RSpec.shared_context 'mappers' do
let(:user_mappers) { users.mappers[:user] }
let(:task_mappers) { tasks.mappers[:task] }
let(:tag_mappers) { tags.mappers[:tag] }
before do
configuration.mappers do
define(:users) do
model Test::Models::User
register_as :... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/structs.rb | changeset/spec/shared/structs.rb | # frozen_string_literal: true
RSpec.shared_context 'structs' do
let(:user_struct) do
repo.users.mapper.model
end
let(:task_struct) do
repo.tasks.mapper.model
end
let(:tag_struct) do
repo.tags.mapper.model
end
let(:post_struct) do
repo.posts.mapper.model
end
let(:label_struct) do
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/repo.rb | changeset/spec/shared/repo.rb | # frozen_string_literal: true
RSpec.shared_context('repo') do
include_context 'models'
include_context 'mappers'
let(:repo) { repo_class.new(rom) }
let(:repo_class) do
Class.new(ROM::Repository[:users]) do
def find_users(criteria)
users.find(criteria)
end
def all_users
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/spec/shared/database.rb | changeset/spec/shared/database.rb | # frozen_string_literal: true
RSpec.shared_context 'database setup' do
let(:configuration) { ROM::Configuration.new(:sql, DB_URI) }
let(:conn) { configuration.gateways[:default].connection }
let(:rom) { ROM.container(configuration) }
before :all do
Sequel.database_timezone = :utc
Sequel.application_... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom-changeset.rb | changeset/lib/rom-changeset.rb | # frozen_string_literal: true
require 'rom/changeset'
require 'rom/plugins/relation/changeset'
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset.rb | changeset/lib/rom/changeset.rb | # frozen_string_literal: true
require 'dry/core'
require 'rom/constants'
require 'rom/initializer'
module ROM
# Abstract Changeset class
#
# If you inherit from this class you need to configure additional settings
#
# @example define a custom changeset using :upsert command
# class NewTag < ROM::Changes... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/plugins/relation/changeset.rb | changeset/lib/rom/plugins/relation/changeset.rb | # frozen_string_literal: true
require 'rom/support/notifications'
require 'rom/changeset/create'
require 'rom/changeset/update'
require 'rom/changeset/delete'
require 'rom/changeset/extensions/relation'
module ROM
module Plugins
module Relation
# Relation plugin which adds `Relation#changeset` method
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/associated.rb | changeset/lib/rom/changeset/associated.rb | # frozen_string_literal: true
require 'rom/initializer'
module ROM
class Changeset
# Associated changesets automatically set up FKs
#
# @api public
class Associated
extend Initializer
# @!attribute [r] left
# @return [Changeset::Create] Child changeset
param :left
#... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/version.rb | changeset/lib/rom/changeset/version.rb | # frozen_string_literal: true
module ROM
class Changeset
VERSION = '5.4.3'
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/update.rb | changeset/lib/rom/changeset/update.rb | # frozen_string_literal: true
module ROM
class Changeset
# Changeset specialization for update commands
#
# Update changesets will only execute their commands when
# the data is different from the original tuple. Original tuple
# is fetched from changeset's relation using `one` method.
#
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/delete.rb | changeset/lib/rom/changeset/delete.rb | # frozen_string_literal: true
module ROM
class Changeset
# Changeset specialization for delete commands
#
# Delete changesets will execute delete command for its relation, which
# means proper restricted relations should be used with this changeset.
#
# @api public
class Delete < Changese... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/pipe_registry.rb | changeset/lib/rom/changeset/pipe_registry.rb | # frozen_string_literal: true
require 'transproc/all'
require 'transproc/registry'
module ROM
class Changeset
# Transproc Registry useful for pipe
#
# @api private
module PipeRegistry
extend Transproc::Registry
import Transproc::Coercions
import Transproc::HashTransformations
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/create.rb | changeset/lib/rom/changeset/create.rb | # frozen_string_literal: true
module ROM
class Changeset
# Changeset specialization for create commands
#
# @see Changeset::Stateful
#
# @api public
class Create < Stateful
command_type :create
def command
super.new(relation)
end
end
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/stateful.rb | changeset/lib/rom/changeset/stateful.rb | # frozen_string_literal: true
require 'rom/changeset/pipe'
module ROM
class Changeset
# Stateful changesets carry data and can transform it into
# a different structure compatible with a persistence backend
#
# @abstract
class Stateful < Changeset
# Default no-op pipe
EMPTY_PIPE = Pi... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/pipe.rb | changeset/lib/rom/changeset/pipe.rb | # frozen_string_literal: true
require 'transproc/transformer'
require 'rom/changeset/pipe_registry'
module ROM
class Changeset
# Composable data transformation pipe used by default in changesets
#
# @api private
class Pipe < Transproc::Transformer[PipeRegistry]
extend Initializer
defin... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/changeset/lib/rom/changeset/extensions/relation.rb | changeset/lib/rom/changeset/extensions/relation.rb | # frozen_string_literal: true
require 'rom/relation/graph'
module ROM
class Changeset
# Namespace for changeset extensions
#
# @api public
module Extensions
# Changeset extenions for combined relations
#
# @api public
module Relation
class Graph
# Build a ch... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/lib/rom.rb | lib/rom.rb | # frozen_string_literal: true
require 'rom-core'
require 'rom-repository'
require 'rom-changeset'
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/lib/rom/version.rb | lib/rom/version.rb | # frozen_string_literal: true
module ROM
VERSION = '5.4.3'
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/benchmarks/profile_one.rb | core/benchmarks/profile_one.rb | # frozen_string_literal: true
require_relative 'setup'
require 'hotch'
users.by_name('User 1').one
Hotch() do
1000.times do
users.by_name('User 1').one
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/benchmarks/profile_wrap.rb | core/benchmarks/profile_wrap.rb | # frozen_string_literal: true
require_relative 'setup'
require 'hotch'
rel = tasks.limit(100).wrap(:user)
rel.to_a
Hotch() do
1000.times do
rel.each { |t| t.user.name }
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/benchmarks/setup.rb | core/benchmarks/setup.rb | # frozen_string_literal: true
require 'bundler'
Bundler.require
require 'benchmark/ips'
require 'rom-sql'
require 'rom-repository'
require 'active_record'
require 'logger'
begin
require 'byebug'
rescue LoadError
# ignore
end
require_relative 'gc_suite'
SEED = ENV['SEED'] == 'true'
def rom
ROM_ENV
end
def ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/benchmarks/profile_combine.rb | core/benchmarks/profile_combine.rb | # frozen_string_literal: true
require_relative 'setup'
require 'hotch'
Hotch() do
100.times do
users.combine(:tasks).to_a
end
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/benchmarks/gc_suite.rb | core/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/core/benchmarks/basic_bench.rb | core/benchmarks/basic_bench.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative 'setup'
run('Loading ONE user object') do |x|
x.verify do |user|
user.name == 'User 1'
end
x.report('AR') do
ARUser.by_name('User 1').first
end
x.report('ROM') do
users.by_name('User 1').limit(1).first
end
end
run('Loading ALL... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/spec_helper.rb | core/spec/spec_helper.rb | # frozen_string_literal: true
require 'pathname'
SPEC_ROOT = root = Pathname(__FILE__).dirname
if ENV['COVERAGE'] == 'true'
require 'codacy-coverage'
Codacy::Reporter.start(partial: true)
end
require 'warning'
require 'dry/core'
Warning.ignore(/__FILE__/)
Warning.ignore(/__LINE__/)
if Gem::Version.new(RUBY_VE... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/support/constant_leak_finder.rb | core/spec/support/constant_leak_finder.rb | # frozen_string_literal: true
# Finds leaking constants created during ROM specs
module ConstantLeakFinder
def self.find(example)
constants = Object.constants
example.run
added_constants = (Object.constants - constants)
added = added_constants.map(&Object.method(:const_get))
if added.any? { |mo... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/support/types.rb | core/spec/support/types.rb | # frozen_string_literal: true
require 'dry-types'
module Types
include Dry.Types(default: :nominal)
end
| ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/support/schema.rb | core/spec/support/schema.rb | # frozen_string_literal: true
require 'rom/support/inflector'
module SchemaHelpers
def define_schema(source, attrs)
ROM::Schema.define(
source,
attributes: attrs.map do |name, id|
{
type: define_type(id, source: source),
options: { name: name }
}
end
)
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/setup_spec.rb | core/spec/integration/setup_spec.rb | # frozen_string_literal: true
RSpec.describe 'Configuring ROM' do
context 'with existing schema' do
include_context 'container'
include_context 'users and tasks'
let(:jane) { { name: 'Jane', email: 'jane@doe.org' } }
let(:joe) { { name: 'Joe', email: 'joe@doe.org' } }
before do
configurat... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/transformer_spec.rb | core/spec/integration/transformer_spec.rb | # frozen_string_literal: true
require 'rom'
require 'rom/transformer'
RSpec.describe ROM::Transformer do
subject(:relation) do
rom.relations[:users]
end
let(:rom) do
ROM.container(:memory) do |config|
config.relation(:users)
config.register_mapper(default_mapper)
config.register_mapp... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/command_registry_spec.rb | core/spec/integration/command_registry_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'ROM::CommandRegistry' do
include_context 'container'
let(:users) { container.commands[:users] }
before do
configuration.relation(:users)
configuration.register_command(Class.new(ROM::Commands::Create[:memory]) do
register_as :c... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/commands_spec.rb | core/spec/integration/commands_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Commands' do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:users) do
def by_id(id)
restrict(id: id)
end
end
configuration.commands(:users) do
define(:upda... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/multi_env_spec.rb | core/spec/integration/multi_env_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe 'Setting up ROM with multiple environments' do
let(:configuration) do
{
one: ROM::Configuration.new(:memory),
two: ROM::Configuration.new(:memory)
}
end
let(:container) do
{
one: ROM.container(... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/multi_repo_spec.rb | core/spec/integration/multi_repo_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe 'Using in-memory gateways for cross-gateway access' do
let(:configuration) do
ROM::Configuration.new(left: :memory, right: :memory, main: :memory)
end
let(:container) { ROM.container(configuration) }
let(:gateways) { ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/relations/registry_dsl_spec.rb | core/spec/integration/relations/registry_dsl_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Relation registration DSL' do
include_context 'container'
include_context 'users and tasks'
it 'allows to expose chainable relations' do
configuration.relation(:tasks) do
def high_priority
restrict { |tuple| tuple[:priority] ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/relations/default_dataset_spec.rb | core/spec/integration/relations/default_dataset_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ROM::Relation, '.dataset' do
include_context 'container'
it 'injects configured dataset when block was provided' do
configuration.relation(:users) do
dataset do |_klass|
insert(id: 2, name: 'Joe')
insert(id: 1, name: 'Ja... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/relations/inheritance_spec.rb | core/spec/integration/relations/inheritance_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Inheritance relation hierarchy' do
include_context 'container'
before do
module Test
class Users < ROM::Relation[:memory]
schema(:users) {}
def by_email(email)
restrict(email: email)
end
end
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/relations/reading_spec.rb | core/spec/integration/relations/reading_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Reading relations' do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:tasks)
configuration.relation(:users) do
def by_name(name)
restrict(name: name)
end
def w... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/commands/update_spec.rb | core/spec/integration/commands/update_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'dry-struct'
RSpec.describe 'Commands / Update' do
include_context 'container'
include_context 'users and tasks'
subject(:users) { container.commands.users }
before do
configuration.relation(:users) do
schema(:users) do
attribute ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/commands/delete_spec.rb | core/spec/integration/commands/delete_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Commands / Delete' do
include_context 'container'
include_context 'users and tasks'
subject(:users) { container.commands.users }
before do
configuration.relation(:users) do
def by_name(name)
restrict(name: name)
end
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/commands/create_spec.rb | core/spec/integration/commands/create_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'dry-struct'
RSpec.describe 'Commands / Create' do
include_context 'container'
include_context 'users and tasks'
let(:users) { container.commands.users }
let(:tasks) { container.commands.tasks }
before do
configuration.relation(:users)
co... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/memory/commands/update_spec.rb | core/spec/integration/memory/commands/update_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe ROM::Memory::Commands::Update do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:users) do
def by_id(id)
restrict(id: id)
end
end
configuratio... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/memory/commands/delete_spec.rb | core/spec/integration/memory/commands/delete_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe ROM::Memory::Commands::Delete do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:users) do
def by_id(id)
restrict(id: id)
end
end
configuratio... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/memory/commands/create_spec.rb | core/spec/integration/memory/commands/create_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe ROM::Memory::Commands::Create do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:users) do
def by_id(id)
restrict(id: id)
end
end
configuratio... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/gateways/extending_relations_spec.rb | core/spec/integration/gateways/extending_relations_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
RSpec.describe 'Gateways / Extending Relations' do
include_context 'container'
include_context 'users and tasks'
before do
module ROM
module Memory
class Relation < ROM::Relation
schema(:users) {}
de... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/gateways/setting_logger_spec.rb | core/spec/integration/gateways/setting_logger_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'rom/memory'
require 'logger'
RSpec.describe 'Gateways / Setting logger' do
let(:logger_class) do
Class.new do
attr_reader :messages
def initialize
@messages = []
end
def info(msg)
@messages << msg
end
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/step_spec.rb | core/spec/integration/mapper/step_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
include_context 'users and tasks'
before do
configuration.relation(:lists)
configuration.default.dataset(:lists).insert(
list_id: 1,
list_tasks: [
{ user: 'Jaco... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/setup_spec.rb | core/spec/integration/mapper/setup_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper Setup' do
include_context 'container'
before do
configuration.mappers do
define(:users_mapper) do
attribute :id
end
define(:tags_mapper) do
attribute :user_id
attribute :label
end
e... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/group_spec.rb | core/spec/integration/mapper/group_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
include_context 'users and tasks'
let(:header) { mapper.header }
describe 'grouped relation mapper' do
before do
configuration.relation(:tasks) do
def with_users
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/fold_spec.rb | core/spec/integration/mapper/fold_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
include_context 'users and tasks'
let(:header) { mapper.header }
describe 'folded relation mapper' do
before do
configuration.relation(:tasks) do
def with_users
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/symbolizing_attributes_spec.rb | core/spec/integration/mapper/symbolizing_attributes_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mappers / Symbolizing atributes' do
include_context 'container'
before do
configuration.relation(:users)
configuration.relation(:tasks)
end
it 'automatically maps all attributes using top-level settings' do
module Test
cla... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/unfold_spec.rb | core/spec/integration/mapper/unfold_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
before do
configuration.relation(:users)
users = configuration.default.dataset(:users)
users.insert(name: 'Joe', roles: ['admin', 'user', 'user', nil])
users.insert(name: '... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/deep_embedded_spec.rb | core/spec/integration/mapper/deep_embedded_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mappers / deeply embedded tuples' do
include_context 'container'
it 'allows mapping embedded tuples' do
configuration.relation(:users)
configuration.mappers do
define(:users) do
model name: 'Test::User'
attribute ... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/embedded_spec.rb | core/spec/integration/mapper/embedded_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mappers / embedded' do
include_context 'container'
before do
configuration.relation(:users)
end
it 'allows mapping embedded tuples' do
configuration.mappers do
define(:users) do
model name: 'Test::User'
attrib... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/combine_spec.rb | core/spec/integration/mapper/combine_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
include_context 'users and tasks'
describe 'combine' do
before do
configuration.relation(:tasks) do
auto_map false
schema(:tasks) {}
def for_users(users)... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/prefix_separator_spec.rb | core/spec/integration/mapper/prefix_separator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
before do
configuration.relation(:users)
users = configuration.default.dataset(:users)
users.insert(
user_id: 1,
user_name: 'Joe',
user_email: 'joe@doe.com',
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/prefix_spec.rb | core/spec/integration/mapper/prefix_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
before do
configuration.relation(:users)
users = configuration.default.dataset(:users)
users.insert(
user_id: 1,
user_name: 'Joe',
user_email: 'joe@doe.com',
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/mapper_spec.rb | core/spec/integration/mapper/mapper_spec.rb | # frozen_string_literal: true
RSpec.describe ROM::Mapper do
let(:mapper_klass) do
Class.new(ROM::Mapper).tap do |mapper_klass|
mapper_klass.class_eval(&mapper_body)
end
end
let(:mapper) { mapper_klass.build }
subject { mapper.call(tuples) }
describe '.attribute' do
context 'with block' do... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/prefixing_attributes_spec.rb | core/spec/integration/mapper/prefixing_attributes_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mappers / Prefixing attributes' do
include_context 'container'
before do
configuration.relation(:users)
end
it 'automatically maps all attributes using the provided prefix' do
class Test::UserMapper < ROM::Mapper
relation :use... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
rom-rb/rom | https://github.com/rom-rb/rom/blob/ac5d6618f36b0c48525fa48b7f6c774e0d1d2860/core/spec/integration/mapper/wrap_spec.rb | core/spec/integration/mapper/wrap_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Mapper definition DSL' do
include_context 'container'
include_context 'users and tasks'
let(:header) { mapper.header }
describe 'wrapped relation mapper' do
before do
configuration.relation(:tasks) do
def with_user
... | ruby | MIT | ac5d6618f36b0c48525fa48b7f6c774e0d1d2860 | 2026-01-04T15:58:11.374901Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.