swagalicious 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/swagalicious/example_helpers.rb +7 -5
- data/lib/swagalicious/version.rb +1 -1
- data/lib/swagalicious.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 356ef7d1c57b5d2c0887ef48741926c1d15799b0dee6ec2f44c447ccad909c56
|
4
|
+
data.tar.gz: 3daa87a8d3b13e7b35d688b6620bf050f07eb208938a1fd257613a8bca259714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a9e321d4f883d71c12a05212ae97b7d55b1c403d69820c8c58236382e5abf4d1f869e3aba13dba3fe3a8134d06264145f6523b89a27f7cc4a18bb4539bb86a1
|
7
|
+
data.tar.gz: 80d3b8950565c86d82f4437eac5d9ed022913f0b3df4c8f2e32d1edc3ce57ea41be2925d3b1f829952e6fb93dcc9de63685d88a24c1d327a0a3228bd715dc420
|
data/Gemfile.lock
CHANGED
@@ -20,25 +20,27 @@ class Swagalicious
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def app
|
23
|
-
@app ||= Rack::Builder.parse_file("config.ru").first
|
23
|
+
@app ||= defined?(Rails) ? Rails.application : Rack::Builder.parse_file("config.ru").first
|
24
24
|
end
|
25
25
|
|
26
26
|
def client
|
27
27
|
@client ||= Faraday.new do |b|
|
28
|
-
b.adapter
|
28
|
+
b.adapter Faraday::Adapter::Rack, app
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def submit_request(metadata, mocked: false, mock_name: nil)
|
33
|
-
request
|
33
|
+
request = RequestFactory.new.build_request(metadata, self)
|
34
|
+
uri = URI.parse(request[:path])
|
35
|
+
uri.path = uri.path.gsub("//", "/")
|
34
36
|
|
35
37
|
response = if mocked
|
36
|
-
file_name = File.basename(mock_name ||
|
38
|
+
file_name = File.basename(mock_name || path)
|
37
39
|
|
38
40
|
MockResponse.new(file_name)
|
39
41
|
else
|
40
42
|
client.public_send(request[:verb]) do |req|
|
41
|
-
req.url
|
43
|
+
req.url uri.to_s
|
42
44
|
req.headers = request[:headers]
|
43
45
|
req.body = request[:payload]
|
44
46
|
end
|
data/lib/swagalicious/version.rb
CHANGED
data/lib/swagalicious.rb
CHANGED
@@ -2,6 +2,11 @@ require "rspec/core"
|
|
2
2
|
|
3
3
|
require_relative "./swagalicious/version"
|
4
4
|
|
5
|
+
begin
|
6
|
+
require "rspec/rails"
|
7
|
+
rescue nil
|
8
|
+
end
|
9
|
+
|
5
10
|
class Swagalicious
|
6
11
|
class Error < StandardError; end
|
7
12
|
|
@@ -24,6 +29,11 @@ class Swagalicious
|
|
24
29
|
c.add_setting :swagger_root
|
25
30
|
c.add_setting :swagger_docs
|
26
31
|
c.add_setting :swagger_dry_run
|
32
|
+
|
33
|
+
if defined?(Rails) && defined?(RSpec::Rails)
|
34
|
+
c.include RSpec::Rails::RequestExampleGroup, type: :doc
|
35
|
+
end
|
36
|
+
|
27
37
|
c.extend Swagalicious::ExampleGroupHelpers, type: :doc
|
28
38
|
c.include Swagalicious::ExampleHelpers, type: :doc
|
29
39
|
end
|