spec/processors/image_spec.rb in hydra-derivatives-3.3.2 vs spec/processors/image_spec.rb in hydra-derivatives-3.4.0

- old
+ new

@@ -1,22 +1,23 @@ require 'spec_helper' describe Hydra::Derivatives::Processors::Image do - let(:file_name) { "file_name" } subject { described_class.new(file_name, directives) } + let(:file_name) { "file_name" } + context "when arguments are passed as a hash" do before { allow(subject).to receive(:load_image_transformer).and_return(mock_image) } context "with a multi-page pdf source file" do - let(:first_page) { double("MockPage") } - let(:second_page) { double("MockPage") } - let(:mock_image) { double("MockImageOfPdf", layers: [first_page, second_page]) } + let(:first_page) { instance_double("MockPage") } + let(:second_page) { instance_double("MockPage") } + let(:mock_image) { instance_double("MockImageOfPdf", layers: [first_page, second_page]) } before { allow(mock_image).to receive(:type).and_return("PDF") } - context "by default" do + context "when default" do let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } } it "uses the first page" do expect(first_page).to receive(:flatten) expect(second_page).not_to receive(:flatten) @@ -50,12 +51,12 @@ end context "with an image source file" do before { allow(mock_image).to receive(:type).and_return("JPEG") } - context "by default" do - let(:mock_image) { double("MockImage") } + context "when default" do + let(:mock_image) { instance_double("MockImage") } let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } } it "uses the image file" do expect(mock_image).not_to receive(:layers) expect(mock_image).to receive(:flatten) @@ -66,13 +67,13 @@ subject.process end end context "when specifying a layer" do - let(:first_layer) { double("MockPage") } - let(:second_layer) { double("MockPage") } - let(:mock_image) { double("MockImage", layers: [first_layer, second_layer]) } + let(:first_layer) { instance_double("MockPage") } + let(:second_layer) { instance_double("MockPage") } + let(:mock_image) { instance_double("MockImage", layers: [first_layer, second_layer]) } let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75, layer: 1 } } it "uses the layer" do expect(second_layer).to receive(:flatten) expect(first_layer).not_to receive(:flatten) @@ -111,9 +112,10 @@ end end context "when running the complete command", requires_imagemagick: true do let(:file_name) { File.join(fixture_path, "test.tif") } + it "converts the image" do expect(Hydra::Derivatives::PersistBasicContainedOutputFileService).to receive(:call).with(kind_of(StringIO), directives) subject.process end end