soaspec 0.2.32 → 0.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -15
  3. data/.gitlab-ci.yml +62 -62
  4. data/.rspec +3 -3
  5. data/.rubocop.yml +2 -2
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/ChangeLog +632 -625
  8. data/Dockerfile +7 -7
  9. data/Gemfile +8 -8
  10. data/LICENSE.txt +21 -21
  11. data/README.md +231 -231
  12. data/Rakefile +52 -52
  13. data/Todo.md +16 -16
  14. data/exe/soaspec +138 -138
  15. data/exe/xml_to_yaml_file +43 -43
  16. data/lib/soaspec.rb +106 -105
  17. data/lib/soaspec/baseline.rb +23 -0
  18. data/lib/soaspec/core_ext/hash.rb +44 -44
  19. data/lib/soaspec/cucumber/generic_steps.rb +94 -94
  20. data/lib/soaspec/demo.rb +6 -6
  21. data/lib/soaspec/errors.rb +24 -22
  22. data/lib/soaspec/exchange/exchange.rb +129 -129
  23. data/lib/soaspec/exchange/exchange_extractor.rb +90 -90
  24. data/lib/soaspec/exchange/exchange_properties.rb +28 -28
  25. data/lib/soaspec/exchange/exchange_repeater.rb +21 -21
  26. data/lib/soaspec/exchange/request_builder.rb +70 -70
  27. data/lib/soaspec/exchange/variable_storer.rb +24 -24
  28. data/lib/soaspec/exchange_handlers/exchange_handler.rb +98 -98
  29. data/lib/soaspec/exchange_handlers/exchange_handler_defaults.rb +61 -61
  30. data/lib/soaspec/exchange_handlers/handler_accessors.rb +132 -132
  31. data/lib/soaspec/exchange_handlers/request/rest_request.rb +59 -51
  32. data/lib/soaspec/exchange_handlers/request/soap_request.rb +41 -41
  33. data/lib/soaspec/exchange_handlers/response_extractor.rb +84 -84
  34. data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +111 -111
  35. data/lib/soaspec/exchange_handlers/rest_handler.rb +307 -298
  36. data/lib/soaspec/exchange_handlers/rest_methods.rb +65 -65
  37. data/lib/soaspec/exchange_handlers/rest_parameters.rb +112 -112
  38. data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +42 -42
  39. data/lib/soaspec/exchange_handlers/soap_handler.rb +241 -241
  40. data/lib/soaspec/exe_helpers.rb +94 -94
  41. data/lib/soaspec/generate_server.rb +48 -48
  42. data/lib/soaspec/generator/.rspec.erb +5 -5
  43. data/lib/soaspec/generator/.travis.yml.erb +5 -5
  44. data/lib/soaspec/generator/Gemfile.erb +8 -8
  45. data/lib/soaspec/generator/README.md.erb +29 -29
  46. data/lib/soaspec/generator/Rakefile.erb +19 -19
  47. data/lib/soaspec/generator/config/data/default.yml.erb +2 -2
  48. data/lib/soaspec/generator/css/bootstrap.css +6833 -6833
  49. data/lib/soaspec/generator/features/support/env.rb.erb +3 -3
  50. data/lib/soaspec/generator/generate_exchange.html.erb +47 -47
  51. data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
  52. data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
  53. data/lib/soaspec/generator/lib/new_rest_service.rb.erb +56 -56
  54. data/lib/soaspec/generator/lib/new_soap_service.rb.erb +29 -29
  55. data/lib/soaspec/generator/lib/package_service.rb.erb +2 -2
  56. data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
  57. data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
  58. data/lib/soaspec/generator/spec/rest_spec.rb.erb +9 -9
  59. data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
  60. data/lib/soaspec/generator/spec/spec_helper.rb.erb +23 -23
  61. data/lib/soaspec/generator/template/soap_template.xml +6 -6
  62. data/lib/soaspec/indifferent_hash.rb +9 -9
  63. data/lib/soaspec/interpreter.rb +70 -70
  64. data/lib/soaspec/matchers.rb +140 -118
  65. data/lib/soaspec/o_auth2.rb +142 -142
  66. data/lib/soaspec/soaspec_shared_examples.rb +26 -26
  67. data/lib/soaspec/spec_logger.rb +143 -143
  68. data/lib/soaspec/template_reader.rb +30 -30
  69. data/lib/soaspec/test_server/bank.wsdl +90 -90
  70. data/lib/soaspec/test_server/get_bank.rb +166 -166
  71. data/lib/soaspec/test_server/id_manager.rb +41 -41
  72. data/lib/soaspec/test_server/invoices.rb +29 -29
  73. data/lib/soaspec/test_server/namespace.xml +14 -14
  74. data/lib/soaspec/test_server/note.xml +5 -5
  75. data/lib/soaspec/test_server/puppy_service.rb +21 -21
  76. data/lib/soaspec/test_server/test_attribute.rb +14 -14
  77. data/lib/soaspec/test_server/test_namespace.rb +14 -14
  78. data/lib/soaspec/version.rb +6 -6
  79. data/lib/soaspec/virtual_server.rb +190 -176
  80. data/lib/soaspec/wait.rb +43 -43
  81. data/lib/soaspec/wsdl_generator.rb +215 -215
  82. data/soaspec.gemspec +58 -58
  83. data/test.wsdl +116 -116
  84. data/test.xml +10 -10
  85. data/test_wsdl.rb +43 -43
  86. metadata +4 -3
@@ -1,3 +1,3 @@
1
- require 'soaspec'
2
- require 'require_all'
3
- require_all 'lib'
1
+ require 'soaspec'
2
+ require 'require_all'
3
+ require_all 'lib'
@@ -1,48 +1,48 @@
1
- <html>
2
- <head>
3
- <title>REST Exchange generator</title>
4
- <link rel="stylesheet" href="css/bootstrap.css" type="text/css" charset="utf-8" />
5
- </head>
6
- <body>
7
- <main class="container-fluid">
8
- <h1>REST Exchange generator</h1>
9
- <h2>Handler creator <small><%= GenerateServer.create_params['feedback'] %></small></h2>
10
- <form class="form-horizontal" method="POST" action="/generate">
11
- <div class="form-group">
12
- <label class="col-sm-2 control-label" for="className">Class Name</label>
13
- <div class="col-sm-10">
14
- <input id="className" class="form-control" type="text" name="className"
15
- placeholder="ApiUnderTest" value="<%= GenerateServer.create_params['className'] %>">
16
- <p class="help-block">This is what you will refer to the API in your test code. Use Pascal Case</p>
17
- </div>
18
- </div>
19
- <div class="form-group">
20
- <label class="col-sm-2 control-label" for="baseUrl">Base URL</label>
21
- <div class="col-sm-10">
22
- <input id="baseUrl" class="form-control" type="text" name="baseUrl"
23
- placeholder="https://url/which/api/starts_with" value="<%= GenerateServer.create_params['baseUrl'] %>">
24
- <p class="help-block">Url with which all REST requests using this class will start with.
25
- Exchanges creating using this class can append to this with the 'suburl' parameter.</p>
26
- </div>
27
- </div>
28
- <div class="form-group">
29
- <label class="col-sm-2 control-label" for="basicAuth">Basic Auth</label>
30
- <div class="col-sm-5">
31
- <input id="basicAuthUser" class="form-control" type="text" name="basicAuthUser"
32
- placeholder="user" value="<%= GenerateServer.create_params['basicAuthUser'] %>">
33
- <p class="help-block">Basic auth parameters. Leave empty for none.</p>
34
- </div>
35
- <div class="col-sm-5">
36
- <input id="basicAuthPassword" class="form-control" type="text" name="basicAuthPassword"
37
- placeholder="password" value="<%= GenerateServer.create_params['basicAuthPassword'] %>">
38
- </div>
39
- </div>
40
- <div class="form-group">
41
- <div class="col-sm-offset-2 col-sm-10">
42
- <input type="submit" value="Generate handler" class="btn btn-primary">
43
- </div>
44
- </div>
45
- </form>
46
- </main>
47
- </body>
1
+ <html>
2
+ <head>
3
+ <title>REST Exchange generator</title>
4
+ <link rel="stylesheet" href="css/bootstrap.css" type="text/css" charset="utf-8" />
5
+ </head>
6
+ <body>
7
+ <main class="container-fluid">
8
+ <h1>REST Exchange generator</h1>
9
+ <h2>Handler creator <small><%= GenerateServer.create_params['feedback'] %></small></h2>
10
+ <form class="form-horizontal" method="POST" action="/generate">
11
+ <div class="form-group">
12
+ <label class="col-sm-2 control-label" for="className">Class Name</label>
13
+ <div class="col-sm-10">
14
+ <input id="className" class="form-control" type="text" name="className"
15
+ placeholder="ApiUnderTest" value="<%= GenerateServer.create_params['className'] %>">
16
+ <p class="help-block">This is what you will refer to the API in your test code. Use Pascal Case</p>
17
+ </div>
18
+ </div>
19
+ <div class="form-group">
20
+ <label class="col-sm-2 control-label" for="baseUrl">Base URL</label>
21
+ <div class="col-sm-10">
22
+ <input id="baseUrl" class="form-control" type="text" name="baseUrl"
23
+ placeholder="https://url/which/api/starts_with" value="<%= GenerateServer.create_params['baseUrl'] %>">
24
+ <p class="help-block">Url with which all REST requests using this class will start with.
25
+ Exchanges creating using this class can append to this with the 'suburl' parameter.</p>
26
+ </div>
27
+ </div>
28
+ <div class="form-group">
29
+ <label class="col-sm-2 control-label" for="basicAuth">Basic Auth</label>
30
+ <div class="col-sm-5">
31
+ <input id="basicAuthUser" class="form-control" type="text" name="basicAuthUser"
32
+ placeholder="user" value="<%= GenerateServer.create_params['basicAuthUser'] %>">
33
+ <p class="help-block">Basic auth parameters. Leave empty for none.</p>
34
+ </div>
35
+ <div class="col-sm-5">
36
+ <input id="basicAuthPassword" class="form-control" type="text" name="basicAuthPassword"
37
+ placeholder="password" value="<%= GenerateServer.create_params['basicAuthPassword'] %>">
38
+ </div>
39
+ </div>
40
+ <div class="form-group">
41
+ <div class="col-sm-offset-2 col-sm-10">
42
+ <input type="submit" value="Generate handler" class="btn btn-primary">
43
+ </div>
44
+ </div>
45
+ </form>
46
+ </main>
47
+ </body>
48
48
  </html>
@@ -1,26 +1,26 @@
1
-
2
- require 'soaspec'
3
-
4
- # This class is not part of the gem. It's an example of a class you can make
5
- # to describe your APIs. Usually this would exist in the 'lib' directory
6
- # Common configuration for the Savon client should go here
7
- class BLZService < Soaspec::SoapHandler
8
- # Add to or override default Savon client options
9
- def savon_options
10
- {
11
- wsdl: 'http://localhost:4999/BLZService?wsdl'
12
- }
13
- end
14
-
15
- strip_namespaces true # This allows namespace not to be used. Be careful with this
16
-
17
- # # Specifying that get_weather_result must be present in the SOAP response
18
- mandatory_elements [:plz]
19
-
20
- # Example of xpath value that must be true for all success scenarios
21
- mandatory_xpath_values 'ns1:bezeichnung' => 'Deutsche Bank'
22
-
23
- # Example of setting an attribute on the root XML element
24
- root_attributes 'Version' => '1'
25
-
26
- end
1
+
2
+ require 'soaspec'
3
+
4
+ # This class is not part of the gem. It's an example of a class you can make
5
+ # to describe your APIs. Usually this would exist in the 'lib' directory
6
+ # Common configuration for the Savon client should go here
7
+ class BLZService < Soaspec::SoapHandler
8
+ # Add to or override default Savon client options
9
+ def savon_options
10
+ {
11
+ wsdl: 'http://localhost:4999/BLZService?wsdl'
12
+ }
13
+ end
14
+
15
+ strip_namespaces true # This allows namespace not to be used. Be careful with this
16
+
17
+ # # Specifying that get_weather_result must be present in the SOAP response
18
+ mandatory_elements [:plz]
19
+
20
+ # Example of xpath value that must be true for all success scenarios
21
+ mandatory_xpath_values 'ns1:bezeichnung' => 'Deutsche Bank'
22
+
23
+ # Example of setting an attribute on the root XML element
24
+ root_attributes 'Version' => '1'
25
+
26
+ end
@@ -1,12 +1,12 @@
1
-
2
- require 'soaspec'
3
-
4
- class <%= options[:name] %> < Soaspec::SoapHandler
5
- # Add to or override default Savon client options
6
- def savon_options
7
- {
8
- wsdl: '<%= options[:wsdl] %>'
9
- }
10
- end
11
-
12
- end
1
+
2
+ require 'soaspec'
3
+
4
+ class <%= options[:name] %> < Soaspec::SoapHandler
5
+ # Add to or override default Savon client options
6
+ def savon_options
7
+ {
8
+ wsdl: '<%= options[:wsdl] %>'
9
+ }
10
+ end
11
+
12
+ end
@@ -1,57 +1,57 @@
1
- # This class represent REST Api calls for the <%= @name %> API
2
- class <%= @name %> < Soaspec::RestHandler
3
- ## Defining request
4
-
5
- # All requests to <%= @name %> will start with this url <% if @base_url %>
6
- base_url '<%= @base_url %>'
7
- <% else %>
8
- # TODO: Change this mandatory base_url to the url that all requests to this service start with
9
- # base_url "https://my_host/api/<%= ENV['environment'] %>/api_name" # ERB can be used to make this dynamic based on environment
10
- <% end %>
11
- # Headers that will be sent by default using this Handler
12
- # If symbol is used, they'll be converted to standard HTTP headers
13
- # headers accept: 'application/json', content_type: 'application/json'
14
-
15
- # Filename of oauth2 file to use for oauth2 parameters. 'Soaspec.credentials_folder' can be set to globally defined a folder with credentials
16
- # This will add a default 'Authorization: Bearer access_token' header if 'Authorization' is not specified in headers
17
- # The '.yml' extension will be added automatically if not present.
18
- # oauth2_file 'filename.yml'
19
-
20
- <% unless @basic_auth_user&.empty? %>
21
- # File with basic auth credentials is within the '<%= Soaspec.credentials_folder %>' folder
22
- basic_auth_file '<%= @name.snakecase %>.yml'
23
- <% else %>
24
- # Filename of YAML with basic auth parameters in it 'Soaspec.credentials_folder' can be set to globally defined a folder with credentials
25
- # It is of the format
26
- # user: 'username'
27
- # password: 'password'
28
- # basic_auth_file 'basic_auth.yml' # Load YAML file with basic auth credentials in it
29
- <% end %>
30
-
31
- ### Request Body
32
-
33
- # Filename of template to be used. This is within 'Soaspec.template_folder' folder
34
- # template_name 'filename'
35
-
36
- # Default hash to be used in request that will be converted to JSON. This can be overriden and added to by each Exchange using this class
37
- # default_hash a: 1, b: 2
38
-
39
- ## Extracting response
40
-
41
- # Use this to extract the value of either a JSON (JSONPath) or XML (Xpath) element. 'element_name' is the method that will be
42
- # generated on an Exchange to obtain it
43
- # element :element_name, 'element_path'
44
-
45
- # Use this to extract an attribute from XML. If the name of the method and the attribute name are the same then only one parameter is
46
- # needed
47
- # attribute(:attribute_method_name, 'name_of_attribute')
48
-
49
- ## Creating verifications for success response
50
-
51
- # Values that must have a certain value for 'success scenario' shared example
52
- # mandatory_json_values '$..status' => 'available'
53
-
54
- # Elements that must be in the response for 'success scenario' shared example
55
- # Below will expect an element at the path 'tags' to be present
56
- # mandatory_elements :tags
1
+ # This class represent REST Api calls for the <%= @name %> API
2
+ class <%= @name %> < Soaspec::RestHandler
3
+ ## Defining request
4
+
5
+ # All requests to <%= @name %> will start with this url <% if @base_url %>
6
+ base_url '<%= @base_url %>'
7
+ <% else %>
8
+ # TODO: Change this mandatory base_url to the url that all requests to this service start with
9
+ # base_url "https://my_host/api/<%= ENV['environment'] %>/api_name" # ERB can be used to make this dynamic based on environment
10
+ <% end %>
11
+ # Headers that will be sent by default using this Handler
12
+ # If symbol is used, they'll be converted to standard HTTP headers
13
+ # headers accept: 'application/json', content_type: 'application/json'
14
+
15
+ # Filename of oauth2 file to use for oauth2 parameters. 'Soaspec.credentials_folder' can be set to globally defined a folder with credentials
16
+ # This will add a default 'Authorization: Bearer access_token' header if 'Authorization' is not specified in headers
17
+ # The '.yml' extension will be added automatically if not present.
18
+ # oauth2_file 'filename.yml'
19
+
20
+ <% unless @basic_auth_user&.empty? %>
21
+ # File with basic auth credentials is within the '<%= Soaspec.credentials_folder %>' folder
22
+ basic_auth_file '<%= @name.snakecase %>.yml'
23
+ <% else %>
24
+ # Filename of YAML with basic auth parameters in it 'Soaspec.credentials_folder' can be set to globally defined a folder with credentials
25
+ # It is of the format
26
+ # user: 'username'
27
+ # password: 'password'
28
+ # basic_auth_file 'basic_auth.yml' # Load YAML file with basic auth credentials in it
29
+ <% end %>
30
+
31
+ ### Request Body
32
+
33
+ # Filename of template to be used. This is within 'Soaspec.template_folder' folder
34
+ # template_name 'filename'
35
+
36
+ # Default hash to be used in request that will be converted to JSON. This can be overriden and added to by each Exchange using this class
37
+ # default_hash a: 1, b: 2
38
+
39
+ ## Extracting response
40
+
41
+ # Use this to extract the value of either a JSON (JSONPath) or XML (Xpath) element. 'element_name' is the method that will be
42
+ # generated on an Exchange to obtain it
43
+ # element :element_name, 'element_path'
44
+
45
+ # Use this to extract an attribute from XML. If the name of the method and the attribute name are the same then only one parameter is
46
+ # needed
47
+ # attribute(:attribute_method_name, 'name_of_attribute')
48
+
49
+ ## Creating verifications for success response
50
+
51
+ # Values that must have a certain value for 'success scenario' shared example
52
+ # mandatory_json_values '$..status' => 'available'
53
+
54
+ # Elements that must be in the response for 'success scenario' shared example
55
+ # Below will expect an element at the path 'tags' to be present
56
+ # mandatory_elements :tags
57
57
  end
@@ -1,30 +1,30 @@
1
- # This class represent SOAP Api calls for the <%= @name %> API
2
- class <%= @name %> < Soaspec::SoapHandler
3
- # Wsdl for <%= @name %>
4
- def savon_options
5
- {
6
- # wsdl 'https://my_host/api?wsdl' TODO: Change this to the wsdl that this SOAP service uses
7
- }
8
- end
9
-
10
- ## Verifying on response
11
-
12
- # Values that must have a certain value for 'success scenario' shared example
13
- # mandatory_json_values '$..status' => 'available'
14
-
15
- # Elements that must be in the response for 'success scenario' shared example
16
- # Below will expect an element at the path 'tags' to be present
17
- # mandatory_elements :tags
18
-
19
- # Use this to extract the value of either a JSON (JSONPath) or XML (Xpath) element. 'element_name' is the method that will be
20
- # generated on an Exchange to obtain it
21
- # element :element_name, 'element_path'
22
-
23
- # Use this to extract an attribute from XML. If the name of the method and the attribute name are the same then only one parameter is
24
- # needed
25
- # attribute(:attribute_method_name, 'name_of_attribute')
26
-
27
- # Set an attribute on the root XML element
28
- # root_attributes 'Version' => '1'
29
-
1
+ # This class represent SOAP Api calls for the <%= @name %> API
2
+ class <%= @name %> < Soaspec::SoapHandler
3
+ # Wsdl for <%= @name %>
4
+ def savon_options
5
+ {
6
+ # wsdl 'https://my_host/api?wsdl' TODO: Change this to the wsdl that this SOAP service uses
7
+ }
8
+ end
9
+
10
+ ## Verifying on response
11
+
12
+ # Values that must have a certain value for 'success scenario' shared example
13
+ # mandatory_json_values '$..status' => 'available'
14
+
15
+ # Elements that must be in the response for 'success scenario' shared example
16
+ # Below will expect an element at the path 'tags' to be present
17
+ # mandatory_elements :tags
18
+
19
+ # Use this to extract the value of either a JSON (JSONPath) or XML (Xpath) element. 'element_name' is the method that will be
20
+ # generated on an Exchange to obtain it
21
+ # element :element_name, 'element_path'
22
+
23
+ # Use this to extract an attribute from XML. If the name of the method and the attribute name are the same then only one parameter is
24
+ # needed
25
+ # attribute(:attribute_method_name, 'name_of_attribute')
26
+
27
+ # Set an attribute on the root XML element
28
+ # root_attributes 'Version' => '1'
29
+
30
30
  end
@@ -1,3 +1,3 @@
1
- class PackageService < Soaspec::RestHandler
2
- base_url 'http://localhost:4999/packages'
1
+ class PackageService < Soaspec::RestHandler
2
+ base_url 'http://localhost:4999/packages'
3
3
  end
@@ -1,8 +1,8 @@
1
-
2
- require 'rspec'
3
-
4
- shared_examples_for 'error scenario' do
5
- it 'does not have status code of 200' do
6
- expect(described_class.status_code).not_to eq 200
7
- end
8
- end
1
+
2
+ require 'rspec'
3
+
4
+ shared_examples_for 'error scenario' do
5
+ it 'does not have status code of 200' do
6
+ expect(described_class.status_code).not_to eq 200
7
+ end
8
+ end
@@ -1,12 +1,12 @@
1
-
2
- require 'spec_helper'
3
-
4
- <%= operation %> = <%= options[:name] %>.new(<%= @class_params %>)
5
- <%= operation %>.operation = :<%= operation %>
6
- <%= operation %>.default_hash = data_for '<%= operation %>/default'
7
-
8
- context <%= operation %> do
9
- describe Exchange.new(:default) do
10
- it_behaves_like 'success scenario'
11
- end
12
- end
1
+
2
+ require 'spec_helper'
3
+
4
+ <%= operation %> = <%= options[:name] %>.new(<%= @class_params %>)
5
+ <%= operation %>.operation = :<%= operation %>
6
+ <%= operation %>.default_hash = data_for '<%= operation %>/default'
7
+
8
+ context <%= operation %> do
9
+ describe Exchange.new(:default) do
10
+ it_behaves_like 'success scenario'
11
+ end
12
+ end
@@ -1,9 +1,9 @@
1
- context PackageService.new('Test extract id') do
2
- describe get 'Negative', suburl: '4/40' do
3
- its(['success']) { is_expected.to eq 'false' }
4
- end
5
-
6
- describe get 'Positive', suburl: '4/41' do
7
- its(['success']) { is_expected.to eq 'true' }
8
- end
9
- end
1
+ context PackageService.new('Test extract id') do
2
+ describe get 'Negative', suburl: '4/40' do
3
+ its(['success']) { is_expected.to eq 'false' }
4
+ end
5
+
6
+ describe get 'Positive', suburl: '4/41' do
7
+ its(['success']) { is_expected.to eq 'true' }
8
+ end
9
+ end
@@ -1,51 +1,51 @@
1
-
2
- require 'spec_helper'
3
-
4
- id = '70070010'
5
- # BLZService.new(template_name: 'soap_template') Use this instead of default_hash to use template approach
6
-
7
- context 'Test Examples' do
8
- context BLZService.new('Get Bank', operation: :get_bank, default_hash: { blz: id }) do
9
-
10
- describe Exchange.new(:default) do
11
- it { is_expected.to contain_value id }
12
- it { is_expected.to include_in_body id }
13
- it_behaves_like 'success scenario'
14
- after(:all) { described_class.store(:title, 'bezeichnung') }
15
- end
16
-
17
- describe Exchange.new(:xpath_eg, blz: 100000) do
18
- its(['plz']) { is_expected.to eq '100000' }
19
- it { is_expected.to have_xpath_value '//ns1:bezeichnung' => 'Deutsche Bank' }
20
- context 'Handle retrieving stored value' do
21
- it { is_expected.to have_xpath_value 'bezeichnung' => described_class.retrieve(:title) }
22
- end
23
- end
24
-
25
- describe Exchange.new(:yaml_eg, data_for(:small_id)) do
26
- it_behaves_like 'success scenario'
27
- end
28
-
29
- # Retry for success more for web services that intermittently fail
30
- describe Exchange.new(:short_hand_xpath).retry_for_success do
31
- # Be careful. If you call a method that does not use namespaces, calling one that does may not find the element
32
- its(['ns1:bezeichnung']) { is_expected.to eq 'Deutsche Bank' } # '//' is not required at the beginning
33
- end
34
- describe Exchange.new('Check existence of elements') do
35
- it { is_expected.to have_element_at_xpath '//ns1:bezeichnung' }
36
- it { is_expected.not_to have_element_at_xpath '//ns1:bezeichnung_pretend' }
37
- end
38
- end
39
- end
40
-
41
- error_example = BLZService.new('Error example')
42
- error_example.operation = :get_bank
43
- error_example.default_hash = {}
44
-
45
- context 'Error Examples' do
46
- context error_example do
47
- describe Exchange.new(:no_blz_error) do
48
- it_behaves_like 'error scenario'
49
- end
50
- end
51
- end
1
+
2
+ require 'spec_helper'
3
+
4
+ id = '70070010'
5
+ # BLZService.new(template_name: 'soap_template') Use this instead of default_hash to use template approach
6
+
7
+ context 'Test Examples' do
8
+ context BLZService.new('Get Bank', operation: :get_bank, default_hash: { blz: id }) do
9
+
10
+ describe Exchange.new(:default) do
11
+ it { is_expected.to contain_value id }
12
+ it { is_expected.to include_in_body id }
13
+ it_behaves_like 'success scenario'
14
+ after(:all) { described_class.store(:title, 'bezeichnung') }
15
+ end
16
+
17
+ describe Exchange.new(:xpath_eg, blz: 100000) do
18
+ its(['plz']) { is_expected.to eq '100000' }
19
+ it { is_expected.to have_xpath_value '//ns1:bezeichnung' => 'Deutsche Bank' }
20
+ context 'Handle retrieving stored value' do
21
+ it { is_expected.to have_xpath_value 'bezeichnung' => described_class.retrieve(:title) }
22
+ end
23
+ end
24
+
25
+ describe Exchange.new(:yaml_eg, data_for(:small_id)) do
26
+ it_behaves_like 'success scenario'
27
+ end
28
+
29
+ # Retry for success more for web services that intermittently fail
30
+ describe Exchange.new(:short_hand_xpath).retry_for_success do
31
+ # Be careful. If you call a method that does not use namespaces, calling one that does may not find the element
32
+ its(['ns1:bezeichnung']) { is_expected.to eq 'Deutsche Bank' } # '//' is not required at the beginning
33
+ end
34
+ describe Exchange.new('Check existence of elements') do
35
+ it { is_expected.to have_element_at_xpath '//ns1:bezeichnung' }
36
+ it { is_expected.not_to have_element_at_xpath '//ns1:bezeichnung_pretend' }
37
+ end
38
+ end
39
+ end
40
+
41
+ error_example = BLZService.new('Error example')
42
+ error_example.operation = :get_bank
43
+ error_example.default_hash = {}
44
+
45
+ context 'Error Examples' do
46
+ context error_example do
47
+ describe Exchange.new(:no_blz_error) do
48
+ it_behaves_like 'error scenario'
49
+ end
50
+ end
51
+ end