match-json-schema 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ceb81281ab3586daf8c4edb6feaf50e3d5015e2536cb8621fb87d8c5102041b8
4
- data.tar.gz: e3e67008679d81d568d825c2aa06b036e7399fbdad2985f02c1d6cc5cfb20158
3
+ metadata.gz: e78977fa0ea3e4d5dc3dc05350a192a469882863ddcb2926c2cbf9c8afa8ad70
4
+ data.tar.gz: 5f3c5ce7c0bcff91f538b3728a605b4370671f1682567e640c4a7b081151bb7d
5
5
  SHA512:
6
- metadata.gz: cfdc22ef91c7c2fee64060d78204ffaf29f0303d25d86a9567c21ca687bd6eb396afb6d279d88b81fbf64c123899a5d2aa1d998b730429ca00ba89d3ed5ce1a7
7
- data.tar.gz: 9c580d5babdafc7d7c1ddf6409ab6eb558a1a4726d482bf49d5317c48a1e8f78f00e616e1afa36a077a39810f716d2cbe1d7b6745cbd802a7ad82af02a2e4b55
6
+ metadata.gz: 9972455a1363f2d7150f410705d275578d105dd3a6fd23ef579818dcb438c357a76e1cef2ff294e32d1ae138b48d8fabf58e2e9ebd1efd47f1977910b864e343
7
+ data.tar.gz: 1b661aca79747bcb3c697c66c3d4b0b2fe4e87c74c1a7080dfccef5d8b438ea9066e8944707e497b10858ef570b45708d126ee18c51816e559797cd48c05533d
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: circleci/ruby:2.5.1-node
6
+ steps:
7
+ - checkout
8
+ - run: bundle install
9
+
10
+ - type: shell
11
+ command: bundle exec rake spec
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at taki@users.noreply.github.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ match-json-schema (0.2.1)
5
+ json-schema
6
+ pry-byebug
7
+ rspec (~> 3.8)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
14
+ byebug (10.0.2)
15
+ coderay (1.1.2)
16
+ diff-lcs (1.3)
17
+ json-schema (2.8.0)
18
+ addressable (>= 2.4)
19
+ method_source (0.9.0)
20
+ pry (0.11.3)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.9.0)
23
+ pry-byebug (3.6.0)
24
+ byebug (~> 10.0)
25
+ pry (~> 0.10)
26
+ public_suffix (3.0.3)
27
+ rake (10.5.0)
28
+ rspec (3.8.0)
29
+ rspec-core (~> 3.8.0)
30
+ rspec-expectations (~> 3.8.0)
31
+ rspec-mocks (~> 3.8.0)
32
+ rspec-core (3.8.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-expectations (3.8.1)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-mocks (3.8.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.8.0)
40
+ rspec-support (3.8.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.16)
47
+ match-json-schema!
48
+ rake (~> 10.0)
49
+
50
+ BUNDLED WITH
51
+ 1.16.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 taki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # match-json-schema[![CircleCI](https://circleci.com/gh/taki/match-json-schema.svg?style=svg)](https://circleci.com/gh/taki/match-json-schema)
2
+
3
+ match_json_schema compliant with JSON Schema Draft 4.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ RSpec.describe UsersController, type: :controller do
9
+ describe 'GET #show' do
10
+ let(:user) { User.create!(name: :kurou) }
11
+
12
+ specify do
13
+ get :show, params: {id: user.id, format: :json}
14
+
15
+ schema = {
16
+ type: :object,
17
+ required: %i(id name created_at updated_at),
18
+ properties: {
19
+ id: {type: :integer},
20
+ name: {type: :string},
21
+ created_at: {type: :string},
22
+ updated_at: {type: :string}
23
+ }
24
+ }
25
+
26
+ expect(response).to match_json_schema(schema)
27
+ end
28
+ end
29
+ end
30
+ ```
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ require 'json-schema'
2
+
3
+ require 'match/json/schema/rspec_matchers'
4
+
5
+ RSpec.configure do |config|
6
+ config.include Match::Json::Schema::RspecMatchers
7
+ end
@@ -0,0 +1,25 @@
1
+ module Match
2
+ module Json
3
+ module Schema
4
+ module RspecMatchers
5
+ RSpec::Matchers.define :match_json_schema do |expected|
6
+ @error_message = ''
7
+
8
+ match do |actual|
9
+ begin
10
+ JSON::Validator.validate!(expected, JSON.parse(actual.body, symbolize_names: true))
11
+ true
12
+ rescue JSON::Schema::ValidationError => e
13
+ @error_message = e.message
14
+ false
15
+ end
16
+ end
17
+
18
+ failure_message do |_actual|
19
+ @error_message
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ module Match
2
+ module Json
3
+ module Schema
4
+ VERSION = '0.2.1'.freeze
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'match/json/schema/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'match-json-schema'
7
+ spec.version = Match::Json::Schema::VERSION
8
+ spec.authors = ['taki']
9
+ spec.email = ['taki@users.noreply.github.com']
10
+
11
+ spec.summary = 'match-json-schema compliant with JSON Schema Draft 4.'
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/taki/match-json-schema'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'json-schema'
23
+ spec.add_dependency 'pry-byebug'
24
+ spec.add_dependency 'rspec', '~> 3.8'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match-json-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - taki
@@ -86,7 +86,20 @@ email:
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
- files: []
89
+ files:
90
+ - ".circleci/config.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - lib/match/json/schema.rb
100
+ - lib/match/json/schema/rspec_matchers.rb
101
+ - lib/match/json/schema/version.rb
102
+ - match_json_schema.gemspec
90
103
  homepage: https://github.com/taki/match-json-schema
91
104
  licenses:
92
105
  - MIT