soaspec 0.0.64 → 0.0.65

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: 25c86df1d3a144dc27e77be77a31c9b4391fd07a
4
- data.tar.gz: 9fae1931ca918a24b6d44e7a7539225d79d829ee
3
+ metadata.gz: 1b74599fe5d32dc78abe0ad63f1454c5173ac188
4
+ data.tar.gz: ab105cf905b37f63a6fc6a52c694e85d3577c621
5
5
  SHA512:
6
- metadata.gz: 2f876e1f3e3e532e9c4dd0bc65cc16e50da035d165a9d712add298c4221a61cd3808c9f13a779658543d22c2339060af88ee4bedb01b01df93a44e1982c1b665
7
- data.tar.gz: 9e913c8ded49a9df53a65ae78a9e3672e725486f755c562ea3610e092a301ce773e8a217143e0cda0d21dc7e498a0236e5cc5e72355ead42853130f6b111c1e1
6
+ metadata.gz: fe214897a46aef14ffc950badadcd818927d5e6e38d427d29a7e3ce4d9ae0916d24f4262c3457d2d812ea3b198c7d2365ee174d498d31a457c485d0f54085bac
7
+ data.tar.gz: ec75d15728e9b97082d9039bf9ea14652671488652991b539c1d883f77061057acf9de25ef83b6cce0d8a7b944dd51c83937e7549bc73cb6c2b920e5ca4aa0be
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.65
2
+ * Enhancements
3
+ * Added ability to set 'suburl' and 'method' in Exchange accessor. Will be used in FactoryBot later
4
+
1
5
  Version 0.0.64
2
6
  * Enhancements
3
7
  * Got FactoryBot working for RestHandler. See specs for example
@@ -32,26 +32,23 @@ get '/as/token.oauth2' do
32
32
  end
33
33
 
34
34
  # Used for testing storage of data
35
- post '/test/id' do
36
- # puts request.body.string
35
+ post '/test/name' do
37
36
  request_hash = JSON.parse(request.body.string)
38
- # request_hash = JSON.parse('{ "id": "1" }')
39
- # puts request_hash
40
- uuid = SecureRandom.uuid
41
- Soaspec::TestServer::PuppyService.data[uuid] = {}
42
- Soaspec::TestServer::PuppyService.data[uuid][:id] = request_hash['id']
43
- # puts PuppyService.data
44
- 'Success'
37
+ id = Soaspec::TestServer::PuppyService.new_id
38
+ Soaspec::TestServer::PuppyService.data[id][:name] = request_hash['name']
39
+ response_hash = { result: { status: 'success', data: Soaspec::TestServer::PuppyService.data[id] } }
40
+ JSON.generate response_hash
45
41
  end
46
42
 
47
43
  # Used for testing retrieving storage of data
48
- get '/test/id/:id' do |id|
49
- # puts "ID is:#{id}:"
50
- # puts id.class
51
- # puts PuppyService.data
52
- # puts PuppyService.data['id']
53
- # puts PuppyService.data[id]
54
- result = Soaspec::TestServer::PuppyService.data.select { |_key, hash| hash[:id] == id }
55
-
56
- JSON.generate(result)
44
+ get '/test/name/:id' do |id|
45
+ result = Soaspec::TestServer::PuppyService.data[id.to_i]
46
+ JSON.generate result
47
+ end
48
+
49
+ patch '/test/name/:id' do |id|
50
+ request_hash = JSON.parse(request.body.string)
51
+ Soaspec::TestServer::PuppyService.data[id.to_i][:name] = request_hash['name']
52
+ response_hash = { result: { status: 'updated', with: request_hash['name'] } }
53
+ JSON.generate response_hash
57
54
  end
@@ -4,11 +4,9 @@ require_relative '../soaspec'
4
4
  class Exchange
5
5
 
6
6
  # Class of Api Handler for which this exchange is made
7
- attr_reader :api_class
7
+ attr_accessor :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
12
10
  # Name used for displaying class
13
11
  attr_accessor :test_name
14
12
 
@@ -48,15 +46,16 @@ class Exchange
48
46
  end
49
47
  end
50
48
 
51
- # Merge exchange initialized request params with ones set later on
52
- def merge_request_body
53
- if @override_parameters[:body] || default_params[:body]
54
- @override_parameters[:body] ||= {}
55
- @override_parameters[:body].merge!(default_params[:body])
56
- @override_parameters
57
- else
58
- @override_parameters.merge(default_params[:body])
59
- end
49
+ # Specify a url to add onto the base_url of the ExchangeHandler used
50
+ # @param [String] url Url to add onto the base_url of the ExchangeHandler used
51
+ def suburl=(url)
52
+ @override_parameters[:suburl] = url
53
+ end
54
+
55
+ # Specify HTTP method to use. Default is :post
56
+ # @param [Symbol] method HTTP method. E.g, :get, :patch
57
+ def method=(method)
58
+ @override_parameters[:method] = method
60
59
  end
61
60
 
62
61
  # Make request to handler with parameters defined
@@ -64,7 +63,7 @@ class Exchange
64
63
  # @return [Response] Response from Api handler
65
64
  def make_request
66
65
  Soaspec::SpecLogger.add_to 'Example ' + test_name
67
- request_params = default_params ? merge_request_body : @override_parameters
66
+ request_params = @override_parameters
68
67
  retry_count.times do
69
68
  response = @api_class.make_request(request_params)
70
69
  return response unless retry_for_success?
@@ -142,8 +141,8 @@ class Exchange
142
141
  # Can be used to build a request over several steps (e.g Cucumber)
143
142
  # Will be used with FactoryBot
144
143
  def []=(key, value)
145
- self.default_params = { body: {} } unless default_params # Initialize as Hash if not set
146
- default_params[:body][key] = value
144
+ @override_parameters[:body] ||= {}
145
+ @override_parameters[:body][key] = value
147
146
  end
148
147
 
149
148
  # Implement undefined setter with []= for FactoryBot to use without needing to define params to set
@@ -151,7 +150,7 @@ class Exchange
151
150
  # @param [Object] args
152
151
  # @param [Object] block
153
152
  def method_missing(method_name, *args, &block)
154
- if method_name[-1] == '='
153
+ if method_name[-1] == '=' # A setter method
155
154
  if args.first.class < Exchange # This would be prerequisite exchange
156
155
  define_singleton_method(method_name[0..-2]) do
157
156
  args.first
@@ -2,8 +2,17 @@ module Soaspec
2
2
  module TestServer
3
3
  class PuppyService
4
4
  @data = {}
5
+ @current_id = 1
5
6
  class << self
6
7
  attr_accessor :data
8
+
9
+ def new_id
10
+ @data[@current_id] = {}
11
+ @data[@current_id][:id] = @current_id
12
+ @current_id += 1
13
+ @current_id - 1
14
+ end
15
+
7
16
  end
8
17
  end
9
18
  end
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.64'.freeze
2
+ VERSION = '0.0.65'.freeze
3
3
  end
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.64
4
+ version: 0.0.65
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-23 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler