Skip to content

Commit c7ffb12

Browse files
committed
Refactor test
1 parent 7a69afe commit c7ffb12

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

spec/checkout_spec.rb

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,17 @@
99
}
1010
end
1111

12-
it 'detects a namespace collision between Checkout and Payment PaymentsApi classes' do
13-
# Load both auto-generated PaymentsApi classes manually
14-
payment_api_path = File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__)
15-
checkout_api_path = File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__)
12+
it 'uses the correct PaymentsApi for the Checkout service' do
13+
# Load both API files to ensure there's no conflict after the fix.
14+
load File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__)
15+
load File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__)
1616

17-
load payment_api_path
18-
load checkout_api_path
19-
20-
# Instantiate what the Checkout facade will call
2117
checkout = Adyen::Checkout.new(@shared_values[:client])
18+
payments_api = checkout.payments_api
2219

23-
# Retrieve the PaymentsApi class reference that the facade resolves to
24-
resolved_class = checkout.payments_api.class
25-
26-
# Verify which service it actually represents
27-
service_name =
28-
if resolved_class.instance_methods.include?(:service_name)
29-
resolved_class.new(@shared_values[:client], @shared_values[:client].checkout.version).service_name
30-
else
31-
resolved_class.to_s
32-
end
33-
34-
puts "service_name"
35-
puts service_name
36-
# This expectation documents the current buggy behavior.
37-
# It should fail once the namespace is properly fixed.
38-
expect(service_name)
39-
.to eq('Adyen::PaymentsApi'),
40-
"Expected Checkout.payments_api to instantiate the Checkout::PaymentsApi class, " \
41-
"but it appears to be using the Payment service implementation instead (#{resolved_class})"
20+
# Verify that the Checkout facade uses the correct PaymentsApi class.
21+
expect(payments_api.class.name).to eq('Adyen::PaymentsApi')
22+
expect(payments_api.service).to eq('Checkout')
4223
end
4324

4425
# must be created manually because every field in the response is an array

0 commit comments

Comments
 (0)