Sha256: ebcfd5b61cf7b24bb6761f96b852fe9d19da2ef3073703c35380a153db7cbf82

Contents?: true

Size: 911 Bytes

Versions: 12

Compression:

Stored size: 911 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.message).to eq 'failure'
  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

12 entries across 12 versions & 1 rubygems

Version Path
riiif-2.1.0 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.7.1 spec/models/riiif/http_file_resolver_spec.rb
riiif-2.0.0 spec/models/riiif/http_file_resolver_spec.rb
riiif-2.0.0.beta2 spec/models/riiif/http_file_resolver_spec.rb
riiif-2.0.0.beta1 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.7.0 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.6.0 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.5.1 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.5.0 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.4.4 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.4.3 spec/models/riiif/http_file_resolver_spec.rb
riiif-1.4.2 spec/models/riiif/http_file_resolver_spec.rb