1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-09-08 03:45:51 +03:00
Этот коммит содержится в:
Andrey
2020-12-07 23:10:23 +03:00
родитель 55dbde6397
Коммит b40b9a32b3
29 изменённых файлов: 133 добавлений и 184 удалений

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

@@ -9,11 +9,10 @@
"confirmation": {
"type": "redirect",
"return_url": "https://url.test",
"confirmation_url": "https://money.yandex.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e"
"confirmation_url": "https://money.yookassa.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e"
},
"created_at": "2019-06-10T21:26:41.395Z",
"metadata": {
},
"metadata": {},
"payment_method": {
"type": "bank_card",
"id": "2490ded1-000f-5000-8000-1f64111bc63e",

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

@@ -1,10 +1,12 @@
# frozen_string_literal: true
begin
require 'pry'
rescue LoadError
nil
end
require 'yandex-checkout'
require 'yookassa'
require 'webmock/rspec'
RSpec.configure do |config|

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

@@ -1,5 +0,0 @@
RSpec.describe YandexCheckout do
it 'has a version number' do
expect(YandexCheckout::VERSION).not_to be nil
end
end

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

@@ -1,13 +1,13 @@
# frozen_string_literal: true
RSpec.describe YandexCheckout::Payment do
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) }
shared_examples 'returns_payment_object' do
it 'returns success' do
expect(subject).to be_kind_of YandexCheckout::Response
expect(subject).to be_kind_of Yookassa::Response
expect(subject.id).to eq '2490ded1-000f-5000-8000-1f64111bc63e'
expect(subject.test).to eq true
expect(subject.paid).to eq false
@@ -18,17 +18,17 @@ RSpec.describe YandexCheckout::Payment do
expect(subject.expires_at).to eq nil
expect(subject.metadata).to eq Hash[]
expect(subject.amount).to be_kind_of YandexCheckout::Entity::Amount
expect(subject.amount).to be_kind_of Yookassa::Entity::Amount
expect(subject.amount.currency).to eq 'RUB'
expect(subject.amount.value).to eq 10.0
expect(subject.confirmation).to be_kind_of YandexCheckout::Entity::Confirmation
expect(subject.confirmation.confirmation_url).to eq 'https://money.yandex.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e'
expect(subject.confirmation).to be_kind_of Yookassa::Entity::Confirmation
expect(subject.confirmation.confirmation_url).to eq 'https://money.yookassa.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e'
expect(subject.confirmation.type).to eq 'redirect'
expect(subject.confirmation.return_url).to eq 'https://url.test'
expect(subject.confirmation.enforce).to eq nil
expect(subject.payment_method).to be_kind_of YandexCheckout::Entity::PaymentMethod
expect(subject.payment_method).to be_kind_of Yookassa::Entity::PaymentMethod
expect(subject.payment_method.card).to eq nil
expect(subject.payment_method.id).to eq '2490ded1-000f-5000-8000-1f64111bc63e'
expect(subject.payment_method.saved).to eq false
@@ -39,7 +39,7 @@ RSpec.describe YandexCheckout::Payment do
describe '#create' do
let(:params) { { payment: File.read('spec/fixtures/payment.json') } }
let(:url) { 'https://payment.yandex.net/api/v3/payments' }
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) }
@@ -55,7 +55,7 @@ RSpec.describe YandexCheckout::Payment do
describe '#get_payment_info' do
let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' }
let(:url) { "https://payment.yandex.net/api/v3/payments/#{payment_id}" }
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) }
@@ -72,7 +72,7 @@ RSpec.describe YandexCheckout::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://payment.yandex.net/api/v3/payments/#{payment_id}/capture" }
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) }
@@ -88,7 +88,7 @@ RSpec.describe YandexCheckout::Payment do
describe '#cancel' do
let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' }
let(:url) { "https://payment.yandex.net/api/v3/payments/#{payment_id}/cancel" }
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) }

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

@@ -1,20 +1,20 @@
# frozen_string_literal: true
RSpec.describe YandexCheckout::Refund do
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) }
shared_examples 'returns_refund_object' do
it 'returns success' do
expect(subject).to be_kind_of YandexCheckout::Response
expect(subject).to be_kind_of Yookassa::Response
expect(subject.id).to eq '2491ab0c-0015-5000-9000-1640c7f1a6f0'
expect(subject.payment_id).to eq '2491a6e2-000f-5000-9000-1480e820ae17'
expect(subject.status).to eq 'succeeded'
expect(subject.created_at).to eq '2019-06-11T11:58:04.502Z'
expect(subject.description).to eq 'test refund, idem-key 78c95366-ec4b-4284-a0fd-41e694bcdf11'
expect(subject.amount).to be_kind_of YandexCheckout::Entity::Amount
expect(subject.amount).to be_kind_of Yookassa::Entity::Amount
expect(subject.amount.currency).to eq 'RUB'
expect(subject.amount.value).to eq 8.0
end
@@ -22,7 +22,7 @@ RSpec.describe YandexCheckout::Refund do
describe '#create' do
let(:payload) { File.read('spec/fixtures/refund.json') }
let(:url) { 'https://payment.yandex.net/api/v3/refunds' }
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) }
@@ -38,7 +38,7 @@ RSpec.describe YandexCheckout::Refund do
describe '#get_refund_info' do
let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' }
let(:url) { "https://payment.yandex.net/api/v3/refunds/#{payment_id}" }
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) }

7
spec/yookassa_spec.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,7 @@
# frozen_string_literal: true
RSpec.describe Yookassa do
it 'has a version number' do
expect(Yookassa::VERSION).not_to be nil
end
end