Sha256: cb194a2e67c9e9cf79dcf2d61d05886cc52ed791e7aa4761d4d5ac4073f50c80
Contents?: true
Size: 973 Bytes
Versions: 31
Compression:
Stored size: 973 Bytes
Contents
require 'spec_helper' describe Layout do let(:layout){ FactoryBot.build(:layout) } describe 'name' do it 'is invalid when blank' do layout = FactoryBot.build(:layout, name: '') layout.valid? expect(layout.errors[:name]).to include("this must not be blank") end it 'should validate uniqueness of' do layout = FactoryBot.build(:layout, name: 'Normal', content: "Content!") layout.save! other = FactoryBot.build(:layout, name: 'Normal', content: "Content!") expect{other.save!}.to raise_error(ActiveRecord::RecordInvalid) end it 'should validate length of' do layout = FactoryBot.build(:layout, name: 'x' * 100) expect(layout.errors[:name]).to be_blank layout = FactoryBot.build(:layout, name: 'x' * 101) expect{layout.save!}.to raise_error(ActiveRecord::RecordInvalid) expect(layout.errors[:name]).to include("this must not be longer than 100 characters") end end end
Version data entries
31 entries across 31 versions & 1 rubygems