Sha256: 87150c31ebfdae3299d6c5c1d0cc3e0485676badc48a0264657767c11a753412
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# encoding: utf-8 require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper") describe "ImageHandler" do let(:image_handler) { Prawn::ImageHandler.new } let(:handler_a) { double("Handler A") } let(:handler_b) { double("Handler B") } it "finds the image handler for an image" do allow(handler_a).to receive(:can_render?).and_return(true) image_handler.register(handler_a) image_handler.register(handler_b) handler = image_handler.find("arbitrary blob") expect(handler).to eq(handler_a) end it "can prepend handlers" do allow(handler_b).to receive(:can_render?).and_return(true) image_handler.register(handler_a) image_handler.register!(handler_b) handler = image_handler.find("arbitrary blob") expect(handler).to eq(handler_b) end it "can unregister a handler" do allow(handler_b).to receive(:can_render?).and_return(true) image_handler.register(handler_a) image_handler.register(handler_b) image_handler.unregister(handler_a) handler = image_handler.find('arbitrary blob') expect(handler).to eq(handler_b) end it "raises an error when no matching handler is found" do allow(handler_a).to receive(:can_render?).and_return(false) allow(handler_b).to receive(:can_render?).and_return(false) image_handler.register(handler_a) image_handler.register(handler_b) expect { image_handler.find("arbitrary blob") }. to(raise_error(Prawn::Errors::UnsupportedImageType)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.1.0 | spec/image_handler_spec.rb |