|
1 | 1 | require "helper" |
2 | 2 |
|
3 | 3 | RSpec.describe Affirm::Client do |
4 | | - context "new instance" do |
5 | | - it "creates Faraday connection" do |
6 | | - expect(subject.connection).to be_an_instance_of(Faraday::Connection) |
| 4 | + before(:all) do |
| 5 | + Affirm.configure do |config| |
| 6 | + config.public_api_key = "abc" |
| 7 | + config.private_api_key = "xyz" |
7 | 8 | end |
8 | 9 | end |
9 | 10 |
|
10 | | - context "with api keys set" do |
11 | | - before do |
12 | | - Affirm.configure do |config| |
13 | | - config.public_api_key = "abc" |
14 | | - config.private_api_key = "xyz" |
15 | | - end |
16 | | - end |
17 | | - |
18 | | - it "sets json handlers" do |
19 | | - expect( |
20 | | - subject.connection.builder.handlers |
21 | | - ).to include(FaradayMiddleware::EncodeJson, FaradayMiddleware::ParseJson) |
22 | | - end |
23 | | - |
24 | | - it "sets basic auth header" do |
25 | | - expect(subject.connection.headers["Authorization"]).to eq("Basic YWJjOnh5eg==") |
| 11 | + context "new instance" do |
| 12 | + it "creates Faraday connection" do |
| 13 | + expect(subject.connection).to be_an_instance_of(Faraday::Connection) |
26 | 14 | end |
27 | 15 | end |
28 | 16 |
|
|
41 | 29 | subject.connection.adapter(:test, @stubs) |
42 | 30 | end |
43 | 31 |
|
| 32 | + it "sets basic auth header" do |
| 33 | + response = subject.post("foo", {}) |
| 34 | + expect(response.env.request_headers["Authorization"]).to eq("Basic YWJjOnh5eg==") |
| 35 | + end |
| 36 | + |
44 | 37 | it "makes request to full url" do |
45 | 38 | response = subject.post("foo", {}) |
46 | 39 | expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo") |
|
74 | 67 | subject.connection.adapter(:test, @stubs) |
75 | 68 | end |
76 | 69 |
|
| 70 | + it "sets basic auth header" do |
| 71 | + response = subject.get("foo", {}) |
| 72 | + expect(response.env.request_headers["Authorization"]).to eq("Basic YWJjOnh5eg==") |
| 73 | + end |
| 74 | + |
77 | 75 | it "makes request to full url" do |
78 | 76 | response = subject.get("foo", {}) |
79 | 77 | expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo") |
|
0 commit comments