Sha256: 3bfd64498a00db6646af679bea9912fc51f5217ea1257072374e4ba77012bf52

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

RSpec.describe Faraday do
  it 'has a version number' do
    expect(Faraday::VERSION).not_to be nil
  end

  context 'proxies to default_connection' do
    let(:mock_connection) { double('Connection') }
    before do
      Faraday.default_connection = mock_connection
    end

    it 'proxies methods that exist on the default_connection' do
      expect(mock_connection).to receive(:this_should_be_proxied)

      Faraday.this_should_be_proxied
    end

    it 'uses method_missing on Faraday if there is no proxyable method' do
      expected_message =
        if RUBY_VERSION >= '3.4'
          "undefined method 'this_method_does_not_exist' for module Faraday"
        elsif RUBY_VERSION >= '3.3'
          "undefined method `this_method_does_not_exist' for module Faraday"
        else
          "undefined method `this_method_does_not_exist' for Faraday:Module"
        end

      expect { Faraday.this_method_does_not_exist }.to raise_error(NoMethodError, expected_message)
    end

    it 'proxied methods can be accessed' do
      allow(mock_connection).to receive(:this_should_be_proxied)

      expect(Faraday.method(:this_should_be_proxied)).to be_a(Method)
    end

    after do
      Faraday.default_connection = nil
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
es_cli-0.1.0 vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday_spec.rb
faraday-2.12.2 spec/faraday_spec.rb
faraday-2.12.1 spec/faraday_spec.rb
faraday-2.12.0 spec/faraday_spec.rb
faraday-2.11.0 spec/faraday_spec.rb
faraday-2.10.1 spec/faraday_spec.rb
faraday-2.10.0 spec/faraday_spec.rb
faraday-2.9.2 spec/faraday_spec.rb
faraday-2.9.1 spec/faraday_spec.rb