Sha256: 990a6012f12f19e95e716a39a6b5a71ada4e173a8c4056ccccafef4fab41dfbd
Contents?: true
Size: 934 Bytes
Versions: 11
Compression:
Stored size: 934 Bytes
Contents
require 'spec_helper' describe Riiif::HTTPFileResolver do subject { described_class.new } before do Dir.glob('tmp/network_files/*') do |f| File.unlink(f) end subject.id_to_uri = ->(id) { id } end it "raises an error when the file isn't found" do expect(Kernel).to receive(:open).and_raise(OpenURI::HTTPError.new('failure', StringIO.new)) begin subject.find('1234') rescue Riiif::ImageNotFoundError => e end expect(e).to be_a Riiif::ImageNotFoundError expect(e.original_exception).to be_an OpenURI::HTTPError end context 'when basic authentication credentials are set' do let(:credentials) { %w(username s0s3kr3t) } before do subject.basic_auth_credentials = credentials end it 'uses basic auth credentials' do expect(Kernel).to receive(:open).with('1234', http_basic_authentication: credentials) subject.find('1234') end end end
Version data entries
11 entries across 11 versions & 1 rubygems