rspec_api_docs 0.5.0 → 0.6.0
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 +4 -4
- data/lib/rspec_api_docs/helper.rb +12 -0
- data/lib/rspec_api_docs/version.rb +1 -1
- data/lib/rspec_api_docs.rb +5 -10
- metadata +3 -3
- data/lib/rspec_api_docs/dir.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76777a7419395aa64ebe95d31fd44f718298cc02
|
4
|
+
data.tar.gz: f813c83c66b0db373545fcf147dc31035082a882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df49b092819ef0751506dd098d86911165145e798029222b64167a217b632f1d7dda9ba7c0d0b322db6dbaf8f4ff07850dae3841c69af4a40d3a74c573353d56
|
7
|
+
data.tar.gz: 95d4853c185ba94bb5579eedde31696e5dcbf7db54dc1d25f912aeb85f4df6f190532a8ca0298b842499cb79181881e93cf129ff3083175e6a134e75cff3f24d
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class RspecApiDocs::Helper
|
2
|
+
def self.file
|
3
|
+
root_path = Rails.root.to_s.gsub('/rails', '')
|
4
|
+
file = File.join(root_path, "apiary.apib")
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.running_api_specs?(config)
|
8
|
+
files_to_run = config.instance_variable_get(:@files_or_directories_to_run)
|
9
|
+
puts files_to_run.inspect
|
10
|
+
files_to_run == ["spec/controllers/api/"]
|
11
|
+
end
|
12
|
+
end
|
data/lib/rspec_api_docs.rb
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
require 'rspec/core'
|
2
2
|
require "rspec_api_docs/version"
|
3
|
-
require "rspec_api_docs/
|
3
|
+
require "rspec_api_docs/helper"
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.before(:suite) do
|
7
|
-
|
8
|
-
next unless files_to_run == ["spec/controllers/api/"]
|
7
|
+
next unless RspecApiDocs::Helper.running_api_specs?(config)
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
file = File.join(Rails.root, "apiary.apib")
|
9
|
+
file = RspecApiDocs::Helper.file
|
13
10
|
File.delete(file) if File.exists?(file)
|
14
11
|
end
|
15
12
|
|
16
13
|
config.after(:each) do |example|
|
17
14
|
begin
|
18
|
-
|
19
|
-
files_to_run = config.instance_variable_get(:@files_or_directories_to_run)
|
20
|
-
next unless files_to_run == ["spec/controllers/api/"]
|
15
|
+
next unless RspecApiDocs::Helper.running_api_specs?(config)
|
21
16
|
next unless example.metadata[:file_path].match(/api\/v\d*/)
|
22
17
|
next unless request && request.try(:symbolized_path_parameters)
|
23
18
|
|
@@ -36,7 +31,7 @@ RSpec.configure do |config|
|
|
36
31
|
optional_param = request.symbolized_path_parameters[id_symbol] ? "/{:#{id_symbol}}" : ""
|
37
32
|
action = "#{request.request_method} #{request.symbolized_path_parameters[:controller]}#{optional_param}"
|
38
33
|
|
39
|
-
file =
|
34
|
+
file = RspecApiDocs::Dir.file
|
40
35
|
|
41
36
|
collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)\/v\d*\/(.*)/)[3]
|
42
37
|
version_and_collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)(.*)/)[3]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_api_docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Kadwill
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,7 +70,7 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/rspec_api_docs.rb
|
73
|
-
- lib/rspec_api_docs/
|
73
|
+
- lib/rspec_api_docs/helper.rb
|
74
74
|
- lib/rspec_api_docs/version.rb
|
75
75
|
- rspec_api_docs.gemspec
|
76
76
|
homepage: https://github.com/tomkadwill/rspec_api_docs
|
data/lib/rspec_api_docs/dir.rb
DELETED