forked from lostisland/faraday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaraday_spec.rb
37 lines (29 loc) · 1003 Bytes
/
faraday_spec.rb
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
29
30
31
32
33
34
35
36
37
# 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
expect { Faraday.this_method_does_not_exist }.to raise_error(
NoMethodError,
"undefined method `this_method_does_not_exist' for Faraday:Module"
)
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