Sha256: f84446fb86519119e2ad09be69124377498affb02acce42acadf5f87b001c440
Contents?: true
Size: 667 Bytes
Versions: 9
Compression:
Stored size: 667 Bytes
Contents
require 'models' RSpec.describe 'Model Initialization' do subject { Pen } let(:pen_attributes) { { name: 'pen', color: 'red' } } before(:each) { clear_database } it 'find_or_initialize_by works' do pen = subject.find_or_initialize_by(pen_attributes) expect(pen.persisted?).to be false expect(pen.name).to eq(pen_attributes[:name]) expect(pen.color).to eq(pen_attributes[:color]) end it 'where.first_or_initialize works' do pen = subject.where(pen_attributes).first_or_initialize expect(pen.persisted?).to be false expect(pen.name).to eq(pen_attributes[:name]) expect(pen.color).to eq(pen_attributes[:color]) end end
Version data entries
9 entries across 9 versions & 1 rubygems