1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-08-28 15:16:18 +03:00

Completele replace evil client with http, saving initial interface and backward compatibility

Этот коммит содержится в:
Ivan Shamatov
2021-10-30 18:51:29 +03:00
родитель 98b9eb2667
Коммит 89b77c0350
13 изменённых файлов: 138 добавлений и 140 удалений

8
spec/fixtures/refund.json поставляемый
Просмотреть файл

@@ -1,8 +1,8 @@
{
"amount": {
"value": "8.00",
"currency": "RUB"
},
"payment_id": "40484c25-1095-4d36-8b17-92672d1e127d",
"value": "8.00",
"currency": "RUB"
},
"payment_id": "40484c25-1095-4d36-8b17-92672d1e127d",
"description": "test refund, idem-key 40484c25-1095-4d36-8b17-92672d1e127d"
}

Просмотреть файл

@@ -13,9 +13,4 @@ RSpec.configure do |config|
config.order = :random
config.filter_run focus: true
config.run_all_when_everything_filtered = true
config.around(:each) do |example|
stub_request(:any, //)
example.run
end
end

Просмотреть файл

@@ -1,9 +1,7 @@
# frozen_string_literal: true
module Yookassa
RSpec.describe Config do
subject { described_class.new }
it { is_expected.to respond_to(:shop_id) }
it { is_expected.to respond_to(:api_key) }
end
RSpec.describe Yookassa::Config do
subject { described_class.new }
it { is_expected.to respond_to(:shop_id) }
it { is_expected.to respond_to(:api_key) }
end

Просмотреть файл

@@ -3,7 +3,10 @@
RSpec.describe Yookassa::Payment do
let(:settings) { { shop_id: "SHOP_ID", api_key: "API_KEY" } }
let(:idempotency_key) { 12_345 }
let(:payment) { described_class.new(settings) }
let(:payment) { described_class.new(**settings) }
let(:body) { File.read("spec/fixtures/payment_response.json") }
before { stub_request(:any, //).to_return(body: body, headers: { "Content-Type" => "application/json" }) }
shared_examples "returns_payment_object" do
it "returns success" do
@@ -38,11 +41,9 @@ RSpec.describe Yookassa::Payment do
end
describe "#create" do
let(:params) { { payment: File.read("spec/fixtures/payment.json") } }
let(:params) { JSON.parse(File.read("spec/fixtures/payment.json")) }
let(:url) { "https://api.yookassa.ru/v3/payments" }
let(:body) { File.read("spec/fixtures/payment_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.create(payment: params, idempotency_key: idempotency_key) }
it "sends a request" do
@@ -56,9 +57,7 @@ RSpec.describe Yookassa::Payment do
describe "#get_payment_info" do
let(:payment_id) { "2490ded1-000f-5000-8000-1f64111bc63e" }
let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}" }
let(:body) { File.read("spec/fixtures/payment_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.get_payment_info(payment_id: payment_id) }
it "sends a request" do
@@ -71,11 +70,8 @@ RSpec.describe Yookassa::Payment do
describe "#capture" do
let(:payment_id) { "2490ded1-000f-5000-8000-1f64111bc63e" }
let(:params) { { payment: File.read("spec/fixtures/payment.json") } }
let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}/capture" }
let(:body) { File.read("spec/fixtures/payment_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.capture(payment_id: payment_id, idempotency_key: idempotency_key) }
it "sends a request" do
@@ -89,9 +85,7 @@ RSpec.describe Yookassa::Payment do
describe "#cancel" do
let(:payment_id) { "2490ded1-000f-5000-8000-1f64111bc63e" }
let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}/cancel" }
let(:body) { File.read("spec/fixtures/payment_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.cancel(payment_id: payment_id, idempotency_key: idempotency_key) }
it "sends a request" do

Просмотреть файл

@@ -3,7 +3,10 @@
RSpec.describe Yookassa::Refund do
let(:settings) { { shop_id: "SHOP_ID", api_key: "API_KEY" } }
let(:idempotency_key) { 12_345 }
let(:payment) { described_class.new(settings) }
let(:payment) { described_class.new(**settings) }
let(:body) { File.read("spec/fixtures/refund_response.json") }
before { stub_request(:any, //).to_return(body: body, headers: { "Content-Type" => "application/json" }) }
shared_examples "returns_refund_object" do
it "returns success" do
@@ -21,11 +24,9 @@ RSpec.describe Yookassa::Refund do
end
describe "#create" do
let(:payload) { File.read("spec/fixtures/refund.json") }
let(:payload) { JSON.parse(File.read("spec/fixtures/refund.json")) }
let(:url) { "https://api.yookassa.ru/v3/refunds" }
let(:body) { File.read("spec/fixtures/refund_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.create(payload: payload, idempotency_key: idempotency_key) }
it "sends a request" do
@@ -39,9 +40,7 @@ RSpec.describe Yookassa::Refund do
describe "#get_refund_info" do
let(:payment_id) { "2490ded1-000f-5000-8000-1f64111bc63e" }
let(:url) { "https://api.yookassa.ru/v3/refunds/#{payment_id}" }
let(:body) { File.read("spec/fixtures/refund_response.json") }
before { stub_request(:any, //).to_return(body: body) }
subject { payment.get_refund_info(payment_id: payment_id) }
it "sends a request" do