1+ require 'spec_helper'
2+ require 'json'
3+
4+ RSpec . describe Adyen ::OpenBanking , service : 'OpenBanking' do
5+ before ( :all ) do
6+ @shared_values = {
7+ client : create_client ( :api_key ) ,
8+ service : 'OpenBanking'
9+ }
10+ end
11+
12+ it 'makes a create_account_verification_routes POST call' do
13+ request_body = JSON . parse ( json_from_file ( 'mocks/requests/OpenBanking/create_account_verification_routes.json' ) )
14+ response_body = json_from_file ( 'mocks/responses/OpenBanking/create_account_verification_routes.json' )
15+
16+ url = @shared_values [ :client ] . service_url (
17+ @shared_values [ :service ] ,
18+ 'accountVerification/routes' ,
19+ @shared_values [ :client ] . open_banking . version
20+ )
21+ WebMock . stub_request ( :post , url )
22+ . with (
23+ body : request_body ,
24+ headers : {
25+ 'x-api-key' => @shared_values [ :client ] . api_key
26+ }
27+ )
28+ . to_return (
29+ body : response_body
30+ )
31+
32+ result = @shared_values [ :client ] . open_banking . account_verification_api . create_account_verification_routes ( request_body )
33+ response_hash = result . response
34+
35+ expect ( result . status ) . to eq ( 200 )
36+ expect ( response_hash ) . to eq ( JSON . parse ( response_body ) )
37+ expect ( response_hash ) . to be_a Adyen ::HashWithAccessors
38+ expect ( response_hash ) . to be_a_kind_of Hash
39+ end
40+
41+ it 'makes a get_account_verification_report GET call' do
42+ response_body = json_from_file ( 'mocks/responses/OpenBanking/get_account_verification_report.json' )
43+ code = 'some-verification-code'
44+
45+ url = @shared_values [ :client ] . service_url (
46+ @shared_values [ :service ] ,
47+ "accountVerification/reports/#{ code } " ,
48+ @shared_values [ :client ] . open_banking . version
49+ )
50+ WebMock . stub_request ( :get , url )
51+ . with (
52+ headers : {
53+ 'x-api-key' => @shared_values [ :client ] . api_key
54+ }
55+ )
56+ . to_return (
57+ body : response_body
58+ )
59+
60+ result = @shared_values [ :client ] . open_banking . account_verification_api . get_account_verification_report ( code )
61+ response_hash = result . response
62+
63+ expect ( result . status ) . to eq ( 200 )
64+ expect ( response_hash ) . to eq ( JSON . parse ( response_body ) )
65+ expect ( response_hash ) . to be_a Adyen ::HashWithAccessors
66+ expect ( response_hash ) . to be_a_kind_of Hash
67+ end
68+ end
0 commit comments