Sha256: 24e6f6c6691db9d43a5ad6898f8386735b95665fc888bb9d366afe9fb9adb79c
Contents?: true
Size: 1.07 KB
Versions: 18
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' require 'rom/memory' RSpec.describe 'Mappers / Attributes value' do include_context 'container' before do configuration.relation(:users) end it 'allows to manipulate attribute value' do class Test::UserMapper < ROM::Mapper relation :users attribute :id attribute :name, from: :first_name do 'John' end attribute :age do 9+9 end attribute :weight do |t| t+15 end end configuration.register_mapper(Test::UserMapper) container.relations.users << { id: 123, first_name: 'Jane', weight: 75 } jane = container.relation(:users).as(:users).first expect(jane).to eql(id: 123, name: 'John', weight: 90, age: 18) end it 'raise ArgumentError if type and block used at the same time' do expect { class Test::UserMapper < ROM::Mapper relation :users attribute :name, type: :string do 'John' end end }.to raise_error(ArgumentError, "can't specify type and block at the same time") end end
Version data entries
18 entries across 18 versions & 1 rubygems