Sha256: 052789f275b92f70e0c415f197f92eb1f39497d613da456e3ab9d1efb8aa1021

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

Contents

require 'spec_helper'

describe Hydra::Derivatives::Image do
  let(:object) { ActiveFedora::Base.new }
  let(:output_file) { double }

  subject { Hydra::Derivatives::Image.new(object, 'content', directives)}

  before { expect(subject).to receive(:output_file).with(file_name).and_return(output_file) }

  describe "when arguments are passed as a string" do
    let(:directives) { { thumb: "100x100>" } }
    let(:file_name) { 'content_thumb' }

    it "should use the string as the size and the name is autogenerated" do
      expect(subject).to receive(:create_resized_image).with(output_file, "100x100>", 'png')
      subject.process
    end
  end

  describe "when arguments are passed as a hash" do
    let(:directives) { { thumb: { size: "200x300>", datastream: file_name } } }
    let(:file_name) { 'thumbnail' }

    it "should use the specified size and name" do
      expect(subject).to receive(:create_resized_image).with(output_file, "200x300>", 'png')
      subject.process
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-derivatives-1.0.0 spec/units/image_spec.rb
hydra-derivatives-1.0.0.rc1 spec/units/image_spec.rb
hydra-derivatives-1.0.0.beta1 spec/units/image_spec.rb