Sha256: e49bee8d648da6ec5be49058a7106e0f52cb1c0b4d1773eb533f93a3d8d13e0b
Contents?: true
Size: 913 Bytes
Versions: 1
Compression:
Stored size: 913 Bytes
Contents
require 'rails_helper' module Attorney RSpec.describe Document, type: :model do subject(:document) { Document.new(slug: 'terms', content: 'Lorem ipsum dolor sit amet...') } context 'validations' do it { is_expected.to validate_uniqueness_of(:slug) } it { is_expected.to validate_presence_of(:slug) } context 'slug format' do let(:document) { Document.new(slug: 'terms and conditions') } it 'validates format' do expect(document).not_to be_valid expect(document.errors[:slug]).to eq ["Slug format is invalid, try \"terms-and-conditions\" instead."] end end end describe '.published' do let!(:document_1) { Document.create!(slug: 'terms-1', published: true) } let!(:document_2) { Document.create!(slug: 'terms-2', published: false) } it { expect(Document.published).to eq [document_1] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attorney-1.0.0 | spec/models/attorney/document_spec.rb |