Sha256: f492f4f88f0f68a557200fd8f497ef96e623894b2319b6d27fb1992160f47a1d

Contents?: true

Size: 1006 Bytes

Versions: 36

Compression:

Stored size: 1006 Bytes

Contents

require 'ostruct'

shared_examples 'content_image' do
  describe "when there is a default paperclip image" do
    subject { get_presenter(stub_presenter(image: ContentImage::MISSING_WOOPLE_IMAGE)) }

    it "yields the default image" do
      subject.image { |url| url }.should == ContentImage::DEFAULT_IMAGE
    end
  end

  describe "when there is a null image" do
    subject { get_presenter(stub_presenter(image: nil)) }

    it "yields the default image" do
      subject.image { |url| url }.should == ContentImage::DEFAULT_IMAGE
    end
  end

  describe "when there is an image" do
    subject { get_presenter(stub_presenter(image: 'image.jpg')) }

    it "yields the specified image" do
      subject.image { |url| url }.should == 'image.jpg'
    end
  end

  private

  def get_presenter(model)
    presenter.new(model)
  end

  def stub_presenter(options = {})
    defaults = {name: 'Content Item', url: '/course', image: nil}
    defaults.merge!(options)

    OpenStruct.new(defaults)
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
woople-theme-0.8.1 spec/support/content_image_example.rb
woople-theme-0.8.0 spec/support/content_image_example.rb
woople-theme-0.6.27 spec/support/content_image_example.rb
woople-theme-0.6.26 spec/support/content_image_example.rb
woople-theme-0.6.25 spec/support/content_image_example.rb
woople-theme-0.6.24 spec/support/content_image_example.rb
woople-theme-0.6.23 spec/support/content_image_example.rb
woople-theme-0.6.22 spec/support/content_image_example.rb
woople-theme-0.6.21 spec/support/content_image_example.rb
woople-theme-0.6.20 spec/support/content_image_example.rb
woople-theme-0.6.19 spec/support/content_image_example.rb
woople-theme-0.6.18 spec/support/content_image_example.rb
woople-theme-0.6.17 spec/support/content_image_example.rb
woople-theme-0.6.14 spec/support/content_image_example.rb
woople-theme-0.6.13 spec/support/content_image_example.rb
woople-theme-0.6.12 spec/support/content_image_example.rb