soaspec 0.0.59 → 0.0.60

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: 00575bd80732286d4db1c5bf9fd94768e1b32125
4
- data.tar.gz: b5e4e7469fe387aa0264c0dec836a7ebcb8ac7aa
3
+ metadata.gz: fe90eccaa27081467b713989671f3553fbd14d53
4
+ data.tar.gz: 606284e2168e643b95a987c26ed3a41dbd9262e9
5
5
  SHA512:
6
- metadata.gz: 47cc6b1be05516b7571f4a7e34f3edd9b6f950c382e3c99024e3b6a36e34b9df50ce5484119155af1ad8625ae15036bb152843d4cb59db941a9e168eaeef3ba1
7
- data.tar.gz: 9ad7763688e267213c26d9a1e7ed0c37b6d4deadcce979cd7ceed37dec6d86206d3e788ca85cb08cce0e6cb8c5105d6ac8ac913722179714a8bc1bfa8b997e77
6
+ metadata.gz: 6763d18c950cb1e532490c8ba10206c8e2ae4f0fdadab865492d25f2a25410fa0dbfb8127599fd3dfe14ddf7ae5acb2fe4a96376c6fd776b627f5bfd36f894b8
7
+ data.tar.gz: 19fae2c4feb323ab3bbccae2f1f86df9d32c89ea07ceab1c6a857767ef52dbda129374af8b61116a83e564f202da0d32206e2ca99269f0000682160adf91438f
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.60
2
+ * Enhancements
3
+ * Allow for factory_bot with automatic setting of missing setter methods
4
+
1
5
  Version 0.0.59
2
6
  * Enhancements
3
7
  * Perform ERB in headers to make using access_token using 'headers' possible
@@ -9,6 +9,8 @@ class Exchange
9
9
  attr_accessor :retry_count
10
10
  # Params used when making a request
11
11
  attr_accessor :default_params
12
+ # Name used for displaying class
13
+ attr_accessor :test_name
12
14
 
13
15
  # Set retry for success variable to true so that request will be retried
14
16
  # for retry_count until it's true
@@ -24,9 +26,9 @@ class Exchange
24
26
 
25
27
  # @param [Symbol, String] name Name shown in RSpec run
26
28
  # @param [Hash] override_parameters Parameters to override for default params
27
- def initialize(name, override_parameters = {})
28
- @test_name = name.to_s
29
- @api_class = Soaspec.api_handler # This uses the global parameter. The handler should be set straight before an exchange is made
29
+ def initialize(name = self.class.to_s, override_parameters = {})
30
+ self.test_name ||= name.to_s
31
+ @api_class ||= Soaspec.api_handler # This uses the global parameter. The handler should be set straight before an exchange is made
30
32
  @override_parameters = override_parameters
31
33
  @retry_for_success = false
32
34
  self.retry_count = 3
@@ -51,7 +53,7 @@ class Exchange
51
53
  # Will retry until success code reached if retry_for_success? is set
52
54
  # @return [Response] Response from Api handler
53
55
  def make_request
54
- Soaspec::SpecLogger.add_to 'Example ' + @test_name
56
+ Soaspec::SpecLogger.add_to 'Example ' + test_name
55
57
  request_params = default_params ? merge_request_body : @override_parameters
56
58
  retry_count.times do
57
59
  response = @api_class.make_request(request_params)
@@ -81,7 +83,7 @@ class Exchange
81
83
  # This will make the request and store the response
82
84
  # @return [String] Name given when initializing
83
85
  def to_s
84
- @test_name
86
+ test_name
85
87
  end
86
88
 
87
89
  # Returns response object from Api. Will make the request if not made and then cache it for later on
@@ -126,4 +128,35 @@ class Exchange
126
128
  default_params[:body][key] = value
127
129
  end
128
130
 
131
+ # Implement undefined setter with []= for FactoryBot to use without needing to define params to set
132
+ # @param [Object] method_name
133
+ # @param [Object] args
134
+ # @param [Object] block
135
+ def method_missing(method_name, *args, &block)
136
+ if method_name[-1] == '='
137
+ if args.first.class < Exchange # This would be prerequisite exchange
138
+ define_singleton_method(method_name[0..-2]) do
139
+ args.first
140
+ end
141
+ else
142
+ self[method_name[0..-2]] = args.first
143
+ end
144
+ else
145
+ super
146
+ end
147
+ end
148
+
149
+ # Used for setters that are not defined
150
+ def respond_to_missing?(method_name, *args)
151
+ method_name[-1] == '=' || super
152
+ end
153
+
154
+ # Makes request, caching the response and returning self
155
+ # Used by FactoryBot
156
+ # @return [Self]
157
+ def save!
158
+ call
159
+ self
160
+ end
161
+
129
162
  end
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.59'.freeze
2
+ VERSION = '0.0.60'.freeze
3
3
  end
@@ -25,6 +25,7 @@ the same configuration "
25
25
  spec.add_development_dependency 'bundler', '~> 1.16'
26
26
  spec.add_development_dependency 'cucumber'
27
27
  spec.add_development_dependency 'data_magic'
28
+ spec.add_development_dependency 'factory_bot'
28
29
  spec.add_development_dependency 'rake', '~> 12.0'
29
30
  spec.add_development_dependency 'require_all'
30
31
  spec.add_development_dependency 'rspec', '~> 3.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.59
4
+ version: 0.0.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: factory_bot
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement