rspec-api-blueprint-formatter 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_blueprint.rb +9 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa97c97bdc0ff1c45846a5d0941f76ff950e483
|
4
|
+
data.tar.gz: 333ffb493e1e9289ae840e13f22b63e1cdb7860e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df31b52419a0594e5e3868648fb626267206e6788aaa8bf280f3781b4254e1d49c2dff1ce760f06e19fd6a32bec1d68ed8ce186a5250bf38982951330515ed15
|
7
|
+
data.tar.gz: 5fce90486bb6df004c785313aaea5cab8081a8383e5a1017c3e572611078d302ac6075a4f43b003b7bacfd969368478d0ef0a6bcdafd1def6aa26b85d099fe23
|
data/lib/api_blueprint.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'rspec'
|
2
|
-
require 'rspec/core/formatters/
|
2
|
+
require 'rspec/core/formatters/base_formatter'
|
3
3
|
|
4
|
-
class ApiBlueprint < RSpec::Core::Formatters::
|
5
|
-
VERSION = "0.1.
|
4
|
+
class ApiBlueprint < RSpec::Core::Formatters::BaseFormatter
|
5
|
+
VERSION = "0.1.3"
|
6
6
|
RSpec::Core::Formatters.register self, :example_passed, :example_started, :stop
|
7
7
|
|
8
8
|
def initialize(output)
|
9
9
|
super
|
10
10
|
@passed_examples = {}
|
11
11
|
@group_level = 0
|
12
|
+
RSpec.configuration.silence_filter_announcements = true
|
12
13
|
end
|
13
14
|
|
14
15
|
def example_started(notification)
|
@@ -36,7 +37,7 @@ class ApiBlueprint < RSpec::Core::Formatters::BaseTextFormatter
|
|
36
37
|
examples: {
|
37
38
|
description => {
|
38
39
|
request: {
|
39
|
-
parameters:
|
40
|
+
parameters: request.parameters.except(*request.path_parameters.keys.map(&:to_s)).to_json,
|
40
41
|
format: request.format
|
41
42
|
},
|
42
43
|
source: passed.example.instance_variable_get(:@example_block).source,
|
@@ -70,11 +71,11 @@ class ApiBlueprint < RSpec::Core::Formatters::BaseTextFormatter
|
|
70
71
|
|
71
72
|
def print_resource(resource_name, actions)
|
72
73
|
unless resource_name =~ /^[^\[\]]*\[\/[^\]]+\]/
|
73
|
-
raise "
|
74
|
+
raise "resource: '#{resource_name}' is invalid. :resource needs to be specified according to https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md#resource-section"
|
74
75
|
end
|
75
76
|
output.puts "# #{resource_name}"
|
76
77
|
|
77
|
-
http_verbs = actions.keys.map {|action| action.scan(/\[([A-Z]+)
|
78
|
+
http_verbs = actions.keys.map {|action| action.scan(/\[([A-Z]+).+\]/).flatten[0] }
|
78
79
|
|
79
80
|
unless http_verbs.length == http_verbs.uniq.length
|
80
81
|
raise "Action HTTP verbs are not unique #{actions.keys.inspect} for resource: '#{resource_name}'"
|
@@ -95,7 +96,7 @@ class ApiBlueprint < RSpec::Core::Formatters::BaseTextFormatter
|
|
95
96
|
def print_example(example_description, example_metadata)
|
96
97
|
output.puts "+ Request #{example_description}\n" \
|
97
98
|
"\n" \
|
98
|
-
"#{
|
99
|
+
" #{example_metadata[:request][:parameters]}\n" \
|
99
100
|
" \n" \
|
100
101
|
" Location: #{example_metadata[:location]}\n" \
|
101
102
|
" Source code:\n" \
|
@@ -114,7 +115,7 @@ class ApiBlueprint < RSpec::Core::Formatters::BaseTextFormatter
|
|
114
115
|
def description_array_from(example_metadata)
|
115
116
|
parent = example_metadata[:parent_example_group] if example_metadata.key?(:parent_example_group)
|
116
117
|
parent ||= example_metadata[:example_group] if example_metadata.key?(:example_group)
|
117
|
-
if parent[:action].nil?
|
118
|
+
if parent.nil? || parent[:action].nil?
|
118
119
|
[]
|
119
120
|
else
|
120
121
|
[example_metadata[:description]] + description_array_from(parent)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-api-blueprint-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nam Chu Hoai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,10 +87,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.6.7
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Use your Rspec tests to build your API documentation
|
94
94
|
test_files:
|
95
95
|
- spec/rspec/api/blueprint/formatter_spec.rb
|
96
96
|
- spec/spec_helper.rb
|
97
|
+
has_rdoc:
|