rspec-rails-swagger 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a916826de8e3e0b5f89296dcd78ca114356c106
|
4
|
+
data.tar.gz: e709fb01df49194a494f20e6b26a47958ae5d409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daca2e677f67f13e83259c5cfae1046c033a6bb3dd82853f2d0f6455c5d49de8ea57026531692d98d9988914c8752bf8daf36869494c33bd2353c0b6e16357ce
|
7
|
+
data.tar.gz: cc2bcb1103465c99da748a33b0b18a3bf17745a15ecaef02e40a92905a1918f132d53f3e16ea687a492a47da5df69c6f60e02147422cadac18b4089e3d923ef2
|
@@ -204,13 +204,14 @@ module RSpec
|
|
204
204
|
method = builder.method
|
205
205
|
path = [builder.path, builder.query].join
|
206
206
|
headers = builder.headers
|
207
|
+
env = builder.env
|
207
208
|
body = builder.body
|
208
209
|
|
209
210
|
# Run the request
|
210
211
|
if ::Rails::VERSION::MAJOR >= 5
|
211
|
-
self.send(method, path, {params: body, headers: headers})
|
212
|
+
self.send(method, path, {params: body, headers: headers, env: env})
|
212
213
|
else
|
213
|
-
self.send(method, path, body, headers)
|
214
|
+
self.send(method, path, body, headers.merge(env))
|
214
215
|
end
|
215
216
|
|
216
217
|
if example.metadata[:capture_examples]
|
@@ -4,10 +4,17 @@ module RSpec
|
|
4
4
|
class RequestBuilder
|
5
5
|
attr_reader :metadata, :instance
|
6
6
|
|
7
|
+
##
|
8
|
+
# Creates a new RequestBuilder from the Example class's +metadata+ hash
|
9
|
+
# and a test +instance+ that we can use to populate the parameter
|
10
|
+
# values.
|
7
11
|
def initialize(metadata, instance)
|
8
12
|
@metadata, @instance = metadata, instance
|
9
13
|
end
|
10
14
|
|
15
|
+
##
|
16
|
+
# Finds the Document associated with this request so things like schema
|
17
|
+
# and parameter references can be resolved.
|
11
18
|
def document
|
12
19
|
@document ||= begin
|
13
20
|
name = metadata[:swagger_document]
|
@@ -27,6 +34,10 @@ module RSpec
|
|
27
34
|
Array(metadata[:swagger_operation][:consumes]).presence || Array(document[:consumes])
|
28
35
|
end
|
29
36
|
|
37
|
+
##
|
38
|
+
# Returns parameters defined in the operation and path item. Providing
|
39
|
+
# a +location+ will filter the parameters to those with a matching +in+
|
40
|
+
# value.
|
30
41
|
def parameters location = nil
|
31
42
|
path_item = metadata[:swagger_path_item] || {}
|
32
43
|
operation = metadata[:swagger_operation] || {}
|
@@ -39,12 +50,10 @@ module RSpec
|
|
39
50
|
end
|
40
51
|
|
41
52
|
def parameter_values location
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
.
|
46
|
-
.map{ |k| k.split('&').last }
|
47
|
-
.map{ |name| [name, instance.send(name)] }
|
53
|
+
values = parameters(location).
|
54
|
+
map{ |_, p| p['$ref'] ? document.resolve_ref(p['$ref']) : p }.
|
55
|
+
select{ |p| p[:required] || instance.respond_to?(p[:name]) }.
|
56
|
+
map{ |p| [p[:name], instance.send(p[:name])] }
|
48
57
|
Hash[values]
|
49
58
|
end
|
50
59
|
|
@@ -62,6 +71,15 @@ module RSpec
|
|
62
71
|
headers
|
63
72
|
end
|
64
73
|
|
74
|
+
##
|
75
|
+
# If +instance+ defines an +env+ method this will return those values
|
76
|
+
# for inclusion in the Rack env hash.
|
77
|
+
def env
|
78
|
+
return {} unless instance.respond_to? :env
|
79
|
+
|
80
|
+
instance.env
|
81
|
+
end
|
82
|
+
|
65
83
|
def path
|
66
84
|
base_path = document[:basePath] || ''
|
67
85
|
# Find params in the path and replace them with values defined in
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails-swagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andrew morton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|