|
9 | 9 | } |
10 | 10 | end |
11 | 11 |
|
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__) |
16 | 16 |
|
17 | | - load payment_api_path |
18 | | - load checkout_api_path |
19 | | - |
20 | | - # Instantiate what the Checkout facade will call |
21 | 17 | checkout = Adyen::Checkout.new(@shared_values[:client]) |
| 18 | + payments_api = checkout.payments_api |
22 | 19 |
|
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') |
42 | 23 | end |
43 | 24 |
|
44 | 25 | # must be created manually because every field in the response is an array |
|
0 commit comments