soapy_bing 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/README.md +18 -18
- data/Rakefile +1 -0
- data/lib/soapy_bing.rb +5 -1
- data/lib/soapy_bing/account.rb +1 -0
- data/lib/soapy_bing/accounts.rb +13 -17
- data/lib/soapy_bing/ads.rb +18 -41
- data/lib/soapy_bing/ads/campaign_performance_report.rb +49 -0
- data/lib/soapy_bing/ads/campaigns.rb +106 -0
- data/lib/soapy_bing/ads/parsers/bulk_csv_parser.rb +34 -0
- data/lib/soapy_bing/ads/parsers/report_csv_parser.rb +45 -0
- data/lib/soapy_bing/ads/report.rb +93 -0
- data/lib/soapy_bing/campaign_management.rb +21 -0
- data/lib/soapy_bing/country_codes.rb +17 -0
- data/lib/soapy_bing/country_codes.yml +727 -0
- data/lib/soapy_bing/customer.rb +1 -0
- data/lib/soapy_bing/helpers.rb +1 -1
- data/lib/soapy_bing/helpers/zip_downloader.rb +1 -0
- data/lib/soapy_bing/oauth_credentials.rb +1 -0
- data/lib/soapy_bing/param_guard.rb +1 -0
- data/lib/soapy_bing/service.rb +69 -0
- data/lib/soapy_bing/service_operation.rb +62 -0
- data/lib/soapy_bing/version.rb +2 -1
- data/lib/soapy_bing/wsdl/ad_insight.wsdl +1 -0
- data/lib/soapy_bing/wsdl/bulk.wsdl +1 -0
- data/lib/soapy_bing/wsdl/campaign_management.wsdl +1 -0
- data/lib/soapy_bing/wsdl/customer_billing.wsdl +1 -0
- data/lib/soapy_bing/wsdl/customer_management.wsdl +1 -0
- data/lib/soapy_bing/wsdl/reporting.wsdl +1 -0
- data/lib/tasks/console.rake +1 -0
- data/lib/tasks/coverage.rake +1 -0
- data/lib/tasks/spec.rake +1 -0
- data/lib/tasks/upate_wsdl_files.rake +23 -0
- data/lib/tasks/update_country_codes.rake +24 -0
- data/soapy_bing.gemspec +2 -1
- data/spec/fixtures/ads/campaign_performance_report.csv +37 -0
- data/spec/fixtures/ads/campaign_performance_report.json +170 -0
- data/spec/fixtures/ads/campaigns_by_account_id.csv +7 -0
- data/spec/fixtures/{bulk/campaigns.json → ads/campaigns_by_account_id.json} +496 -240
- data/spec/fixtures/ads/campaigns_by_campaign_ids.csv +5 -0
- data/spec/fixtures/ads/campaigns_by_campaign_ids.json +910 -0
- data/spec/fixtures/vcr_cassettes/SoapyBing_Accounts/_list/returns_a_list_of_SoapyBing_Account_objects.yml +27 -27
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_campaigns/by_account_id/returns_parsed_rows.yml +301 -0
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_campaigns/by_campaign_ids/returns_parsed_rows.yml +300 -0
- data/spec/fixtures/vcr_cassettes/SoapyBing_CampaignManagement/_get_geo_locations/returns_a_list_of_geo_locations_hashes.yml +154 -0
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_pending_status.yml +65 -94
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_empty_response.yml +511 -0
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_response.yml +384 -0
- data/spec/integration/soapy_bing/accounts_spec.rb +1 -0
- data/spec/integration/soapy_bing/ads_campaigns_spec.rb +85 -0
- data/spec/integration/soapy_bing/campaign_management_spec.rb +22 -0
- data/spec/integration/soapy_bing/oauth_credentials_spec.rb +1 -0
- data/spec/simplecov_setup.rb +1 -0
- data/spec/soapy_bing/account_spec.rb +6 -2
- data/spec/soapy_bing/accounts_spec.rb +47 -0
- data/spec/soapy_bing/ads/campaign_performance_report_spec.rb +79 -0
- data/spec/soapy_bing/ads/campaigns_spec.rb +99 -0
- data/spec/soapy_bing/ads/{bulk/parsers/csv_parser_spec.rb → parsers/bulk_csv_parser_spec.rb} +5 -4
- data/spec/soapy_bing/ads/{reports/parsers/csv_parser_spec.rb → parsers/report_csv_parser_spec.rb} +6 -4
- data/spec/soapy_bing/country_codes_spec.rb +39 -0
- data/spec/soapy_bing/helpers/zip_downloader_spec.rb +2 -0
- data/spec/soapy_bing/oauth_credentials_spec.rb +6 -2
- data/spec/soapy_bing/param_guard_spec.rb +2 -0
- data/spec/soapy_bing/service_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/dotenv.rb +1 -0
- data/spec/support/vcr.rb +75 -6
- metadata +74 -118
- data/lib/soapy_bing/ads/bulk.rb +0 -3
- data/lib/soapy_bing/ads/bulk/campaigns.rb +0 -65
- data/lib/soapy_bing/ads/bulk/parsers.rb +0 -2
- data/lib/soapy_bing/ads/bulk/parsers/csv_parser.rb +0 -35
- data/lib/soapy_bing/ads/reports.rb +0 -4
- data/lib/soapy_bing/ads/reports/base.rb +0 -74
- data/lib/soapy_bing/ads/reports/campaign_performance_report.rb +0 -24
- data/lib/soapy_bing/ads/reports/parsers.rb +0 -2
- data/lib/soapy_bing/ads/reports/parsers/csv_parser.rb +0 -46
- data/lib/soapy_bing/helpers/class_name.rb +0 -10
- data/lib/soapy_bing/soap.rb +0 -4
- data/lib/soapy_bing/soap/request.rb +0 -10
- data/lib/soapy_bing/soap/request/base.rb +0 -38
- data/lib/soapy_bing/soap/request/download_campaigns_by_account_ids_request.rb +0 -17
- data/lib/soapy_bing/soap/request/get_accounts_info_request.rb +0 -17
- data/lib/soapy_bing/soap/request/get_ad_groups_by_campaign_id_request.rb +0 -17
- data/lib/soapy_bing/soap/request/get_ads_by_ad_group_id_request.rb +0 -17
- data/lib/soapy_bing/soap/request/get_bulk_download_status_request.rb +0 -17
- data/lib/soapy_bing/soap/request/get_targets_by_campaign_ids_request.rb +0 -17
- data/lib/soapy_bing/soap/request/poll_generate_report_request.rb +0 -34
- data/lib/soapy_bing/soap/request/submit_generate_report_request.rb +0 -17
- data/lib/soapy_bing/soap/response.rb +0 -14
- data/lib/soapy_bing/soap/response/base.rb +0 -17
- data/lib/soapy_bing/soap/response/download_campaigns_by_account_ids_response.rb +0 -12
- data/lib/soapy_bing/soap/response/get_accounts_info_response.rb +0 -12
- data/lib/soapy_bing/soap/response/get_ad_groups_by_campaign_id_response.rb +0 -12
- data/lib/soapy_bing/soap/response/get_ads_by_ad_group_id_response.rb +0 -12
- data/lib/soapy_bing/soap/response/get_bulk_download_status_response.rb +0 -17
- data/lib/soapy_bing/soap/response/get_targets_by_campaign_ids_response.rb +0 -12
- data/lib/soapy_bing/soap/response/payload.rb +0 -28
- data/lib/soapy_bing/soap/response/poll_generate_report_response.rb +0 -14
- data/lib/soapy_bing/soap/response/report_status.rb +0 -34
- data/lib/soapy_bing/soap/response/submit_generate_report_response.rb +0 -12
- data/lib/soapy_bing/soap/template_renderer.rb +0 -22
- data/lib/soapy_bing/soap/templates/download_campaigns_by_account_ids.xml.erb +0 -22
- data/lib/soapy_bing/soap/templates/get_accounts_info.xml.erb +0 -12
- data/lib/soapy_bing/soap/templates/get_ad_groups_by_campaign_id.xml.erb +0 -15
- data/lib/soapy_bing/soap/templates/get_ads_by_ad_group_id.xml.erb +0 -15
- data/lib/soapy_bing/soap/templates/get_bulk_download_status.xml.erb +0 -15
- data/lib/soapy_bing/soap/templates/get_targets_by_campaign_ids.xml.erb +0 -20
- data/lib/soapy_bing/soap/templates/poll_generate_report.xml.erb +0 -18
- data/lib/soapy_bing/soap/templates/submit_generate_report.xml.erb +0 -46
- data/spec/fixtures/bulk/campaigns.csv +0 -8
- data/spec/fixtures/get_ad_groups_by_campaign_id.json +0 -587
- data/spec/fixtures/get_ads_by_ad_group_id.json +0 -218
- data/spec/fixtures/get_targets_by_campaign_ids.json +0 -81
- data/spec/fixtures/reports/campaign_performance_report.csv +0 -37
- data/spec/fixtures/reports/campaign_performance_report.json +0 -146
- data/spec/fixtures/soap_templates/simple.xml.erb +0 -2
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ad_groups_by_campaign_id/1_1_1.yml +0 -150
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ads_by_ad_group_id/1_2_1.yml +0 -141
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_targets_by_campaign_ids/1_3_1.yml +0 -111
- data/spec/fixtures/vcr_cassettes/SoapyBing_Ads_Bulk_Campaigns/_result_file_url/returns_result_file_url.yml +0 -216
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_status.yml +0 -284
- data/spec/integration/soapy_bing/ads/bulk/campaigns_spec.rb +0 -35
- data/spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb +0 -40
- data/spec/integration/soapy_bing/ads_spec.rb +0 -32
- data/spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb +0 -42
- data/spec/soapy_bing/ads_spec.rb +0 -33
- data/spec/soapy_bing/helpers/class_name_spec.rb +0 -15
- data/spec/soapy_bing/soap/request/base_spec.rb +0 -55
- data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +0 -60
- data/spec/soapy_bing/soap/response/base_spec.rb +0 -13
- data/spec/soapy_bing/soap/response/get_bulk_download_status_response_spec.rb +0 -60
- data/spec/soapy_bing/soap/response/payload_spec.rb +0 -48
- data/spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb +0 -26
- data/spec/soapy_bing/soap/response/report_status_spec.rb +0 -92
- data/spec/soapy_bing/soap/response/submit_generate_report_response_spec.rb +0 -20
- data/spec/soapy_bing/soap/template_renderer_spec.rb +0 -25
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Helpers::ClassName do
|
3
|
-
describe '#class_name' do
|
4
|
-
subject(:class_name) do
|
5
|
-
stub_const(
|
6
|
-
'OUTERNS::INNERNS::MyClass',
|
7
|
-
Class.new.include(described_class)
|
8
|
-
).new.class_name
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'resolves class name' do
|
12
|
-
expect(class_name).to eq 'MyClass'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Request::Base do
|
3
|
-
let(:req_context) { { foo: 'Bar' } }
|
4
|
-
subject(:request) { described_class.new(context: req_context) }
|
5
|
-
|
6
|
-
before { stub_const('MyCustomRequest', Class.new(described_class) {}) }
|
7
|
-
let(:my_custom_request) { MyCustomRequest.new(context: req_context) }
|
8
|
-
|
9
|
-
describe '#context' do
|
10
|
-
it 'keeps initialized value' do
|
11
|
-
expect(request.context).to eq req_context
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#post' do
|
16
|
-
let(:body) { 'my body' }
|
17
|
-
let(:headers) { { 'My' => 'Header' } }
|
18
|
-
|
19
|
-
it 'delegates post request to HTTParty' do
|
20
|
-
expect(HTTParty).to receive(:post).with(
|
21
|
-
'http://example.com',
|
22
|
-
hash_including(body: body, headers: hash_including(headers))
|
23
|
-
)
|
24
|
-
request.post('http://example.com', body: body, headers: headers)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#default_body' do
|
29
|
-
subject(:default_body) { my_custom_request.default_body }
|
30
|
-
it 'renders request body template' do
|
31
|
-
renderer = instance_double(SoapyBing::Soap::TemplateRenderer)
|
32
|
-
expect(SoapyBing::Soap::TemplateRenderer).to receive(:new)
|
33
|
-
.with(hash_including(req_context)).and_return(renderer)
|
34
|
-
expect(renderer).to receive(:render).with('my_custom')
|
35
|
-
default_body
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#default_headers' do
|
40
|
-
subject(:default_headers) { my_custom_request.default_headers }
|
41
|
-
it 'contains soap action' do
|
42
|
-
expect(default_headers).to include('SOAPAction' => 'MyCustom')
|
43
|
-
end
|
44
|
-
it 'contains default headers' do
|
45
|
-
expect(default_headers).to include(described_class::DEFAULT_HTTP_HEADERS)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#action_name' do
|
50
|
-
subject(:action_name) { my_custom_request.action_name }
|
51
|
-
it 'resolves request\'s class soap action' do
|
52
|
-
expect(action_name).to eq 'MyCustom'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Request::PollGenerateReportRequest do
|
3
|
-
describe '#perform' do
|
4
|
-
let(:response_body) do
|
5
|
-
{
|
6
|
-
'Envelope' => {
|
7
|
-
'Body' => {
|
8
|
-
'PollGenerateReportResponse' => {
|
9
|
-
'ReportRequestStatus' => {
|
10
|
-
'Status' => nil,
|
11
|
-
'ReportDownloadUrl' => 'http://example.com'
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:pending_response_body) do
|
20
|
-
response_body['Envelope']['Body']['PollGenerateReportResponse'] \
|
21
|
-
['ReportRequestStatus']['Status'] = 'Pending'
|
22
|
-
response_body
|
23
|
-
end
|
24
|
-
let(:successful_response_body) do
|
25
|
-
response_body['Envelope']['Body']['PollGenerateReportResponse'] \
|
26
|
-
['ReportRequestStatus']['Status'] = 'Success'
|
27
|
-
response_body
|
28
|
-
end
|
29
|
-
|
30
|
-
before do
|
31
|
-
call_count = 0
|
32
|
-
allow(HTTParty).to receive(:post) do
|
33
|
-
call_count += 1
|
34
|
-
call_count == 3 ? successful_response_body : pending_response_body
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
subject(:perform) do
|
39
|
-
described_class
|
40
|
-
.new(
|
41
|
-
context: {
|
42
|
-
oauth: instance_double(SoapyBing::OauthCredentials).as_null_object,
|
43
|
-
account: instance_double(SoapyBing::Account).as_null_object
|
44
|
-
}
|
45
|
-
)
|
46
|
-
.perform
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'polls until successful response' do
|
50
|
-
expect(HTTParty).to receive(:post).exactly(3).times
|
51
|
-
expect(perform.payload).to eq 'http://example.com'
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'throws PollingTimeoutError when exceeded polling tries' do
|
55
|
-
stub_const('SoapyBing::Soap::Request::PollGenerateReportRequest::POLLING_TRIES', 1)
|
56
|
-
expect(HTTParty).to receive(:post).once
|
57
|
-
expect { perform }.to raise_error described_class::PollingTimeoutError
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::Base do
|
3
|
-
before { stub_const('MyCustomResponse', Class.new(described_class) {}) }
|
4
|
-
let(:response_body) { 'Some response body' }
|
5
|
-
let(:my_custom_response) { MyCustomResponse.new(response_body) }
|
6
|
-
|
7
|
-
describe '#body' do
|
8
|
-
subject(:body) { my_custom_response.body }
|
9
|
-
it 'keeps initialized value' do
|
10
|
-
expect(body).to eq response_body
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::GetBulkDownloadStatusResponse do
|
3
|
-
subject(:response) { described_class.new(response_hash) }
|
4
|
-
|
5
|
-
describe '#payload' do
|
6
|
-
context 'in progress status response' do
|
7
|
-
let(:response_hash) do
|
8
|
-
{
|
9
|
-
'Envelope' => {
|
10
|
-
'Body' => {
|
11
|
-
'GetBulkDownloadStatusResponse' => {
|
12
|
-
'Errors' => nil,
|
13
|
-
'PercentComplete' => '42',
|
14
|
-
'RequestStatus' => 'InProgress',
|
15
|
-
'ResultFileUrl' => nil
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns status and percent complete' do
|
23
|
-
expect(response.payload).to include(
|
24
|
-
'PercentComplete' => '42',
|
25
|
-
'RequestStatus' => 'InProgress',
|
26
|
-
'ResultFileUrl' => nil
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'failed status response' do
|
32
|
-
let(:response_hash) do
|
33
|
-
{
|
34
|
-
'Envelope' => {
|
35
|
-
'Body' => {
|
36
|
-
'GetBulkDownloadStatusResponse' => {
|
37
|
-
'Errors' => [
|
38
|
-
'OperationError' => {
|
39
|
-
'Code' => '0',
|
40
|
-
'ErrorCode' => 'InternalError',
|
41
|
-
'Message' => 'An internal error has occurred'
|
42
|
-
}
|
43
|
-
],
|
44
|
-
'PercentComplete' => '0',
|
45
|
-
'RequestStatus' => 'Failed',
|
46
|
-
'ResultFileUrl' => nil
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'raises a StatusFailed exception with error message' do
|
54
|
-
expect { response.payload }.to raise_error(
|
55
|
-
described_class::StatusFailed, /An internal error has occurred/
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::Payload do
|
3
|
-
before do
|
4
|
-
stub_const(
|
5
|
-
'MyCustomResponse',
|
6
|
-
Class.new(SoapyBing::Soap::Response::Base).include(described_class)
|
7
|
-
)
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:body) { {} }
|
11
|
-
subject(:response) { MyCustomResponse.new(body) }
|
12
|
-
|
13
|
-
describe '#payload' do
|
14
|
-
it 'memoize #extract_payload value' do
|
15
|
-
expect(response).to receive(:extract_payload).once.and_return(true)
|
16
|
-
2.times { response.payload }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'faulty response' do
|
20
|
-
let(:body) do
|
21
|
-
{
|
22
|
-
'Envelope' => {
|
23
|
-
'Body' => {
|
24
|
-
'Fault' => {
|
25
|
-
'FaultCode' => '123',
|
26
|
-
'FaultMessage' => 'Fault Test'
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
end
|
32
|
-
let(:expected_error_message) do
|
33
|
-
'{"FaultCode"=>"123", "FaultMessage"=>"Fault Test"}'
|
34
|
-
end
|
35
|
-
it 'raises a Fault exception with fault message' do
|
36
|
-
expect { response.payload }.to raise_error(
|
37
|
-
SoapyBing::Soap::Response::Payload::Fault, expected_error_message
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#extract_payload' do
|
44
|
-
it 'throws NotImplementedError' do
|
45
|
-
expect { response.extract_payload }.to raise_error NotImplementedError
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::PollGenerateReportResponse do
|
3
|
-
let(:url) { 'http://my-site.com' }
|
4
|
-
let(:response_hash) do
|
5
|
-
{
|
6
|
-
'Envelope' => {
|
7
|
-
'Body' => {
|
8
|
-
'PollGenerateReportResponse' => {
|
9
|
-
'ReportRequestStatus' => {
|
10
|
-
'ReportDownloadUrl' => url
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
end
|
17
|
-
subject(:response) { described_class.new(response_hash) }
|
18
|
-
|
19
|
-
it 'includes ReportStatus' do
|
20
|
-
expect(described_class.ancestors).to include SoapyBing::Soap::Response::ReportStatus
|
21
|
-
end
|
22
|
-
|
23
|
-
it '#extract_payload returns download url' do
|
24
|
-
expect(response.extract_payload).to eq url
|
25
|
-
end
|
26
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::ReportStatus do
|
3
|
-
before do
|
4
|
-
stub_const(
|
5
|
-
'MyCustomResponse',
|
6
|
-
Class
|
7
|
-
.new(SoapyBing::Soap::Response::Base)
|
8
|
-
.include(described_class)
|
9
|
-
)
|
10
|
-
end
|
11
|
-
let(:response_hash) do
|
12
|
-
{
|
13
|
-
'Envelope' => {
|
14
|
-
'Body' => {
|
15
|
-
'MyCustomResponse' => {
|
16
|
-
'ReportRequestStatus' => {
|
17
|
-
'Status' => nil
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
end
|
24
|
-
subject(:response) { MyCustomResponse.new(response_hash) }
|
25
|
-
|
26
|
-
describe 'status' do
|
27
|
-
before do
|
28
|
-
response_hash['Envelope']['Body']['MyCustomResponse']['ReportRequestStatus']
|
29
|
-
.merge!('Status' => status)
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when error' do
|
33
|
-
let(:status) { 'Error' }
|
34
|
-
|
35
|
-
it '#status is Error' do
|
36
|
-
expect(response.status).to eq status
|
37
|
-
end
|
38
|
-
|
39
|
-
it '#error? is false' do
|
40
|
-
expect(response).to be_error
|
41
|
-
end
|
42
|
-
|
43
|
-
it '#success? is false' do
|
44
|
-
expect(response).not_to be_success
|
45
|
-
end
|
46
|
-
|
47
|
-
it '#pending? is false' do
|
48
|
-
expect(response).not_to be_pending
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when success' do
|
53
|
-
let(:status) { 'Success' }
|
54
|
-
|
55
|
-
it '#status is Success' do
|
56
|
-
expect(response.status).to eq status
|
57
|
-
end
|
58
|
-
|
59
|
-
it '#error? is false' do
|
60
|
-
expect(response).not_to be_error
|
61
|
-
end
|
62
|
-
|
63
|
-
it '#success? is true' do
|
64
|
-
expect(response).to be_success
|
65
|
-
end
|
66
|
-
|
67
|
-
it '#pending? is false' do
|
68
|
-
expect(response).not_to be_pending
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when pending' do
|
73
|
-
let(:status) { 'Pending' }
|
74
|
-
|
75
|
-
it '#status is Pending' do
|
76
|
-
expect(response.status).to eq status
|
77
|
-
end
|
78
|
-
|
79
|
-
it '#error? is false' do
|
80
|
-
expect(response).not_to be_error
|
81
|
-
end
|
82
|
-
|
83
|
-
it '#success? is false' do
|
84
|
-
expect(response).not_to be_success
|
85
|
-
end
|
86
|
-
|
87
|
-
it '#pending? is true' do
|
88
|
-
expect(response).to be_pending
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::Response::SubmitGenerateReportResponse do
|
3
|
-
let(:request_id) { 'foobarbazqux' }
|
4
|
-
let(:response_hash) do
|
5
|
-
{
|
6
|
-
'Envelope' => {
|
7
|
-
'Body' => {
|
8
|
-
'SubmitGenerateReportResponse' => {
|
9
|
-
'ReportRequestId' => request_id
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
end
|
15
|
-
subject(:response) { described_class.new(response_hash) }
|
16
|
-
|
17
|
-
it '#extract_payload returns request id' do
|
18
|
-
expect(response.extract_payload).to eq request_id
|
19
|
-
end
|
20
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.describe SoapyBing::Soap::TemplateRenderer do
|
3
|
-
describe '::TEMPLATE_PATH' do
|
4
|
-
let(:files) { Dir.glob(File.join(described_class::TEMPLATE_PATH, '*.xml.erb')) }
|
5
|
-
|
6
|
-
it 'points to folder with *.xml.erb files' do
|
7
|
-
expect(files.size).to be > 1
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#render' do
|
12
|
-
let(:renderer) { described_class.new(greeting: 'Hello', target: 'World', provocation: '< &') }
|
13
|
-
|
14
|
-
before do
|
15
|
-
stub_const(
|
16
|
-
"#{described_class}::TEMPLATE_PATH",
|
17
|
-
File.join('spec', 'fixtures', 'soap_templates')
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns text with interpolated variables' do
|
22
|
-
expect(renderer.render(:simple)).to eq "Hello, World!\n< &\n"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|