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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6608a92ab8b58f6d615540b792ec5a79c804f90
4
- data.tar.gz: f67f1c4b85651e2a6f29faa8c840192e3e0a35df
3
+ metadata.gz: 76777a7419395aa64ebe95d31fd44f718298cc02
4
+ data.tar.gz: f813c83c66b0db373545fcf147dc31035082a882
5
5
  SHA512:
6
- metadata.gz: 8931352c6f2acdb4ae0ad78823a752ce10a20bc0beac529b7d4f2dac9824da6da4357abad51ad9b07c48495796933d75d7525ea7df9e46c658cb46a9a3e7d653
7
- data.tar.gz: da88f8e0d83089f4cfaefa4e04ab8fe042e423a8bebbef29de807103c68d1b2901d8fdbaebb4416ecf241c1014b18b0b266a6a8ceb4c1349d8ff6381eac7f90d
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
@@ -1,3 +1,3 @@
1
1
  module RspecApiDocs
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -1,23 +1,18 @@
1
1
  require 'rspec/core'
2
2
  require "rspec_api_docs/version"
3
- require "rspec_api_docs/dir"
3
+ require "rspec_api_docs/helper"
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.before(:suite) do
7
- files_to_run = config.instance_variable_get(:@files_or_directories_to_run)
8
- next unless files_to_run == ["spec/controllers/api/"]
7
+ next unless RspecApiDocs::Helper.running_api_specs?(config)
9
8
 
10
- api_docs_folder_path = RspecApiDocs::Dir.find_or_create_api_docs_folder_in(Rails.root)
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
- # 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 == ["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 = File.join(Rails.root, "apiary.apib")
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.5.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-12 00:00:00.000000000 Z
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/dir.rb
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
@@ -1,8 +0,0 @@
1
- class RspecApiDocs::Dir
2
- def self.find_or_create_api_docs_folder_in(path)
3
- api_docs_folder_path = File.join(path, '/api_docs/')
4
- Dir.mkdir(api_docs_folder_path) unless Dir.exists?(api_docs_folder_path)
5
-
6
- api_docs_folder_path
7
- end
8
- end