apiaryio 0.8.1 → 0.9.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/README.md +21 -2
- data/features/fetch.feature +1 -1
- data/features/step_definitions/file_content_step.rb +1 -1
- data/features/styleguide.feature +19 -0
- data/features/support/apiary.apib +4 -0
- data/features/support/env.rb +1 -1
- data/features/support/functions.js +7 -0
- data/features/support/rules.json +8 -0
- data/lib/apiary/cli.rb +14 -2
- data/lib/apiary/command/styleguide.rb +192 -0
- data/lib/apiary/exceptions.rb +2 -0
- data/lib/apiary/version.rb +1 -1
- data/spec/apiary/command/styleguide_spec.rb +152 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac019fb0a54cb6bd3219a060a7fe40ffe9bd6a7d
|
4
|
+
data.tar.gz: 4625c0c0fa4e2f979939cd14e9335413976c15b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09693e31a8d82c94b44e3d2a4ac989d44ac290855ca822b412c75289ece2249f6c3b02c7eaf19119702f3505f580b736853bc43c020777e9fe46020a28c329b4'
|
7
|
+
data.tar.gz: 55ef88709de35254b142bba467576794e72d483209d6adcd3b96d98f0f5fd13a84dd08c8ad5d6a22142420a00354c5349cef6f5b6e29f036211d6755af959a5b
|
data/README.md
CHANGED
@@ -61,6 +61,7 @@ Commands:
|
|
61
61
|
apiary help [COMMAND] # Describe available commands or one specific command
|
62
62
|
apiary preview # Show API documentation in browser or write it to file
|
63
63
|
apiary publish --api-name=API_NAME # Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)
|
64
|
+
apiary styleguide # Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )
|
64
65
|
apiary version # Show version
|
65
66
|
|
66
67
|
```
|
@@ -92,7 +93,7 @@ Usage:
|
|
92
93
|
Options:
|
93
94
|
[--browser=BROWSER] # Show API documentation in specified browser (full command is needed - e.g. `--browser='open -a safari'` in case of osx)
|
94
95
|
[--output=FILE] # Write generated HTML into specified file
|
95
|
-
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for apiary.apib
|
96
|
+
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
|
96
97
|
[--json], [--no-json] # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
|
97
98
|
[--api-host=HOST] # Specify apiary host
|
98
99
|
[--server], [--no-server] # Start standalone web server on port 8080
|
@@ -112,7 +113,7 @@ Usage:
|
|
112
113
|
|
113
114
|
Options:
|
114
115
|
[--message=COMMIT_MESSAGE] # Publish with custom commit message
|
115
|
-
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for apiary.apib
|
116
|
+
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
|
116
117
|
[--json], [--no-json] # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
|
117
118
|
[--api-host=HOST] # Specify apiary host
|
118
119
|
[--push], [--no-push] # Push API Description to the GitHub when API Project is associated with GitHub repository in Apiary
|
@@ -122,6 +123,24 @@ Options:
|
|
122
123
|
Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)
|
123
124
|
```
|
124
125
|
|
126
|
+
#### styleguide
|
127
|
+
|
128
|
+
```
|
129
|
+
$ apiary help styleguide
|
130
|
+
Usage:
|
131
|
+
apiary styleguide
|
132
|
+
|
133
|
+
Options:
|
134
|
+
[--fetch], [--no-fetch] # Fetch styleguide rules and functions from apiary.io
|
135
|
+
[--add=ADD] # Path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
|
136
|
+
[--functions=FUNCTIONS] # Path to to the file with functions definitions
|
137
|
+
[--rules=RULES] # Path to to the file with rules definitions - `functions.js` and `rules.json` are loaded if not specified
|
138
|
+
[--full-report], [--no-full-report] # Get passed assertions ass well. Only failed assertions are included to the result by default
|
139
|
+
|
140
|
+
Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )
|
141
|
+
|
142
|
+
```
|
143
|
+
|
125
144
|
#### version
|
126
145
|
|
127
146
|
```
|
data/features/fetch.feature
CHANGED
@@ -4,5 +4,5 @@ Feature: Fetch apiary.apib from API_NAME.apiary.io
|
|
4
4
|
@needs_apiary_api_key
|
5
5
|
Scenario: Fetch apiary.apib from API_NAME.apiary.io
|
6
6
|
|
7
|
-
When I run `apiary fetch --api-name
|
7
|
+
When I run `apiary fetch --api-name=apiaryclitestingdonottouch`
|
8
8
|
Then the output should contain the content of file "apiary.apib"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Styleguide apiary.apib on docs.API_NAME.apiary.io
|
2
|
+
|
3
|
+
# This is integration testing you have to set APIARY_API_KEY
|
4
|
+
@needs_apiary_api_key
|
5
|
+
Scenario: Styleguide validation
|
6
|
+
|
7
|
+
When I run `apiary styleguide --functions=../../features/support --rules=../../features/support --add=../../features/support --full_report`
|
8
|
+
Then the output should match /(\"validatorError\": false)/
|
9
|
+
And the exit status should be 0
|
10
|
+
|
11
|
+
# This is integration testing you have to set APIARY_API_KEY
|
12
|
+
@needs_apiary_api_key
|
13
|
+
Scenario: Styleguide fetch
|
14
|
+
|
15
|
+
When I run `apiary styleguide --fetch`
|
16
|
+
Then the output should match /(has beed succesfully created)/
|
17
|
+
And the exit status should be 0
|
18
|
+
|
19
|
+
|
data/features/support/env.rb
CHANGED
@@ -7,7 +7,7 @@ end
|
|
7
7
|
Around('@needs_apiary_api_key') do |_scenario, block|
|
8
8
|
# DEBUG puts "Scenario #{scenario.name} wants APIARY_API_KEY."
|
9
9
|
original_value = ENV.delete('APIARY_API_KEY')
|
10
|
-
ENV['APIARY_API_KEY'] = '
|
10
|
+
ENV['APIARY_API_KEY'] = '5a96f04006effca6cc03f1616ed916eb'
|
11
11
|
block.call
|
12
12
|
ENV['APIARY_API_KEY'] = original_value
|
13
13
|
end
|
data/lib/apiary/cli.rb
CHANGED
@@ -3,6 +3,7 @@ require 'thor'
|
|
3
3
|
require 'apiary/command/fetch'
|
4
4
|
require 'apiary/command/preview'
|
5
5
|
require 'apiary/command/publish'
|
6
|
+
require 'apiary/command/styleguide'
|
6
7
|
|
7
8
|
module Apiary
|
8
9
|
class CLI < Thor
|
@@ -19,7 +20,7 @@ module Apiary
|
|
19
20
|
desc 'preview', 'Show API documentation in browser or write it to file'
|
20
21
|
method_option :browser, type: :string, desc: 'Show API documentation in specified browser (full command is needed - e.g. `--browser=\'open -a safari\'` in case of osx)'
|
21
22
|
method_option :output, type: :string, banner: 'FILE', desc: 'Write generated HTML into specified file'
|
22
|
-
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib
|
23
|
+
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file'
|
23
24
|
method_option :json, type: :boolean, desc: 'Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing'
|
24
25
|
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
|
25
26
|
method_option :server, type: :boolean, desc: 'Start standalone web server on port 8080'
|
@@ -34,7 +35,7 @@ module Apiary
|
|
34
35
|
|
35
36
|
desc 'publish', 'Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)'
|
36
37
|
method_option :message, type: :string, banner: 'COMMIT_MESSAGE', desc: 'Publish with custom commit message'
|
37
|
-
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib
|
38
|
+
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file'
|
38
39
|
method_option :json, type: :boolean, desc: 'Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing'
|
39
40
|
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
|
40
41
|
method_option :push, type: :boolean, default: true, desc: 'Push API Description to the GitHub when API Project is associated with GitHub repository in Apiary'
|
@@ -45,6 +46,17 @@ module Apiary
|
|
45
46
|
cmd.execute
|
46
47
|
end
|
47
48
|
|
49
|
+
desc 'styleguide', 'Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )'
|
50
|
+
method_option :fetch, type: :boolean, desc: 'Fetch styleguide rules and functions from apiary.io'
|
51
|
+
method_option :add, type: :string, desc: 'Path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file'
|
52
|
+
method_option :functions, type: :string, desc: 'Path to to the file with functions definitions'
|
53
|
+
method_option :rules, type: :string, desc: 'Path to to the file with rules definitions - `functions.js` and `rules.json` are loaded if not specified'
|
54
|
+
method_option :full_report, type: :boolean, default: false, desc: 'Get passed assertions ass well. Only failed assertions are included to the result by default'
|
55
|
+
def styleguide
|
56
|
+
cmd = Apiary::Command::Styleguide.new options
|
57
|
+
cmd.execute
|
58
|
+
end
|
59
|
+
|
48
60
|
desc 'version', 'Show version'
|
49
61
|
method_option aliases: '-v'
|
50
62
|
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rest-client'
|
3
|
+
require 'rack'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
require 'apiary/agent'
|
8
|
+
require 'apiary/helpers'
|
9
|
+
require 'apiary/exceptions'
|
10
|
+
|
11
|
+
module Apiary::Command
|
12
|
+
class Styleguide
|
13
|
+
include Apiary::Helpers
|
14
|
+
|
15
|
+
attr_reader :options
|
16
|
+
|
17
|
+
def initialize(opts)
|
18
|
+
@options = OpenStruct.new(opts)
|
19
|
+
@options.fetch ||= false
|
20
|
+
@options.add ||= '.'
|
21
|
+
@options.functions ||= '.'
|
22
|
+
@options.rules ||= '.'
|
23
|
+
@options.api_key ||= ENV['APIARY_API_KEY']
|
24
|
+
@options.proxy ||= ENV['http_proxy']
|
25
|
+
@options.api_host ||= 'api.apiary.io'
|
26
|
+
@options.vk_url ||= 'https://voight-kampff-aws.apiary-services.com/production/validate'
|
27
|
+
@options.headers ||= {
|
28
|
+
content_type: :json,
|
29
|
+
accept: :json,
|
30
|
+
user_agent: Apiary.user_agent
|
31
|
+
}
|
32
|
+
@options.failedOnly = !@options.full_report
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute
|
36
|
+
check_api_key
|
37
|
+
if @options.fetch
|
38
|
+
fetch
|
39
|
+
else
|
40
|
+
validate
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def fetch
|
45
|
+
begin
|
46
|
+
assertions = fetch_from_apiary
|
47
|
+
assertions = JSON.parse(assertions)
|
48
|
+
rescue => e
|
49
|
+
abort "Error: Can not fetch rules and functions: #{e}"
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
File.write("./#{default_functions_file_name}", assertions['functions']['functions'])
|
54
|
+
File.write("./#{default_rules_file_name}", JSON.pretty_generate(assertions['rules']['rules']))
|
55
|
+
puts "`./#{default_functions_file_name}` and `./#{default_rules_file_name}` has beed succesfully created"
|
56
|
+
rescue => e
|
57
|
+
abort "Error: Can not write into the rules/functions file: #{e}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def validate
|
62
|
+
token = jwt
|
63
|
+
|
64
|
+
begin
|
65
|
+
token = JSON.parse(token)['jwt']
|
66
|
+
rescue JSON::ParserError => e
|
67
|
+
abort "Can not authenticate: #{e}"
|
68
|
+
end
|
69
|
+
|
70
|
+
begin
|
71
|
+
load
|
72
|
+
rescue StandardError => e
|
73
|
+
abort "Error: #{e.message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
data = {
|
77
|
+
functions: @functions,
|
78
|
+
rules: @rules,
|
79
|
+
add: @add,
|
80
|
+
failedOnly: @options.failedOnly
|
81
|
+
}.to_json
|
82
|
+
|
83
|
+
headers = @options.headers.clone
|
84
|
+
headers[:Authorization] = "Bearer #{token}"
|
85
|
+
|
86
|
+
result = call_resource(@options.vk_url, data, headers, :post)
|
87
|
+
|
88
|
+
begin
|
89
|
+
puts JSON.pretty_generate(JSON.parse(result))
|
90
|
+
rescue
|
91
|
+
abort "Error: Can not parse result: #{result}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def default_rules_file_name
|
96
|
+
'rules.json'
|
97
|
+
end
|
98
|
+
|
99
|
+
def default_functions_file_name
|
100
|
+
'functions.js'
|
101
|
+
end
|
102
|
+
|
103
|
+
def call_apiary(path, data, headers, method)
|
104
|
+
call_resource("https://#{@options.api_host}/#{path}", data, headers, method)
|
105
|
+
end
|
106
|
+
|
107
|
+
def call_resource(url, data, headers, method)
|
108
|
+
RestClient.proxy = @options.proxy
|
109
|
+
|
110
|
+
method = :post unless method
|
111
|
+
|
112
|
+
begin
|
113
|
+
response = RestClient::Request.execute(method: method, url: url, payload: data, headers: headers, verify_ssl: false)
|
114
|
+
rescue RestClient::Exception => e
|
115
|
+
begin
|
116
|
+
err = JSON.parse e.response
|
117
|
+
rescue JSON::ParserError
|
118
|
+
err = {}
|
119
|
+
end
|
120
|
+
|
121
|
+
message = 'Error: Apiary service responded with:'
|
122
|
+
|
123
|
+
if err.key? 'message'
|
124
|
+
abort "#{message} #{e.http_code} #{err['message']}"
|
125
|
+
else
|
126
|
+
abort "#{message} #{e.message}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
response
|
131
|
+
end
|
132
|
+
|
133
|
+
def jwt
|
134
|
+
path = 'styleguide-cli/get-token/'
|
135
|
+
headers = @options.headers.clone
|
136
|
+
headers[:authentication] = "Token #{@options.api_key}"
|
137
|
+
call_apiary(path, {}, headers, :get)
|
138
|
+
end
|
139
|
+
|
140
|
+
def check_api_key
|
141
|
+
unless @options.api_key && @options.api_key != ''
|
142
|
+
abort 'Error: API key must be provided through environment variable APIARY_API_KEY. \Please go to https://login.apiary.io/tokens to obtain it.'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def load
|
147
|
+
@add_path = api_description_source_path(@options.add)
|
148
|
+
@add = api_description_source(@add_path)
|
149
|
+
@functions = get_functions(@options.functions)
|
150
|
+
@rules = get_rules(@options.rules)
|
151
|
+
end
|
152
|
+
|
153
|
+
def fetch_from_apiary
|
154
|
+
path = 'styleguide-cli/get-assertions/'
|
155
|
+
headers = @options.headers.clone
|
156
|
+
headers[:authentication] = "Token #{@options.api_key}"
|
157
|
+
call_apiary(path, {}, headers, :get)
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_rules(path)
|
161
|
+
JSON.parse get_file_content(get_path(path, 'rules'))
|
162
|
+
end
|
163
|
+
|
164
|
+
def get_functions(path)
|
165
|
+
get_file_content(get_path(path, 'functions'))
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_path(path, type)
|
169
|
+
raise "`#{path}` not found" unless File.exist? path
|
170
|
+
|
171
|
+
return path if File.file? path
|
172
|
+
|
173
|
+
file = case type
|
174
|
+
when 'rules'
|
175
|
+
default_rules_file_name
|
176
|
+
else
|
177
|
+
default_functions_file_name
|
178
|
+
end
|
179
|
+
|
180
|
+
path = File.join(path, file)
|
181
|
+
|
182
|
+
return path if File.file? path
|
183
|
+
raise "`#{path}` not found"
|
184
|
+
end
|
185
|
+
|
186
|
+
def get_file_content(path)
|
187
|
+
source = nil
|
188
|
+
File.open(path, 'r:bom|utf-8') { |file| source = file.read }
|
189
|
+
source
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
data/lib/apiary/version.rb
CHANGED
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def test_abort(command, message)
|
4
|
+
expect do
|
5
|
+
begin
|
6
|
+
command.execute
|
7
|
+
rescue SystemExit
|
8
|
+
end
|
9
|
+
end.to output(/#{message}/).to_stderr
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Apiary::Command::Styleguide do
|
13
|
+
describe 'fetch' do
|
14
|
+
it 'call command without APIARY_API_KEY set' do
|
15
|
+
opts = {
|
16
|
+
fetch: true,
|
17
|
+
api_key: ''
|
18
|
+
}
|
19
|
+
command = Apiary::Command::Styleguide.new(opts)
|
20
|
+
test_abort(command, 'Error: API key must be provided through environment variable APIARY_API_KEY.')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'call command with incorrect APIARY_API_KEY' do
|
24
|
+
opts = {
|
25
|
+
fetch: true,
|
26
|
+
api_key: 'xxx'
|
27
|
+
}
|
28
|
+
|
29
|
+
command = Apiary::Command::Styleguide.new(opts)
|
30
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-assertions/").to_return(status: [403, 'This resource requires authenticated API call.'])
|
31
|
+
|
32
|
+
test_abort(command, 'Error: Apiary service responded with: 403')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'call command with correct APIARY_API_KEY' do
|
36
|
+
opts = {
|
37
|
+
fetch: true,
|
38
|
+
api_key: 'xxx'
|
39
|
+
}
|
40
|
+
|
41
|
+
command = Apiary::Command::Styleguide.new(opts)
|
42
|
+
|
43
|
+
body = '{"rules":{"_id":"598af267b999bef906c10ef8","organisation":"5577dbc613036160198734cf","createdAt":"2017-08-22T12:57:05.123Z","rules":[{"intent":"validateApiName","target":"API_Name","functionName":"validateApiName","ruleName":"validateApiName"}]},"functions":{"_id":"598af267b999bef906c10ef9","organisation":"5577dbc613036160198734cf","language":"JavaScript","functions":"/*\r\n @targets: API_Name\r\n */\r\n\r\nfunction validateApiName(apiName) {\r\n return true;\r\n};\r\n"}}'
|
44
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-assertions/").to_return(status: 200, body: body)
|
45
|
+
|
46
|
+
expect do
|
47
|
+
begin
|
48
|
+
command.execute
|
49
|
+
rescue SystemExit
|
50
|
+
end
|
51
|
+
end.to output("`./functions.js` and `./rules.json` has beed succesfully created\n").to_stdout
|
52
|
+
|
53
|
+
assertions = JSON.parse(body)
|
54
|
+
|
55
|
+
functions = nil
|
56
|
+
File.open('./functions.js', 'r:bom|utf-8') { |file| functions = file.read }
|
57
|
+
rules = nil
|
58
|
+
File.open('./rules.json', 'r:bom|utf-8') { |file| rules = file.read }
|
59
|
+
|
60
|
+
expect(assertions['functions']['functions']).to eq(functions)
|
61
|
+
expect(JSON.pretty_generate(assertions['rules']['rules'])).to eq(rules)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'validate' do
|
66
|
+
it 'call command without APIARY_API_KEY set' do
|
67
|
+
opts = {
|
68
|
+
api_key: ''
|
69
|
+
}
|
70
|
+
command = Apiary::Command::Styleguide.new(opts)
|
71
|
+
expect do
|
72
|
+
command.execute
|
73
|
+
end.to raise_error(SystemExit)
|
74
|
+
|
75
|
+
test_abort(command, 'Error: API key must be provided through environment variable APIARY_API_KEY')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'call command with incorrect APIARY_API_KEY' do
|
79
|
+
opts = {
|
80
|
+
api_key: 'xxx'
|
81
|
+
}
|
82
|
+
|
83
|
+
command = Apiary::Command::Styleguide.new(opts)
|
84
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-token/").to_return(status: 403)
|
85
|
+
|
86
|
+
test_abort(command, 'Error: Apiary service responded with: 403')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'call command with incorrect ADD path' do
|
90
|
+
opts = {
|
91
|
+
api_key: 'xxx',
|
92
|
+
functions: 'features/support',
|
93
|
+
rules: 'features/support',
|
94
|
+
add: 'features/supportXXX'
|
95
|
+
}
|
96
|
+
|
97
|
+
command = Apiary::Command::Styleguide.new(opts)
|
98
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-token/").to_return(status: 200, body: '{"jwt":"xxx"}')
|
99
|
+
|
100
|
+
test_abort(command, 'Invalid path features/supportXXX')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'call command with incorrect functions path' do
|
104
|
+
opts = {
|
105
|
+
api_key: 'xxx',
|
106
|
+
functions: 'features/supportXXY',
|
107
|
+
rules: 'features/support',
|
108
|
+
add: 'features/support'
|
109
|
+
}
|
110
|
+
|
111
|
+
command = Apiary::Command::Styleguide.new(opts)
|
112
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-token/").to_return(status: 200, body: '{"jwt":"xxx"}')
|
113
|
+
|
114
|
+
test_abort(command, 'supportXXY` not found')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'call command with incorrect rules path' do
|
118
|
+
opts = {
|
119
|
+
api_key: 'xxx',
|
120
|
+
functions: 'features/support',
|
121
|
+
rules: 'features/supportsupportXXZ',
|
122
|
+
add: 'features/support'
|
123
|
+
}
|
124
|
+
|
125
|
+
command = Apiary::Command::Styleguide.new(opts)
|
126
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-token/").to_return(status: 200, body: '{"jwt":"xxx"}')
|
127
|
+
|
128
|
+
test_abort(command, 'supportXXZ` not found')
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'call command with correct paths' do
|
132
|
+
opts = {
|
133
|
+
api_key: 'xxx',
|
134
|
+
functions: 'features/support',
|
135
|
+
rules: 'features/support',
|
136
|
+
add: 'features/support',
|
137
|
+
full_report: true
|
138
|
+
}
|
139
|
+
|
140
|
+
command = Apiary::Command::Styleguide.new(opts)
|
141
|
+
stub_request(:get, "https://#{command.options.api_host}/styleguide-cli/get-token/").to_return(status: 200, body: '{"jwt":"xxx"}')
|
142
|
+
stub_request(:post, command.options.vk_url).to_return(status: 200, body: '[]')
|
143
|
+
|
144
|
+
expect do
|
145
|
+
begin
|
146
|
+
command.execute
|
147
|
+
rescue SystemExit
|
148
|
+
end
|
149
|
+
end.to output("[\n\n]\n").to_stdout
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiaryio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apiary Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -231,7 +231,11 @@ files:
|
|
231
231
|
- features/preview.feature
|
232
232
|
- features/publish.feature
|
233
233
|
- features/step_definitions/file_content_step.rb
|
234
|
+
- features/styleguide.feature
|
235
|
+
- features/support/apiary.apib
|
234
236
|
- features/support/env.rb
|
237
|
+
- features/support/functions.js
|
238
|
+
- features/support/rules.json
|
235
239
|
- features/version.feature
|
236
240
|
- lib/apiary.rb
|
237
241
|
- lib/apiary/agent.rb
|
@@ -239,6 +243,8 @@ files:
|
|
239
243
|
- lib/apiary/command/fetch.rb
|
240
244
|
- lib/apiary/command/preview.rb
|
241
245
|
- lib/apiary/command/publish.rb
|
246
|
+
- lib/apiary/command/styleguide.rb
|
247
|
+
- lib/apiary/exceptions.rb
|
242
248
|
- lib/apiary/file_templates/preview.erb
|
243
249
|
- lib/apiary/helpers.rb
|
244
250
|
- lib/apiary/helpers/javascript_helper.rb
|
@@ -247,6 +253,7 @@ files:
|
|
247
253
|
- spec/apiary/command/fetch_spec.rb
|
248
254
|
- spec/apiary/command/preview_spec.rb
|
249
255
|
- spec/apiary/command/publish_spec.rb
|
256
|
+
- spec/apiary/command/styleguide_spec.rb
|
250
257
|
- spec/apiary/helpers_spec.rb
|
251
258
|
- spec/fixtures/api_blueprint_and_swagger/apiary.apib
|
252
259
|
- spec/fixtures/api_blueprint_and_swagger/swagger.json
|
@@ -290,12 +297,17 @@ test_files:
|
|
290
297
|
- features/preview.feature
|
291
298
|
- features/publish.feature
|
292
299
|
- features/step_definitions/file_content_step.rb
|
300
|
+
- features/styleguide.feature
|
301
|
+
- features/support/apiary.apib
|
293
302
|
- features/support/env.rb
|
303
|
+
- features/support/functions.js
|
304
|
+
- features/support/rules.json
|
294
305
|
- features/version.feature
|
295
306
|
- spec/apiary/cli_spec.rb
|
296
307
|
- spec/apiary/command/fetch_spec.rb
|
297
308
|
- spec/apiary/command/preview_spec.rb
|
298
309
|
- spec/apiary/command/publish_spec.rb
|
310
|
+
- spec/apiary/command/styleguide_spec.rb
|
299
311
|
- spec/apiary/helpers_spec.rb
|
300
312
|
- spec/fixtures/api_blueprint_and_swagger/apiary.apib
|
301
313
|
- spec/fixtures/api_blueprint_and_swagger/swagger.json
|