rspec_api_blueprint_matchers 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +26 -0
  5. data/.ruby-version +1 -0
  6. data/Rakefile +2 -1
  7. data/config/rubocop/.lint_rubocop.yml +749 -0
  8. data/config/rubocop/.metrics_rubocop.yml +94 -0
  9. data/config/rubocop/.performance_rubocop.yml +323 -0
  10. data/config/rubocop/.rails_rubocop.yml +256 -0
  11. data/config/rubocop/.style_rubocop.yml +2299 -0
  12. data/docker-compose.yml +17 -0
  13. data/lib/rspec_api_blueprint_matchers.rb +1 -0
  14. data/lib/rspec_apib/config.rb +1 -0
  15. data/lib/rspec_apib/elements/annotation.rb +1 -0
  16. data/lib/rspec_apib/elements/array.rb +1 -0
  17. data/lib/rspec_apib/elements/asset.rb +1 -0
  18. data/lib/rspec_apib/elements/base.rb +11 -10
  19. data/lib/rspec_apib/elements/category.rb +2 -1
  20. data/lib/rspec_apib/elements/copy.rb +2 -1
  21. data/lib/rspec_apib/elements/data_structure.rb +2 -0
  22. data/lib/rspec_apib/elements/href_variables.rb +3 -2
  23. data/lib/rspec_apib/elements/http_headers.rb +5 -4
  24. data/lib/rspec_apib/elements/http_message_payload.rb +3 -2
  25. data/lib/rspec_apib/elements/http_request.rb +16 -10
  26. data/lib/rspec_apib/elements/http_response.rb +3 -1
  27. data/lib/rspec_apib/elements/http_transaction.rb +4 -3
  28. data/lib/rspec_apib/elements/member.rb +3 -2
  29. data/lib/rspec_apib/elements/object.rb +2 -1
  30. data/lib/rspec_apib/elements/parse_result.rb +1 -0
  31. data/lib/rspec_apib/elements/resource.rb +1 -0
  32. data/lib/rspec_apib/elements/source_map.rb +1 -0
  33. data/lib/rspec_apib/elements/string.rb +1 -0
  34. data/lib/rspec_apib/elements/templated_href.rb +1 -0
  35. data/lib/rspec_apib/elements/transition.rb +1 -0
  36. data/lib/rspec_apib/elements.rb +1 -0
  37. data/lib/rspec_apib/extractors/http_transaction.rb +1 -0
  38. data/lib/rspec_apib/extractors/resource.rb +1 -0
  39. data/lib/rspec_apib/extractors.rb +1 -0
  40. data/lib/rspec_apib/parser.rb +2 -1
  41. data/lib/rspec_apib/request.rb +7 -10
  42. data/lib/rspec_apib/response.rb +2 -2
  43. data/lib/rspec_apib/rspec.rb +4 -3
  44. data/lib/rspec_apib/transaction_coverage_report.rb +4 -3
  45. data/lib/rspec_apib/transaction_coverage_validator.rb +4 -3
  46. data/lib/rspec_apib/transaction_validator.rb +1 -0
  47. data/lib/rspec_apib/transcluder.rb +2 -2
  48. data/lib/rspec_apib/version.rb +2 -1
  49. data/lib/rspec_apib.rb +2 -1
  50. data/lib/transcluder.rb +1 -0
  51. data/rspec_api_blueprint_matchers.gemspec +6 -4
  52. metadata +25 -2
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "json"
2
3
  module RSpecApib
3
4
  class Response
@@ -27,13 +28,12 @@ module RSpecApib
27
28
  raw_response.response_headers
28
29
  end
29
30
 
30
-
31
31
  private
32
32
 
33
33
  attr_accessor :raw_response
34
34
 
35
35
  def is_json?
36
- content_type=~/json/
36
+ content_type =~ /json/
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rspec/matchers"
2
3
  require "rspec_apib/transaction_validator"
3
4
  require "rspec_apib/transaction_coverage_validator"
@@ -16,12 +17,12 @@ RSpec::Matchers.define :match_api_docs_for do |path:, request_method:, content_t
16
17
 
17
18
  end
18
19
 
19
- failure_message do |actual|
20
+ failure_message do |_actual|
20
21
  error_messages.join("\n")
21
22
  end
22
23
  end
23
24
 
24
- RSpec::Matchers.define :have_covered_all_api_documentation do | parser: RSpecApib.config.default_parser |
25
+ RSpec::Matchers.define :have_covered_all_api_documentation do |parser: RSpecApib.config.default_parser|
25
26
  error_messages = []
26
27
  Transaction = Struct.new(:request, :response)
27
28
  match do |actual|
@@ -34,7 +35,7 @@ RSpec::Matchers.define :have_covered_all_api_documentation do | parser: RSpecApi
34
35
 
35
36
  end
36
37
 
37
- failure_message do |actual|
38
+ failure_message do |_actual|
38
39
  error_messages.join("\n")
39
40
  end
40
41
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RSpecApib
2
3
  class TransactionCoverageReport
3
4
  def initialize(transactions:, parser: RSpecApib.config.default_parser)
@@ -6,8 +7,8 @@ module RSpecApib
6
7
  end
7
8
 
8
9
  def uncovered_transactions
9
- documented_transaction_tracker = parser.http_transactions.inject({}) do |acc, t|
10
- acc[t]=false
10
+ documented_transaction_tracker = parser.http_transactions.each_with_object({}) do |t, acc|
11
+ acc[t] = false
11
12
  acc
12
13
  end
13
14
  transactions.each do |requested_tx|
@@ -15,7 +16,7 @@ module RSpecApib
15
16
  documented_transaction_tracker[dtx] = true if dtx.matches?(requested_tx.request, requested_tx.response)
16
17
  end
17
18
  end
18
- documented_transaction_tracker.reject {|k,v| v}.keys
19
+ documented_transaction_tracker.reject {|_k, v| v}.keys
19
20
  end
20
21
 
21
22
  def undocumented_transactions
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rspec_apib/transaction_coverage_report"
2
3
  module RSpecApib
3
4
  class TransactionCoverageValidator
@@ -9,18 +10,18 @@ module RSpecApib
9
10
  errors = []
10
11
  reporter = TransactionCoverageReport.new(transactions: transactions, parser: parser)
11
12
  uncovered = reporter.uncovered_transactions
12
- if uncovered.length > 0
13
+ unless uncovered.empty?
13
14
  uncovered.each do |tx|
14
15
  errors << self.class.uncovered_tx_message(tx)
15
16
  end
16
17
  end
17
18
  undocumented = reporter.undocumented_transactions
18
- if undocumented.length > 0
19
+ unless undocumented.empty?
19
20
  undocumented.each do |tx|
20
21
  errors << self.class.undocumented_tx_message(tx)
21
22
  end
22
23
  end
23
- if errors.length > 0
24
+ if !errors.empty?
24
25
  error_messages.concat errors
25
26
  error_messages << "Coverage Summary: #{uncovered.length} uncovered and #{undocumented.length} undocumented transactions"
26
27
  false
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RSpecApib
2
3
  class TransactionValidator
3
4
  # validate_request_schema can be :always, :never, :when_defined
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RSpecApib::Transcluder
2
3
  REGEX = /:\[[^\]]*\]\(([^\)]*)\)/
3
4
  def self.each_line(file, &block)
@@ -15,7 +16,7 @@ module RSpecApib::Transcluder
15
16
  end
16
17
 
17
18
  def self.transclude(file, line, &block)
18
- line.gsub!(REGEX) do |match|
19
+ line.gsub!(REGEX) do |_match|
19
20
  transclude_file = $1
20
21
  unless transclude_file =~ /^\//
21
22
  transclude_file = File.expand_path(transclude_file, File.dirname(file))
@@ -26,5 +27,4 @@ module RSpecApib::Transcluder
26
27
  yield line
27
28
  end
28
29
 
29
-
30
30
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RSpecApib
2
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3".freeze
3
4
  end
data/lib/rspec_apib.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rspec_apib/version"
2
3
  require "rspec_apib/parser"
3
4
  require "rspec_apib/extractors"
@@ -7,7 +8,7 @@ require "rspec_apib/config"
7
8
  require "rspec_apib/request"
8
9
  require "rspec_apib/response"
9
10
  module RSpecApib
10
- ROOT_THREAD_VARS = :"rspec_apib"
11
+ ROOT_THREAD_VARS = :rspec_apib
11
12
  # The global configuration object
12
13
  # If a block is passed into this method, it is yielded with
13
14
  # the config object and all actions are performed from within the
data/lib/transcluder.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RSpecApib::Transcluder
2
3
 
3
4
  end
@@ -1,7 +1,8 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rspec_apib/version'
5
+ require "rspec_apib/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "rspec_api_blueprint_matchers"
@@ -9,8 +10,8 @@ Gem::Specification.new do |spec|
9
10
  spec.authors = ["Shift Commerce Ltd"]
10
11
  spec.email = ["team@shiftcommerce.com"]
11
12
 
12
- spec.summary = %q{API Blueprint Tools For RSpec}
13
- spec.description = %q{API Blueprint Tools For RSpec - Matching http transactions against an API Blueprint document to ensure the API that you are implementing matches the API that is documented which your clients will expect to be the case.}
13
+ spec.summary = "API Blueprint Tools For RSpec"
14
+ spec.description = "API Blueprint Tools For RSpec - Matching http transactions against an API Blueprint document to ensure the API that you are implementing matches the API that is documented which your clients will expect to be the case."
14
15
  spec.homepage = "https://github.com/shiftcommerce/rspec_api_blueprint_matchers"
15
16
  spec.license = "MIT"
16
17
 
@@ -26,4 +27,5 @@ Gem::Specification.new do |spec|
26
27
  spec.add_development_dependency "bundler", "~> 1.14"
27
28
  spec.add_development_dependency "byebug"
28
29
  spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rubocop", "0.46"
29
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_api_blueprint_matchers
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
  - Shift Commerce Ltd
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.46'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: '0.46'
97
111
  description: API Blueprint Tools For RSpec - Matching http transactions against an
98
112
  API Blueprint document to ensure the API that you are implementing matches the API
99
113
  that is documented which your clients will expect to be the case.
@@ -103,8 +117,11 @@ executables: []
103
117
  extensions: []
104
118
  extra_rdoc_files: []
105
119
  files:
120
+ - ".codeclimate.yml"
106
121
  - ".gitignore"
107
122
  - ".rspec"
123
+ - ".rubocop.yml"
124
+ - ".ruby-version"
108
125
  - ".travis.yml"
109
126
  - Dockerfile
110
127
  - Gemfile
@@ -115,6 +132,12 @@ files:
115
132
  - bin/setup
116
133
  - codeship-services.yml
117
134
  - codeship-steps.yml
135
+ - config/rubocop/.lint_rubocop.yml
136
+ - config/rubocop/.metrics_rubocop.yml
137
+ - config/rubocop/.performance_rubocop.yml
138
+ - config/rubocop/.rails_rubocop.yml
139
+ - config/rubocop/.style_rubocop.yml
140
+ - docker-compose.yml
118
141
  - lib/rspec_api_blueprint_matchers.rb
119
142
  - lib/rspec_apib.rb
120
143
  - lib/rspec_apib/config.rb
@@ -175,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
198
  version: '0'
176
199
  requirements: []
177
200
  rubyforge_project:
178
- rubygems_version: 2.6.10
201
+ rubygems_version: 2.6.11
179
202
  signing_key:
180
203
  specification_version: 4
181
204
  summary: API Blueprint Tools For RSpec