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.10.0 spec/support/content_image_example.rb
woople-theme-0.9.0 spec/support/content_image_example.rb
woople-theme-0.8.19 spec/support/content_image_example.rb
woople-theme-0.8.18 spec/support/content_image_example.rb
woople-theme-0.8.17 spec/support/content_image_example.rb
woople-theme-0.8.16 spec/support/content_image_example.rb
woople-theme-0.8.15 spec/support/content_image_example.rb
woople-theme-0.8.14 spec/support/content_image_example.rb
woople-theme-0.8.13 spec/support/content_image_example.rb
woople-theme-0.8.12 spec/support/content_image_example.rb
woople-theme-0.8.11 spec/support/content_image_example.rb
woople-theme-0.8.10 spec/support/content_image_example.rb
woople-theme-0.8.9 spec/support/content_image_example.rb
woople-theme-0.8.8 spec/support/content_image_example.rb
woople-theme-0.8.7 spec/support/content_image_example.rb
woople-theme-0.8.6 spec/support/content_image_example.rb
woople-theme-0.8.5 spec/support/content_image_example.rb
woople-theme-0.8.4 spec/support/content_image_example.rb
woople-theme-0.8.3 spec/support/content_image_example.rb
woople-theme-0.8.2 spec/support/content_image_example.rb