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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2039bd3f0c7d96f3b0793d3d2688acae7c450815a8943532187b218f3d7d7939
4
- data.tar.gz: 18ee9a8aa325795e4b75f221c70f0ccf7195007872f9c4366db56f98c471905d
3
+ metadata.gz: 356ef7d1c57b5d2c0887ef48741926c1d15799b0dee6ec2f44c447ccad909c56
4
+ data.tar.gz: 3daa87a8d3b13e7b35d688b6620bf050f07eb208938a1fd257613a8bca259714
5
5
  SHA512:
6
- metadata.gz: 21cf90ba1dc63fef0fcf37182fba4ab92938878f2e66442369a880c10624a59f1344a72297b9b94b28cde9e3fddf0dc1874ddef57e17ddc40d365b962547eb9d
7
- data.tar.gz: f5c66b99a2cd90e607daa22f93995e37a1019e9b28620c56d2b8348221c94a545a3ac54167e35062e81122b7bfdfadf4bfb43d53863a1d4ae7b578f869963554
6
+ metadata.gz: 3a9e321d4f883d71c12a05212ae97b7d55b1c403d69820c8c58236382e5abf4d1f869e3aba13dba3fe3a8134d06264145f6523b89a27f7cc4a18bb4539bb86a1
7
+ data.tar.gz: 80d3b8950565c86d82f4437eac5d9ed022913f0b3df4c8f2e32d1edc3ce57ea41be2925d3b1f829952e6fb93dcc9de63685d88a24c1d327a0a3228bd715dc420
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swagalicious (0.4.5)
4
+ swagalicious (0.4.6)
5
5
  faraday (~> 2.0)
6
6
  faraday-rack
7
7
  json-schema
@@ -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(:rack)
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 = RequestFactory.new.build_request(metadata, self)
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 || URI.parse(request[:path]).path)
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 request[:path].gsub("//", "/")
43
+ req.url uri.to_s
42
44
  req.headers = request[:headers]
43
45
  req.body = request[:payload]
44
46
  end
@@ -1,3 +1,3 @@
1
1
  class Swagalicious
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagalicious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Howe