Skip to content

Commit 2b5916a

Browse files
committed
Update tests
1 parent 2cad97a commit 2b5916a

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ GEM
5050

5151
PLATFORMS
5252
arm64-darwin-22
53+
x86_64-darwin-21
5354

5455
DEPENDENCIES
5556
affirm-ruby!

spec/charge_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@
266266
before do
267267
expect(Affirm::Client).to receive(:request)
268268
.with(:post, "charges/1/update",
269-
order_id: "XYZ-007",
270-
shipping_carrier: "FedEx",
271-
shipping_confirmation: "1ZX007")
269+
{
270+
order_id: "XYZ-007",
271+
shipping_carrier: "FedEx",
272+
shipping_confirmation: "1ZX007"
273+
})
272274
.and_return(failed_response)
273275
end
274276

@@ -310,9 +312,11 @@
310312
before do
311313
expect(Affirm::Client).to receive(:request)
312314
.with(:post, "charges/1/update",
313-
order_id: "XYZ-007",
314-
shipping_carrier: "FedEx",
315-
shipping_confirmation: "1ZX007"
315+
{
316+
order_id: "XYZ-007",
317+
shipping_carrier: "FedEx",
318+
shipping_confirmation: "1ZX007"
319+
}
316320
)
317321
.and_return(successful_response)
318322
end

spec/client_spec.rb

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
require "helper"
22

33
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"
78
end
89
end
910

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)
2614
end
2715
end
2816

@@ -41,6 +29,11 @@
4129
subject.connection.adapter(:test, @stubs)
4230
end
4331

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+
4437
it "makes request to full url" do
4538
response = subject.post("foo", {})
4639
expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo")
@@ -74,6 +67,11 @@
7467
subject.connection.adapter(:test, @stubs)
7568
end
7669

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+
7775
it "makes request to full url" do
7876
response = subject.get("foo", {})
7977
expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo")

0 commit comments

Comments
 (0)