soaspec 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +15 -15
- data/.gitlab-ci.yml +31 -31
- data/.rspec +3 -3
- data/.rubocop.yml +2 -2
- data/CODE_OF_CONDUCT.md +74 -74
- data/ChangeLog +384 -380
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +85 -85
- data/Rakefile +24 -24
- data/Todo.md +6 -6
- data/exe/soaspec +119 -119
- data/exe/soaspec-virtual-server +103 -103
- data/exe/xml_to_yaml_file +60 -60
- data/lib/soaspec.rb +91 -80
- data/lib/soaspec/core_ext/hash.rb +83 -83
- data/lib/soaspec/exchange.rb +234 -234
- data/lib/soaspec/exchange_handlers/exchange_handler.rb +103 -103
- data/lib/soaspec/exchange_handlers/handler_accessors.rb +106 -106
- data/lib/soaspec/exchange_handlers/rest_accessors.rb +92 -92
- data/lib/soaspec/exchange_handlers/rest_handler.rb +311 -311
- data/lib/soaspec/exchange_handlers/rest_methods.rb +44 -44
- data/lib/soaspec/exchange_handlers/soap_handler.rb +236 -236
- data/lib/soaspec/exe_helpers.rb +56 -56
- data/lib/soaspec/generator/.rspec.erb +5 -5
- data/lib/soaspec/generator/.travis.yml.erb +5 -5
- data/lib/soaspec/generator/Gemfile.erb +8 -8
- data/lib/soaspec/generator/README.md.erb +29 -29
- data/lib/soaspec/generator/Rakefile.erb +19 -19
- data/lib/soaspec/generator/config/data/default.yml.erb +1 -1
- data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
- data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
- data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
- data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
- data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
- data/lib/soaspec/generator/spec/spec_helper.rb.erb +20 -20
- data/lib/soaspec/generator/template/soap_template.xml +6 -6
- data/lib/soaspec/interpreter.rb +40 -40
- data/lib/soaspec/matchers.rb +65 -65
- data/lib/soaspec/not_found_errors.rb +13 -13
- data/lib/soaspec/soaspec_shared_examples.rb +24 -24
- data/lib/soaspec/spec_logger.rb +27 -27
- data/lib/soaspec/test_server/bank.wsdl +90 -90
- data/lib/soaspec/test_server/get_bank.rb +160 -160
- data/lib/soaspec/test_server/invoices.rb +27 -27
- data/lib/soaspec/test_server/namespace.xml +14 -14
- data/lib/soaspec/test_server/note.xml +5 -5
- data/lib/soaspec/test_server/puppy_service.rb +20 -20
- data/lib/soaspec/test_server/test_attribute.rb +13 -13
- data/lib/soaspec/version.rb +2 -2
- data/lib/soaspec/wsdl_generator.rb +144 -144
- data/soaspec.gemspec +45 -45
- data/test.wsdl +116 -116
- data/test.xml +10 -10
- data/test_wsdl.rb +43 -43
- metadata +3 -3
data/lib/soaspec/exe_helpers.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
|
2
|
-
require 'fileutils'
|
3
|
-
module Soaspec
|
4
|
-
# Help with tasks common to soaspec executables
|
5
|
-
module ExeHelpers
|
6
|
-
|
7
|
-
# Spec task string depending upon whether virtual is used
|
8
|
-
def spec_task
|
9
|
-
task_name = options[:virtual] ? 'spec: :start_test_server' : ':spec'
|
10
|
-
"RSpec::Core::RakeTask.new(#{task_name}) do |t|"
|
11
|
-
end
|
12
|
-
|
13
|
-
# Retrieve default file contents based on filename
|
14
|
-
def retrieve_contents(filename, erb)
|
15
|
-
default_file = File.join(File.dirname(__FILE__), 'generator', filename + (erb ? '.erb' : ''))
|
16
|
-
contents = File.read(default_file)
|
17
|
-
erb ? ERB.new(contents).result(binding) : contents
|
18
|
-
end
|
19
|
-
|
20
|
-
# @param [String] filename Name of the file to create
|
21
|
-
# @param [String] content Content to place inside file
|
22
|
-
def create_file(filename: nil, content: nil, ignore_if_present: false, erb: true)
|
23
|
-
raise 'Need to pass filename' unless filename
|
24
|
-
content ||= retrieve_contents(filename, erb)
|
25
|
-
if File.exist? filename
|
26
|
-
old_content = File.read(filename)
|
27
|
-
if old_content != content && !ignore_if_present
|
28
|
-
warn "!! #{filename} already exists and differs from template"
|
29
|
-
end
|
30
|
-
else
|
31
|
-
File.open(filename, 'w') { |f| f.puts content }
|
32
|
-
puts 'Created: ' + filename
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def create_folder(folder)
|
37
|
-
if File.exist? folder
|
38
|
-
warn "!! #{folder} already exists and is not a directory" unless File.directory? folder
|
39
|
-
else
|
40
|
-
FileUtils.mkdir folder
|
41
|
-
puts "Created folder: #{folder}/"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Create class representing wsdl in general
|
46
|
-
def class_content
|
47
|
-
ERB.new(File.read(File.join(File.dirname(__FILE__), 'generator', 'lib/dynamic_class_content.rb.erb'))).result(binding)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Create a spec for an WSDL operation
|
51
|
-
# @param [String] operation Used in ERB to create a test for a WSDL operation
|
52
|
-
def generated_soap_spec_for(operation)
|
53
|
-
ERB.new(File.read(File.join(File.dirname(__FILE__), 'generator', 'spec/dynamic_soap_spec.rb.erb'))).result(binding)
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
module Soaspec
|
4
|
+
# Help with tasks common to soaspec executables
|
5
|
+
module ExeHelpers
|
6
|
+
|
7
|
+
# Spec task string depending upon whether virtual is used
|
8
|
+
def spec_task
|
9
|
+
task_name = options[:virtual] ? 'spec: :start_test_server' : ':spec'
|
10
|
+
"RSpec::Core::RakeTask.new(#{task_name}) do |t|"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve default file contents based on filename
|
14
|
+
def retrieve_contents(filename, erb)
|
15
|
+
default_file = File.join(File.dirname(__FILE__), 'generator', filename + (erb ? '.erb' : ''))
|
16
|
+
contents = File.read(default_file)
|
17
|
+
erb ? ERB.new(contents).result(binding) : contents
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [String] filename Name of the file to create
|
21
|
+
# @param [String] content Content to place inside file
|
22
|
+
def create_file(filename: nil, content: nil, ignore_if_present: false, erb: true)
|
23
|
+
raise 'Need to pass filename' unless filename
|
24
|
+
content ||= retrieve_contents(filename, erb)
|
25
|
+
if File.exist? filename
|
26
|
+
old_content = File.read(filename)
|
27
|
+
if old_content != content && !ignore_if_present
|
28
|
+
warn "!! #{filename} already exists and differs from template"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
File.open(filename, 'w') { |f| f.puts content }
|
32
|
+
puts 'Created: ' + filename
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_folder(folder)
|
37
|
+
if File.exist? folder
|
38
|
+
warn "!! #{folder} already exists and is not a directory" unless File.directory? folder
|
39
|
+
else
|
40
|
+
FileUtils.mkdir folder
|
41
|
+
puts "Created folder: #{folder}/"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create class representing wsdl in general
|
46
|
+
def class_content
|
47
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), 'generator', 'lib/dynamic_class_content.rb.erb'))).result(binding)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create a spec for an WSDL operation
|
51
|
+
# @param [String] operation Used in ERB to create a test for a WSDL operation
|
52
|
+
def generated_soap_spec_for(operation)
|
53
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), 'generator', 'spec/dynamic_soap_spec.rb.erb'))).result(binding)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
--require spec_helper
|
2
|
-
--format documentation
|
3
|
-
<%= '--format RspecJunitFormatter --out logs/spec.xml' if options[:ci] == 'jenkins' %>
|
4
|
-
--format html --out logs/spec.html
|
5
|
-
--color
|
1
|
+
--require spec_helper
|
2
|
+
--format documentation
|
3
|
+
<%= '--format RspecJunitFormatter --out logs/spec.xml' if options[:ci] == 'jenkins' %>
|
4
|
+
--format html --out logs/spec.html
|
5
|
+
--color
|
@@ -1,5 +1,5 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.3.4
|
5
|
-
before_install: gem install bundler -v 1.16.0
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.4
|
5
|
+
before_install: gem install bundler -v 1.16.0
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
source 'https://rubygems.org'
|
3
|
-
|
4
|
-
gem 'data_magic'
|
5
|
-
gem 'require_all'
|
6
|
-
gem 'rake'
|
7
|
-
<%= "gem 'rspec_junit_formatter'" if options[:ci] == 'jenkins' %>
|
8
|
-
gem 'soaspec'
|
1
|
+
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
gem 'data_magic'
|
5
|
+
gem 'require_all'
|
6
|
+
gem 'rake'
|
7
|
+
<%= "gem 'rspec_junit_formatter'" if options[:ci] == 'jenkins' %>
|
8
|
+
gem 'soaspec'
|
@@ -1,29 +1,29 @@
|
|
1
|
-
|
2
|
-
# Installation
|
3
|
-
|
4
|
-
Run `bundle install` to install the gems mentioned in the Gemfile.
|
5
|
-
|
6
|
-
To avoid conflict with gems on the machine globally it may be better to specify gem location with:
|
7
|
-
|
8
|
-
`bundle install --path ~/.gem`
|
9
|
-
|
10
|
-
# Running tests
|
11
|
-
On the command line type:
|
12
|
-
`bundle exec rake spec` or simply `bundle exec rake`
|
13
|
-
|
14
|
-
# Structure
|
15
|
-
|
16
|
-
## Tests
|
17
|
-
RSpec tests are within the `spec` folder and end in `_spec`. Setup and teardown for tests is in `spec/spec_helper`
|
18
|
-
|
19
|
-
## Templates
|
20
|
-
These are the base requests with ERB inside them to create smartly changing requests accoring to the test.yml
|
21
|
-
|
22
|
-
## Data
|
23
|
-
Data used in the test is stored in `config/data` folder. The `data_magic` gem is used by default to read files here.
|
24
|
-
|
25
|
-
## Libraries
|
26
|
-
Libaries to be installed are in 'Gemfile'. Specific gem versions can be specified here and enforeced with `bundle exec rake`
|
27
|
-
|
28
|
-
## Reports
|
29
|
-
Reports are shown in the 'logs' folder. By default Rake produces a junit, an html report, and a `traffic.log` file with the API request and responses in it
|
1
|
+
|
2
|
+
# Installation
|
3
|
+
|
4
|
+
Run `bundle install` to install the gems mentioned in the Gemfile.
|
5
|
+
|
6
|
+
To avoid conflict with gems on the machine globally it may be better to specify gem location with:
|
7
|
+
|
8
|
+
`bundle install --path ~/.gem`
|
9
|
+
|
10
|
+
# Running tests
|
11
|
+
On the command line type:
|
12
|
+
`bundle exec rake spec` or simply `bundle exec rake`
|
13
|
+
|
14
|
+
# Structure
|
15
|
+
|
16
|
+
## Tests
|
17
|
+
RSpec tests are within the `spec` folder and end in `_spec`. Setup and teardown for tests is in `spec/spec_helper`
|
18
|
+
|
19
|
+
## Templates
|
20
|
+
These are the base requests with ERB inside them to create smartly changing requests accoring to the test.yml
|
21
|
+
|
22
|
+
## Data
|
23
|
+
Data used in the test is stored in `config/data` folder. The `data_magic` gem is used by default to read files here.
|
24
|
+
|
25
|
+
## Libraries
|
26
|
+
Libaries to be installed are in 'Gemfile'. Specific gem versions can be specified here and enforeced with `bundle exec rake`
|
27
|
+
|
28
|
+
## Reports
|
29
|
+
Reports are shown in the 'logs' folder. By default Rake produces a junit, an html report, and a `traffic.log` file with the API request and responses in it
|
@@ -1,20 +1,20 @@
|
|
1
|
-
|
2
|
-
# The list of task for a Rake file can be seen with `rake -T`
|
3
|
-
require 'rspec/core/rake_task' # See https://relishapp.com/rspec/rspec-core/docs/command-line/rake-task for details
|
4
|
-
|
5
|
-
# This runs `rspec` command with the following options. Type `rake spec` to run this task
|
6
|
-
<%= spec_task %>
|
7
|
-
t.pattern = "spec/*_spec.rb" # Run all specs in 'spec' folder ending in '_spec'
|
8
|
-
<%= 't.fail_on_error = false' if options[:ci] == 'jenkins' %>
|
9
|
-
end
|
10
|
-
|
11
|
-
task default: :spec # This runs the 'spec' task by default when no task is mentioned. E.g., if only `rake` is typed
|
12
|
-
|
13
|
-
<% if @virtual %>
|
14
|
-
desc 'Start virtual web service'
|
15
|
-
task :start_test_server do
|
16
|
-
ENV['test_server_pid'] = Process.spawn('soaspec-virtual-server', err: %w[logs/test_server.log w]).to_s
|
17
|
-
puts 'Running test server at pid ' + ENV['test_server_pid']
|
18
|
-
sleep 0.5 # Wait a little for virtual server to start up
|
19
|
-
end
|
1
|
+
|
2
|
+
# The list of task for a Rake file can be seen with `rake -T`
|
3
|
+
require 'rspec/core/rake_task' # See https://relishapp.com/rspec/rspec-core/docs/command-line/rake-task for details
|
4
|
+
|
5
|
+
# This runs `rspec` command with the following options. Type `rake spec` to run this task
|
6
|
+
<%= spec_task %>
|
7
|
+
t.pattern = "spec/*_spec.rb" # Run all specs in 'spec' folder ending in '_spec'
|
8
|
+
<%= 't.fail_on_error = false' if options[:ci] == 'jenkins' %>
|
9
|
+
end
|
10
|
+
|
11
|
+
task default: :spec # This runs the 'spec' task by default when no task is mentioned. E.g., if only `rake` is typed
|
12
|
+
|
13
|
+
<% if @virtual %>
|
14
|
+
desc 'Start virtual web service'
|
15
|
+
task :start_test_server do
|
16
|
+
ENV['test_server_pid'] = Process.spawn('soaspec-virtual-server', err: %w[logs/test_server.log w]).to_s
|
17
|
+
puts 'Running test server at pid ' + ENV['test_server_pid']
|
18
|
+
sleep 0.5 # Wait a little for virtual server to start up
|
19
|
+
end
|
20
20
|
<% end %>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
small_id:
|
1
|
+
small_id:
|
2
2
|
blz: 100
|
@@ -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,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,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
|