Sha256: a4a75b321efee72808c228bd2b9f88bf0dde266b0cd13f47a91c413960a293b3

Contents?: true

Size: 1.92 KB

Versions: 14

Compression:

Stored size: 1.92 KB

Contents

require_relative '../../app/presenters/page_header_presenter'
require_relative '../../spec/support/content_image_example'

describe PageHeaderPresenter do
  let(:presenter) { PageHeaderPresenter }

  subject { PageHeaderPresenter.new(stub_presenter) }

  include_examples 'content_image'

  describe "#title" do
    describe "when the object has a name" do
      subject { PageHeaderPresenter.new(stub_presenter(name: 'Name')) }

      it "should have a name" do
        subject.title.should eq('Name')
      end
    end

    describe "when the object has a title" do
      subject { PageHeaderPresenter.new(stub_presenter(title: 'Title')) }

      it "should have the title" do
        subject.stub(:name).and_return('Name')
        subject.title.should eq('Title')
      end
    end
  end

  describe "#image_class" do
    describe "when the object has an image" do
      subject { PageHeaderPresenter.new(stub_presenter(image: 'image')) }

      it "has a class of page-header-with-image" do
        subject.image_class.should eq('page-header-with-image')
      end
    end

    describe "when the object does not have an image" do
      subject { PageHeaderPresenter.new(stub_presenter) }

      it "has a class of nil" do
        subject.image_class.should be_nil
      end
    end
  end

  describe "#completed_class" do
    describe "when the object is completed" do
      subject { PageHeaderPresenter.new(stub_presenter(completed?: true)) }

      it "has a class of completed" do
        subject.completed_class.should eq('completed')
      end
    end

    describe "when the object is incompleted" do
      subject { PageHeaderPresenter.new(stub_presenter(completed?: false)) }

      it "has a class of nil" do
        subject.completed_class.should be_nil
      end
    end
  end

  private

  def stub_presenter(options = {})
    defaults = {completed?: nil, description: nil}
    defaults.merge!(options)

    OpenStruct.new(defaults)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
woople-theme-0.6.27 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.26 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.25 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.24 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.23 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.22 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.21 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.20 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.19 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.18 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.17 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.14 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.13 spec/presenters/page_header_presenter_spec.rb
woople-theme-0.6.12 spec/presenters/page_header_presenter_spec.rb