Sha256: 2faa93bb4d32b7363fc335fb6cd57422d4c6f8f91ca8dfdeeb43ec2cf0278652

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

module Spina::Admin::Conferences::Blog
  RSpec.describe Post, type: :model do
    let(:post) { build(:spina_blog_post) }

    subject { post }

    it { is_expected.to be_valid }
    it { expect { post.save }.to change(Spina::Admin::Conferences::Blog::Post, :count).by(1) }

    context 'with invalid attributes' do
      let(:post) { build(:invalid_spina_blog_post) }

      it { is_expected.to_not be_valid }
      it { expect { post.save }.to_not change(Spina::Admin::Conferences::Blog::Post, :count) }
    end

    describe '.featured' do
      let!(:post) { create(:spina_blog_post, featured: true) }
      let!(:unfeatured) { create(:spina_blog_post) }

      it 'returns 1 result' do
        expect(Spina::Admin::Conferences::Blog::Post.featured).to match_array [post]
      end
    end

    describe '.unfeatured' do
      let!(:post) { create(:spina_blog_post, featured: true) }
      let!(:unfeatured) { create(:spina_blog_post) }

      it 'returns 1 result' do
        expect(Spina::Admin::Conferences::Blog::Post.unfeatured).to match_array [unfeatured]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spina-admin-conferences-blog-0.3.1 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.2.0 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.1.4 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.1.3 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.1.2 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.1.1 spec/models/spina/admin/conferences/blog/post_spec.rb
spina-admin-conferences-blog-0.1.0 spec/models/spina/admin/conferences/blog/post_spec.rb