Sha256: 5a947ff522cece3d4f30ac18f689f8d1033e6cfcd9aa3e281008533b1d871af3

Contents?: true

Size: 515 Bytes

Versions: 11

Compression:

Stored size: 515 Bytes

Contents

require 'rom/schema'

RSpec.describe ROM::Schema, '#wrap' do
  subject(:schema) do
    define_schema(:users, id: :Int, name: :String)
  end

  let(:wrapped) do
    schema.wrap(:users)
  end

  it 'returns projected schema with renamed attributes using provided prefix' do
    expect(wrapped.map(&:alias)).to eql(%i[users_id users_name])
    expect(wrapped.map { |attr| attr.meta[:name] }).to eql(%i[id name])
    expect(wrapped.all?(&:wrapped?)).to be(true)
    expect(wrapped.wrap(:foo)).to eql(wrapped)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rom-3.3.3 spec/unit/rom/schema/wrap_spec.rb
rom-3.3.2 spec/unit/rom/schema/wrap_spec.rb
rom-3.3.1 spec/unit/rom/schema/wrap_spec.rb
rom-3.3.0 spec/unit/rom/schema/wrap_spec.rb
rom-3.2.3 spec/unit/rom/schema/wrap_spec.rb
rom-3.2.2 spec/unit/rom/schema/wrap_spec.rb
rom-3.2.1 spec/unit/rom/schema/wrap_spec.rb
rom-3.2.0 spec/unit/rom/schema/wrap_spec.rb
rom-3.1.0 spec/unit/rom/schema/wrap_spec.rb
rom-3.0.3 spec/unit/rom/schema/wrap_spec.rb
rom-3.0.2 spec/unit/rom/schema/wrap_spec.rb