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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ec7c0ef83d3f6f2707a9c107495e711f807f1f0
4
- data.tar.gz: 5abb86689a0fdfcf3e5e4bbaf0c5a6058e29f55d
3
+ metadata.gz: e3a6353f8e992283d35976b79f700f89bb288190
4
+ data.tar.gz: 11e539b4e35b9b9d5fe99f27cc4217c9ddbede47
5
5
  SHA512:
6
- metadata.gz: 97c8b0f6fc41589fc312325e81f03161536e934e85d0b785e3c424b83a9d9c90fce743b76dd033757faaef29e407228f15ce5b7b0a43395d9e6a9162b907f4b8
7
- data.tar.gz: 26c7238588d78e74ee89f4c62c53923eb398beaedd3577c9b7ce1615542723cf8185338ade81856938451b6e0b03721c7ad0ffc89aec2670d02929c791a2b02c
6
+ metadata.gz: 3699d25bf8194de10124fa7009bd44290b4a1f9397153fab79553591f091d5f6174c79fd2ad719a2067318bc42279cbc7d8351eee4bbd1fa632c060c66c1b6db
7
+ data.tar.gz: f7a1d04367e61049031b464b065788930238dee1a3a3307cc54dbc153abe52a230ddc34f2c7716ff299a83e87d73d3e4ffa8009668b2310289229bddfc04083e
@@ -1,3 +1,3 @@
1
1
  module RspecApiDocs
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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
- api_docs_folder_path = RspecApiDocs::Dir.find_or_create_api_docs_folder_in(Rails.root)
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::File.files_to_remove(config.files_to_run, api_docs_folder_path).each do |f|
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
- file = f.match(/api\/v*.\/.*/)[0].gsub('/', '_').gsub('api_', '').gsub('_controller_test.rb', '.txt')
14
- file = "api_docs/#{file}"
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
- if defined? Rails
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(Rails.root, "/api_docs/#{file_name}.txt"))
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(Rails.root, "/api_docs/#{file_name}.txt")).include?(action_title)
56
+ next if File.read(File.join(file)).include?(action_title)
60
57
 
61
- f.write "## #{collection.capitalize} collection [/#{collection}]\n\n"
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.3.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-19 00:00:00.000000000 Z
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.4.6
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
@@ -1,9 +0,0 @@
1
- class RspecApiDocs::File
2
- def self.files_to_remove(files, api_docs_folder_path)
3
- if files == []
4
- Dir.glob(File.join(api_docs_folder_path, '*'))
5
- else
6
- files
7
- end
8
- end
9
- end