schema_conformist 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f371fda7f28311396661b5eabe38e3630fdcf7957654b9bd9066c904adb82f8
4
- data.tar.gz: 5a7b206ae48f4124c207f16fc0cf299e5caa1f4734c4c084ca27aff85fad5167
3
+ metadata.gz: 5e54cb66b8b3d2067cff927d88c713d3c6884451015d29ec012ef9de875843cc
4
+ data.tar.gz: 2244d52ab6750d662b79c1f0e6343a80a773cf82f5cb68ef5b181b92aa6ab20b
5
5
  SHA512:
6
- metadata.gz: cf5f6565891b81181b6126d98f96399e0cfaba547c3aa6f6f01fcb8493d02c7701bc558e28522e482246e5f9f8ae25f1eb662906944ab26caf3ffac8aca38278
7
- data.tar.gz: b62c4a71d1d3efb3d9f801bd9b384326e9e49edb87b9477c84f15d0783e6ea8a58f79606c7aa668d92643c859f0fed2025df6b61d1313f08008201fe4db56ad5
6
+ metadata.gz: 5fbb90f23972a201248b92b3b757d74fca5a40b249f6f3387963cca84ebd20075823619b4af7cbf106e7ebdb7e102350a8025b7a6223209311a39b2bb6aa3ae4
7
+ data.tar.gz: 71529b799490eb6818c8336a01d78b7930dc4c6ebad10f9d031e1e9fbc5bc15ca7add1b4da222e964ba7ae38e235cc6aa5e981350dde92f7213a556ce5aa575d
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # SchemaConformist
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/schema_conformist.svg)](https://badge.fury.io/rb/schema_conformist) [![Build Status](https://travis-ci.org/kymmt90/schema_conformist.svg?branch=master)](https://travis-ci.org/kymmt90/schema_conformist)
3
+ [![Gem Version](https://badge.fury.io/rb/schema_conformist.svg)](https://badge.fury.io/rb/schema_conformist) [![Build Status](https://github.com/kymmt90/schema_conformist/workflows/build/badge.svg)](https://github.com/kymmt90/schema_conformist/actions?workflow=build)
4
4
 
5
- > An automatic JSON response validator for testing in Rails
5
+ > An automatic JSON request/response validator for testing in Rails
6
6
 
7
- SchemaConformist is an automatic JSON response validator for your API testing in Rails.
7
+ SchemaConformist is an automatic JSON request/response validator for your API testing in Rails.
8
8
 
9
- This library automatically validates that JSON responses are conformant with the schema. The schema can be described as one of [JSON Hyper Schema](http://json-schema.org/latest/json-schema-hypermedia.html), [OpenAPI 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and OpenAPI 3 (currently [3.0.2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) is latest).
9
+ This library automatically validates that JSON requests/responses are conformant with the schema. The schema can be described as one of [JSON Hyper Schema](http://json-schema.org/latest/json-schema-hypermedia.html), [OpenAPI 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and OpenAPI 3 (currently [3.0.2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) is latest).
10
10
 
11
11
  This library uses [Committee](https://github.com/interagent/committee) to validate JSONs.
12
12
 
@@ -28,7 +28,7 @@ Configure `schema_path` as follows (ex. using an OpenAPI 3 schema):
28
28
  Rails.application.config.schema_conformist.schema_path = Rails.root.join('doc', 'openapi.yaml')
29
29
  ```
30
30
 
31
- That's all. Then all JSON responses in integration-test/request-spec are validated according to your schema.
31
+ That's all. Then all JSON requests/responses in integration-test/request-spec are validated according to your schema.
32
32
 
33
33
  ### Writing the Schema
34
34
 
@@ -44,6 +44,9 @@ Configuration options are following:
44
44
  - Required. The path where the schema is placed
45
45
  - `schema_conformist.ignored_api_paths`
46
46
  - Optional. The array of API paths not to validate. Each path can be described in String literal (used for prefix search) or regular expression.
47
+ - `schema_conformist.committee.old_assert_behavior`
48
+ - Optional. Set `true` if you want to skip validating request parameters. The default value is `false`.
49
+ - cf. ["Test Assertions" in Committee README](https://github.com/interagent/committee#test-assertions)
47
50
 
48
51
  ## Contributing
49
52
 
@@ -3,7 +3,7 @@ module SchemaConformist
3
3
  include Committee::Test::Methods
4
4
 
5
5
  def committee_options
6
- { schema: committee_schema }
6
+ { schema: committee_schema }.merge(schema_conformist_committee_options)
7
7
  end
8
8
 
9
9
  def request_object
@@ -23,5 +23,9 @@ module SchemaConformist
23
23
  def schema_path
24
24
  Rails.application.config.schema_conformist.schema_path
25
25
  end
26
+
27
+ def schema_conformist_committee_options
28
+ Rails.application.config.schema_conformist.committee
29
+ end
26
30
  end
27
31
  end
@@ -2,17 +2,18 @@ module SchemaConformist
2
2
  module ProcessWithAssertion
3
3
  include SchemaConformist::Driver
4
4
 
5
- def process(*args)
6
- super *args
5
+ def process(method, path, **kwargs)
6
+ super
7
7
 
8
- path = args[1]
9
- return if ignored?(path)
8
+ return if schema_conformist_ignored_path?(path)
10
9
 
11
10
  assert_schema_conform
12
11
  end
13
12
 
14
- def ignored?(path)
15
- ignored_api_paths.any? do |pattern|
13
+ private
14
+
15
+ def schema_conformist_ignored_path?(path)
16
+ schema_conformist_ignored_api_paths.any? do |pattern|
16
17
  case pattern
17
18
  when String
18
19
  path.start_with?(pattern)
@@ -22,7 +23,7 @@ module SchemaConformist
22
23
  end
23
24
  end
24
25
 
25
- def ignored_api_paths
26
+ def schema_conformist_ignored_api_paths
26
27
  Rails.application.config.schema_conformist.ignored_api_paths
27
28
  end
28
29
  end
@@ -1,9 +1,11 @@
1
1
  module SchemaConformist
2
2
  class Railtie < Rails::Railtie
3
3
  config.before_configuration do
4
- config.schema_conformist = Configuration.new
4
+ config.schema_conformist = ActiveSupport::OrderedOptions.new
5
5
  config.schema_conformist.ignored_api_paths = []
6
6
  config.schema_conformist.schema_path = nil
7
+ config.schema_conformist.committee = ActiveSupport::OrderedOptions.new
8
+ config.schema_conformist.committee.old_assert_behavior = false
7
9
  end
8
10
  end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaConformist
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_conformist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Yamamoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,30 +30,30 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.1
33
+ version: 4.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.1
40
+ version: 4.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.6
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.6
55
- description: SchemaConformist is an automatic JSON response validator for your API
56
- testing in Rails.
54
+ version: '0'
55
+ description: SchemaConformist is an automatic JSON request/response validator for
56
+ your API testing in Rails.
57
57
  email:
58
58
  - kymmt90@gmail.com
59
59
  executables: []
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.0.3
92
+ rubygems_version: 3.1.2
93
93
  signing_key:
94
94
  specification_version: 4
95
- summary: An automatic JSON response validator for testing in Rails
95
+ summary: An automatic JSON request/response validator for testing in Rails
96
96
  test_files: []