Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions spec/checkout_sdk/payments/payment_plan_fields_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

RSpec.describe 'authorization_type and payment_plan request fields' do
let(:payment_plan) do
plan = CheckoutSdk::Payments::PaymentPlan.new
plan.amount_variability = 'Fixed'
plan.name = 'Monthly subscription'
plan
end
let(:authorization_type) { 'Estimated' }

shared_examples 'supports authorization_type and payment_plan' do |klass|

Check failure on line 12 in spec/checkout_sdk/payments/payment_plan_fields_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "supports authorization_type and payment_plan" 4 times.

See more on https://sonarcloud.io/project/issues?id=checkout_checkout-sdk-ruby&issues=AZ7fOSvP58NaSze_LA7n&open=AZ7fOSvP58NaSze_LA7n&pullRequest=177
it "#{klass} exposes authorization_type" do
obj = klass.new
obj.authorization_type = authorization_type
expect(obj.authorization_type).to eq(authorization_type)
end

it "#{klass} exposes payment_plan" do
obj = klass.new
obj.payment_plan = payment_plan
expect(obj.payment_plan).to eq(payment_plan)
expect(obj.payment_plan.amount_variability).to eq('Fixed')
end
end

include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::PaymentLink
include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::HostedPaymentsSession
include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::PaymentSessionsRequest
end
Loading