Sha256: 5d2b3b2b5d6c0705f0bdefd91adac8b6011ef46bcc02aa0588c4d01bbac038ac
Contents?: true
Size: 1.19 KB
Versions: 33
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::Record do context 'custom setters' do context 'assigning values directly to other attributes' do before do Object.send(:remove_const, :Booking) # make sure there is no other booking from previous tests around class Booking < LHS::Record endpoint 'https://bookings' def appointment_attributes=(params) self.appointments = params.map { |item| item[:id] } end end end it 'allows to change raw in custom setters' do booking = Booking.new(appointment_attributes: [{ id: 1 }]) expect(booking.appointments.to_a).to eq [1] end end context 'assign values directly by using square brackets' do before do class Booking < LHS::Record endpoint 'https://bookings' def appointment_attributes=(params) self[:appointments] = params.map { |item| item[:id] } end end end it 'allows to change raw in custom setters' do booking = Booking.new(appointment_attributes: [{ id: 1 }]) expect(booking.appointments.to_a).to eq [1] end end end end
Version data entries
33 entries across 33 versions & 1 rubygems