Sha256: 615b74e330019b17e1b758a68a814672507ec4ecbf46f237f2c5a1db86ac0ebb

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'rails_helper'

module Portfolio
  RSpec.describe 'portfolio/site_projects/index' do
    before do
      view.extend ApplicationHelper, SiteItemsHelper
    end

    context 'with uncategorized projects' do
      let(:site) { create(:site_with_projects) }

      before do
        assign(:site, site)
        render
      end

      it 'displays all published projects' do
        expect(rendered).to match /#{site.site_projects.published.sample.title}/
      end

      it 'doesn\'t display unpublished' do
        expect(rendered).not_to match /#{site.site_projects.unpublished.sample.title}/
      end
    end

    context 'with categorized projects' do
      let(:site) { create(:site_with_categorized_projects) }

      before do
        assign(:site, site)
        render
      end

      it 'displays all published projects' do
        expect(rendered).to match /#{SiteItemCategory.first.name}/
        expect(rendered).to match /#{site.site_projects.published.sample.title}/
      end

      it 'doesn\'t display unpublished' do
        expect(rendered).to match /#{SiteItemCategory.first.name}/
        expect(rendered).not_to match /#{site.site_projects.unpublished.sample.title}/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-portfolio-0.0.2 spec/views/portfolio/site_projects/index.html.erb_spec.rb
rails-portfolio-0.0.1 spec/views/portfolio/site_projects/index.html.erb_spec.rb