File: adapter_registry_spec.rb

package info (click to toggle)
ruby-faraday 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,008 kB
  • sloc: ruby: 6,509; sh: 10; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

RSpec.describe Faraday::AdapterRegistry do
  describe '#initialize' do
    subject(:registry) { described_class.new }

    it { expect { registry.get(:FinFangFoom) }.to raise_error(NameError) }
    it { expect { registry.get('FinFangFoom') }.to raise_error(NameError) }

    it 'looks up class by string name' do
      expect(registry.get('Faraday::Connection')).to eq(Faraday::Connection)
    end

    it 'looks up class by symbol name' do
      expect(registry.get(:Faraday)).to eq(Faraday)
    end

    it 'caches lookups with implicit name' do
      registry.set :symbol
      expect(registry.get('symbol')).to eq(:symbol)
    end

    it 'caches lookups with explicit name' do
      registry.set 'string', :name
      expect(registry.get(:name)).to eq('string')
    end
  end
end