rspec_api_docs 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec_api_docs/version.rb +1 -1
- data/lib/rspec_api_docs.rb +13 -16
- metadata +3 -4
- data/lib/rspec_api_docs/file.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a6353f8e992283d35976b79f700f89bb288190
|
4
|
+
data.tar.gz: 11e539b4e35b9b9d5fe99f27cc4217c9ddbede47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3699d25bf8194de10124fa7009bd44290b4a1f9397153fab79553591f091d5f6174c79fd2ad719a2067318bc42279cbc7d8351eee4bbd1fa632c060c66c1b6db
|
7
|
+
data.tar.gz: f7a1d04367e61049031b464b065788930238dee1a3a3307cc54dbc153abe52a230ddc34f2c7716ff299a83e87d73d3e4ffa8009668b2310289229bddfc04083e
|
data/lib/rspec_api_docs.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
require 'rspec/core'
|
2
2
|
require "rspec_api_docs/version"
|
3
3
|
require "rspec_api_docs/dir"
|
4
|
-
require "rspec_api_docs/file"
|
5
4
|
|
6
5
|
RSpec.configure do |config|
|
7
6
|
config.before(:suite) do
|
8
|
-
|
7
|
+
files_to_run = config.instance_variable_get(:@files_or_directories_to_run)
|
8
|
+
next unless files_to_run == ["test/controllers/api/"]
|
9
9
|
|
10
|
-
RspecApiDocs::
|
11
|
-
next unless f.match(/api\/v*.\/.*/)
|
10
|
+
api_docs_folder_path = RspecApiDocs::Dir.find_or_create_api_docs_folder_in(Rails.root)
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
File.delete(file) if File.exists?(file)
|
16
|
-
end
|
12
|
+
file = File.join(Rails.root, "apiary.apib")
|
13
|
+
File.delete(file) if File.exists?(file)
|
17
14
|
end
|
18
15
|
|
19
16
|
config.after(:each) do |example|
|
20
17
|
begin
|
21
18
|
# exit unless this is under api/v*
|
19
|
+
files_to_run = config.instance_variable_get(:@files_or_directories_to_run)
|
20
|
+
next unless files_to_run == ["test/controllers/api/"]
|
22
21
|
next unless example.metadata[:file_path].match(/api\/v\d*/)
|
23
22
|
next unless request && request.try(:symbolized_path_parameters)
|
24
23
|
|
@@ -37,16 +36,14 @@ RSpec.configure do |config|
|
|
37
36
|
optional_param = request.symbolized_path_parameters[id_symbol] ? "/{:#{id_symbol}}" : ""
|
38
37
|
action = "#{request.request_method} #{request.symbolized_path_parameters[:controller]}#{optional_param}"
|
39
38
|
|
40
|
-
|
41
|
-
file = File.join(Rails.root, "/api_docs/#{file_name}.txt")
|
42
|
-
else
|
43
|
-
file = File.join(File.expand_path('.'), "/api_docs/#{file_name}.txt")
|
44
|
-
end
|
39
|
+
file = File.join(Rails.root, "apiary.apib")
|
45
40
|
|
46
41
|
collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)\/v\d*\/(.*)/)[3]
|
42
|
+
version_and_collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)(.*)/)[3]
|
43
|
+
|
47
44
|
action_title = "#{collection.capitalize} #{request.symbolized_path_parameters[:action].capitalize} [#{request.method}]"
|
48
45
|
File.open(file, 'a') do |f|
|
49
|
-
if File.zero?(File.join(
|
46
|
+
if File.zero?(File.join(file))
|
50
47
|
f.write "FORMAT: 1A\n"
|
51
48
|
f.write "HOST: https://qa1.google.co.uk/api\n\n"
|
52
49
|
|
@@ -56,9 +53,9 @@ RSpec.configure do |config|
|
|
56
53
|
end
|
57
54
|
|
58
55
|
# skip if the action is already defined
|
59
|
-
next if File.read(File.join(
|
56
|
+
next if File.read(File.join(file)).include?(action_title)
|
60
57
|
|
61
|
-
f.write "## #{collection.capitalize} collection [
|
58
|
+
f.write "## #{collection.capitalize} collection [#{version_and_collection}]\n\n"
|
62
59
|
|
63
60
|
f.write "### #{action_title}\n\n"
|
64
61
|
|
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.4.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-06-
|
11
|
+
date: 2016-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/rspec_api_docs.rb
|
73
73
|
- lib/rspec_api_docs/dir.rb
|
74
|
-
- lib/rspec_api_docs/file.rb
|
75
74
|
- lib/rspec_api_docs/version.rb
|
76
75
|
- rspec_api_docs.gemspec
|
77
76
|
homepage: https://github.com/tomkadwill/rspec_api_docs
|
@@ -94,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
93
|
version: '0'
|
95
94
|
requirements: []
|
96
95
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.2.2
|
98
97
|
signing_key:
|
99
98
|
specification_version: 4
|
100
99
|
summary: Generate API blueprint docs when running Rspec
|