openapi_rspec 0.2.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4ac78604afe839b594b928d23fb32cdbab87b822dfda1b019a56a6cc99847b6
4
- data.tar.gz: 8ae114534430f0abed7a4618fc2239ea9696dc4532be9569696ab4e2de354faf
3
+ metadata.gz: 0367f850252eff7b267d205f702bb3424a10f88d3333b700f416fc337879ede2
4
+ data.tar.gz: ba6f7e1e9f0a8a706c6d5f712d50e2c5f916e56201a1131cd73505c6ceec4ce1
5
5
  SHA512:
6
- metadata.gz: 3759f1eb45a8861db4cf0dfcc559a065f9c236ccd5bfdcdbd700268704cec2a0ed668da192720e28889db16c3115e37833b47c41a14b7a58c3dbe49ccf3cbdf9
7
- data.tar.gz: 7c32542acbdd92476ea198c1211f160eed882ff98ec923364a9dad857e76677ffaf4786ac9fd4d33db4033528d42a02230fe59c3c45cbc5196601ed44ba1f4b9
6
+ metadata.gz: 3104ab50af0749801e8a31b422f67c905f76cf75059aa5ba1121008a30990cdce08f941808914cb730b64f7a363bf5a4a839ad682b90a26352b3264b801bc445
7
+ data.tar.gz: eb0a1de49ad9adea06094c06b34d250b4f95f359dedc4c78ccf1e18d98cc5c0a93ec2e6afc1ab1a5fb54bda68827a679f49a24aa46c3680c9b44dc2103fa4913
data/lib/openapi_rspec.rb CHANGED
@@ -18,6 +18,25 @@ module OpenapiRspec
18
18
  OpenapiValidator.call(doc, **params)
19
19
  end
20
20
 
21
+ def self.api_by_path(openapi_path, **params)
22
+ session = Rack::Test::Session.new(config.app)
23
+ begin
24
+ response = session.get(openapi_path)
25
+ rescue StandardError => e
26
+ raise "Unable to perform GET request for swagger json: #{openapi_path} - #{e}."
27
+ end
28
+
29
+ parsed_doc = case openapi_path.split(".").last
30
+ when "yml", "yaml"
31
+ YAML.load(response.body)
32
+ when "json"
33
+ JSON.parse(response.body)
34
+ else
35
+ raise "Unable to parse OpenAPI doc, '#{openapi_path}' is undefined format"
36
+ end
37
+ OpenapiValidator.call(parsed_doc, **params)
38
+ end
39
+
21
40
  RSpec.configure do |config|
22
41
  config.extend ModuleHelpers
23
42
  config.include Helpers
@@ -1,3 +1,3 @@
1
1
  module OpenapiRspec
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2019-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable