soaspec 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9e706722f34e7890feb47a8e56bde1fa5cbed45
4
- data.tar.gz: a5a8574360353674f7cc7fc753916082056f49c3
3
+ metadata.gz: 83ae8790fbb996c10af64623bea6e7be9e6372b1
4
+ data.tar.gz: ff46acc85fb7aceae9079a033d659f93b3dd3798
5
5
  SHA512:
6
- metadata.gz: 265da1e3514f9ba0ad3e47ab6999279d0b1b57ff9667bd8fac6536bee12a748cf88a98a9d25f26e0257c66f3e6fc7d895c3cff6dcfeb156d8db996e2feb7be53
7
- data.tar.gz: aebc6ae4895a036b28b7c092d18dffff39e15f0bbc8da72f752ec8fb89e6acbca7d4dc872edd3eff3d047e50db4e356c2047cb8b47f828e14b69f83c845723db
6
+ metadata.gz: e1e699420cd01b427c8259c8404ac3d53385d304e32767b4b20385fdde13d72ccad836055f0073712745e6a99aeb323faf5700118f0bd106fe23fdf904f4c7d7
7
+ data.tar.gz: d1eadfde7e77d7dc43dd3819fb73cfed1e2eced1d4ded41bcd16813115769fc82beebe2716901413896d416e8a2253d80b0b3e09e7240c0ce95ecaf824a02164
@@ -13,6 +13,11 @@ rspec:
13
13
  paths:
14
14
  - coverage/
15
15
 
16
+ cucumber:
17
+ stage: acceptance
18
+ script:
19
+ - bundle exec cucumber
20
+
16
21
  pages:
17
22
  stage: deploy
18
23
  dependencies:
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.0.58
2
+ * Enhancements
3
+ * Add method to set parts of the request body through `exchange[key]= 'value'`
4
+ * Added example of Cucumber feature demonstrating this
5
+
1
6
  Version 0.0.56
2
7
  * Bug fix
3
8
  * Handle creating of traffic.log file within lib properly
data/Rakefile CHANGED
@@ -27,6 +27,7 @@ CLOBBER.include 'logs/*'
27
27
 
28
28
  desc 'Start virtual web service'
29
29
  task :start_test_server do
30
+ mkdir_p 'logs'
30
31
  ENV['test_server_pid'] = Process.spawn('ruby', 'exe/soaspec-virtual-server', err: %w[logs/test_server.log w]).to_s
31
32
  sleep 1 # Wait a little for virtual server to start up
32
33
  puts 'Running test server at pid ' + ENV['test_server_pid']
@@ -7,6 +7,8 @@ class Exchange
7
7
  attr_reader :api_class
8
8
  # How many times to retry for a success
9
9
  attr_accessor :retry_count
10
+ # Params used when making a request
11
+ attr_accessor :default_params
10
12
 
11
13
  # Set retry for success variable to true so that request will be retried
12
14
  # for retry_count until it's true
@@ -35,13 +37,24 @@ class Exchange
35
37
  end
36
38
  end
37
39
 
40
+ # Merge exchange initialized request params with ones set later on
41
+ def merge_request_body
42
+ if @override_parameters[:body]
43
+ @override_parameters[:body].merge!(default_params[:body])
44
+ @override_parameters
45
+ else
46
+ @override_parameters.merge(default_params[:body])
47
+ end
48
+ end
49
+
38
50
  # Make request to handler with parameters defined
39
51
  # Will retry until success code reached if retry_for_success? is set
40
52
  # @return [Response] Response from Api handler
41
53
  def make_request
42
54
  Soaspec::SpecLogger.add_to 'Example ' + @test_name
55
+ request_params = default_params ? merge_request_body : @override_parameters
43
56
  retry_count.times do
44
- response = @api_class.make_request(@override_parameters)
57
+ response = @api_class.make_request(request_params)
45
58
  return response unless retry_for_success?
46
59
  return response if (200..299).cover? @api_class.status_code_for(response)
47
60
  response
@@ -79,6 +92,8 @@ class Exchange
79
92
  @response ||= make_request
80
93
  end
81
94
 
95
+ alias call response
96
+
82
97
  # Get status code from api class. This is http response for Web Api
83
98
  # @return [Integer] Status code from api class
84
99
  def status_code
@@ -103,4 +118,12 @@ class Exchange
103
118
  @api_class.value_from_path(response, path.to_s)
104
119
  end
105
120
 
121
+ # Set a parameter request in the request body.
122
+ # Can be used to build a request over several steps (e.g Cucumber)
123
+ # Will be used with FactoryBot
124
+ def []=(key, value)
125
+ self.default_params = { body: {} } unless default_params # Initialize as Hash if not set
126
+ default_params[:body][key] = value
127
+ end
128
+
106
129
  end
@@ -86,10 +86,16 @@ module Soaspec
86
86
  @client = Savon.client(merged_options)
87
87
  end
88
88
 
89
+ # Used in making request via hash or in template via Erb
90
+ def request_body_params(request_parameters)
91
+ test_values = request_parameters[:body] ? request_parameters[:body] : request_parameters
92
+ test_values.transform_keys_to_symbols if Soaspec.always_use_keys?
93
+ end
94
+
89
95
  # Used in together with Exchange request that passes such override parameters
90
- def make_request(override_parameters)
91
- test_values = override_parameters # Used in making request via hash or in template via Erb
92
- test_values = test_values.transform_keys_to_symbols if Soaspec.always_use_keys?
96
+ # @param [Hash] request_parameters Parameters used to overwrite defaults in request
97
+ def make_request(request_parameters)
98
+ test_values = request_body_params request_parameters
93
99
  begin
94
100
  if @request_option == :template
95
101
  request_body = File.read('template/' + template_name + '.xml')
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.57'.freeze
2
+ VERSION = '0.0.58'.freeze
3
3
  end
@@ -23,6 +23,7 @@ the same configuration "
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.16'
26
+ spec.add_development_dependency 'cucumber'
26
27
  spec.add_development_dependency 'data_magic'
27
28
  spec.add_development_dependency 'rake', '~> 12.0'
28
29
  spec.add_development_dependency 'require_all'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-16 00:00:00.000000000 Z
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: data_magic
29
43
  requirement: !ruby/object:Gem::Requirement