rspec-api-blueprint-formatter 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/api_blueprint.rb +9 -8
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a24e0f18800d662999446c42eab7e44c3bd3304
4
- data.tar.gz: 505c120fb733f197f7a4cb667e53d06de190a684
3
+ metadata.gz: caa97c97bdc0ff1c45846a5d0941f76ff950e483
4
+ data.tar.gz: 333ffb493e1e9289ae840e13f22b63e1cdb7860e
5
5
  SHA512:
6
- metadata.gz: 103c92125b9d121616975e61cab4d0fa7e1ba85ae9586eda30b164baf6b3a028dd7db841616a93dd31808d118fe83c719cb7af20bfb97448b92d5e4b34e8df89
7
- data.tar.gz: 29b56a1a462e20aee707aa99e38bf1d09414df6458ffca800173028b3ff1441f81812f4554cbadec9acd6e64146209caa6c57cada8fb47740b8961746b8341c9
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/base_text_formatter'
2
+ require 'rspec/core/formatters/base_formatter'
3
3
 
4
- class ApiBlueprint < RSpec::Core::Formatters::BaseTextFormatter
5
- VERSION = "0.1.0"
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: JSON.pretty_generate(request.parameters.except(*request.path_parameters.keys.map(&:to_s))),
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 "resoure: '#{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
+ 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]+)\]/).flatten[0] }
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
- "#{indent_lines(8, example_metadata[:request][:parameters])}\n" \
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.2
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: 2015-11-25 00:00:00.000000000 Z
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.4.5.1
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: