Sha256: b57764743e02095153699188f445b7347e67e949fe209bcebd4610715941819e
Contents?: true
Size: 1.22 KB
Versions: 12
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe DHS::Record do context 'custom setters' do context 'assigning values directly to other attributes' do before do Object.send(:remove_const, :Booking) if Object.const_defined?(:Booking) # make sure there is no other booking from previous tests around class Booking < DHS::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 < DHS::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
12 entries across 12 versions & 1 rubygems