rspec-json_matcher 0.2.0 → 0.3.0

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: 7791271c77095a624211ecf2b3f6bb5a9142f4d31ed43c287c2108ba84b9854d
4
- data.tar.gz: 25fd3df8548e53ff229d18ed58c15a6d6a8837005e78910e0ec52a0252862ece
3
+ metadata.gz: 82b2531f11a978fbc82311e5b11b503fda8892e677fde1c25a1e9bb4f5e9b831
4
+ data.tar.gz: bf414939343a782c9aebc0ed9d8c95163d8fbd31f5f8e2d5a0228f84e3ec45be
5
5
  SHA512:
6
- metadata.gz: cf3fb8482b30cc606f67a40113303a2487d8043fabb7fbf5ec5f2810f5697ed89fffdfba4f045192d6dd54f6f5e123744a2be321d3e341b8703a93e857541a3b
7
- data.tar.gz: 4237facf43539c1e51efa83fca24c336cd5b8bc5729da61df8263dfb06c06ff4733935c5fbc120ddf2b44866e37ab59f5935d2f8d0e0894b25c90c7a51ed40a2
6
+ metadata.gz: a56adac7e616643907c06927a0e306ba393608d3e98d1095e88b9f23d58feebf5843e172882f4784cb9fa75a442cc42b22ebbfb8bca3298351fb6f1b43b5944f
7
+ data.tar.gz: 7e8ceddda5554f5b615dd4c8b1742f8dae9f76317374c709ee8ce00caee1538c45025976111eecd84ff6664a462c1cc70c1788943b89d216b5226d57db15c4b2
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,57 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/bump-request.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'r7kamura/bump-request@v0.7.1'
9
+ - 'ruby/setup-ruby@v1.336.0'
10
+ '.github/workflows/release.yml': []
11
+ '.github/workflows/rubocop-todo-corrector.yml':
12
+ - 'r7kamura/rubocop-todo-corrector@main'
13
+ '.github/workflows/test.yml':
14
+ - 'actions/checkout@v7.0.1'
15
+ - 'ruby/setup-ruby@v1.336.0'
16
+ dependencies:
17
+ 'actions/checkout@v4':
18
+ ref: 'v4'
19
+ commit: 'sha1-11d5960a326750d5838078e36cf38b85af677262'
20
+ owner_id: 44036562
21
+ repo_id: 197814629
22
+ 'actions/checkout@v7.0.1':
23
+ ref: 'v7.0.1'
24
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
25
+ owner_id: 44036562
26
+ repo_id: 197814629
27
+ 'actions/setup-node@v7.1.0':
28
+ ref: 'v7.1.0'
29
+ commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
30
+ owner_id: 44036562
31
+ repo_id: 189476904
32
+ 'r7kamura/bump-request@v0.7.1':
33
+ ref: 'v0.7.1'
34
+ commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
35
+ owner_id: 111689
36
+ repo_id: 533135195
37
+ uses:
38
+ - 'actions/checkout@v7.0.1'
39
+ - 'actions/setup-node@v7.1.0'
40
+ 'r7kamura/rubocop-todo-corrector@main':
41
+ ref: 'main'
42
+ commit: 'sha1-e65211b91997886cad03acba4bf3dfd0b6c7b64c'
43
+ owner_id: 111689
44
+ repo_id: 492378884
45
+ uses:
46
+ - 'actions/checkout@v4'
47
+ - 'ruby/setup-ruby@v1'
48
+ 'ruby/setup-ruby@v1':
49
+ ref: 'v1'
50
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
51
+ owner_id: 210414
52
+ repo_id: 231208785
53
+ 'ruby/setup-ruby@v1.336.0':
54
+ ref: 'v1.336.0'
55
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
56
+ owner_id: 210414
57
+ repo_id: 231208785
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7.0.1
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1.336.0
18
+ with:
19
+ ruby-version: 3.3
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0.7.1
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/rspec/json_matcher/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,11 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ uses: r7kamura/workflows/.github/workflows/gem-release.yml@main
11
+ if: github.repository_owner == 'r7kamura'
@@ -0,0 +1,10 @@
1
+ name: rubocop-todo-corrector
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ run:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: r7kamura/rubocop-todo-corrector@main
@@ -12,11 +12,13 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  ruby:
15
- - 2.7.2
15
+ - '3.3'
16
+ - '3.4'
17
+ - '4.0'
16
18
  steps:
17
- - uses: actions/checkout@v2
19
+ - uses: actions/checkout@v7.0.1
18
20
  - name: Set up Ruby
19
- uses: ruby/setup-ruby@v1
21
+ uses: ruby/setup-ruby@v1.336.0
20
22
  with:
21
23
  ruby-version: ${{ matrix.ruby }}
22
24
  bundler-cache: true
data/.gitignore CHANGED
@@ -14,3 +14,5 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+
18
+ /vendor/
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ SuggestExtensions: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,151 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-05-16 03:43:21 UTC using RuboCop version 1.29.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe auto-correction (--auto-correct).
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/OrderedDependencies:
14
+ Exclude:
15
+ - 'rspec-json_matcher.gemspec'
16
+
17
+ # Offense count: 1
18
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
19
+ Metrics/AbcSize:
20
+ Max: 37
21
+
22
+ # Offense count: 5
23
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
24
+ # IgnoredMethods: refine
25
+ Metrics/BlockLength:
26
+ Max: 292
27
+
28
+ # Offense count: 1
29
+ # Configuration parameters: IgnoredMethods.
30
+ Metrics/CyclomaticComplexity:
31
+ Max: 8
32
+
33
+ # Offense count: 2
34
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
35
+ Metrics/MethodLength:
36
+ Max: 13
37
+
38
+ # Offense count: 1
39
+ # Configuration parameters: IgnoredMethods.
40
+ Metrics/PerceivedComplexity:
41
+ Max: 9
42
+
43
+ # Offense count: 1
44
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
45
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
46
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
47
+ Naming/FileName:
48
+ Exclude:
49
+ - 'lib/rspec-json_matcher.rb'
50
+
51
+ # Offense count: 9
52
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
53
+ # NamePrefix: is_, has_, have_
54
+ # ForbiddenPrefixes: is_, has_, have_
55
+ # AllowedMethods: is_a?
56
+ # MethodDefinitionMacros: define_method, define_singleton_method
57
+ Naming/PredicateName:
58
+ Exclude:
59
+ - 'spec/**/*'
60
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
61
+ - 'lib/rspec/json_matcher/abstract_matcher.rb'
62
+ - 'lib/rspec/json_matcher/exact_comparer.rb'
63
+ - 'lib/rspec/json_matcher/fuzzy_comparer.rb'
64
+
65
+ # Offense count: 1
66
+ # This cop supports safe auto-correction (--auto-correct).
67
+ # Configuration parameters: AllowOnConstant.
68
+ Style/CaseEquality:
69
+ Exclude:
70
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
71
+
72
+ # Offense count: 1
73
+ # This cop supports safe auto-correction (--auto-correct).
74
+ # Configuration parameters: IgnoredMethods.
75
+ # IgnoredMethods: ==, equal?, eql?
76
+ Style/ClassEqualityComparison:
77
+ Exclude:
78
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
79
+
80
+ # Offense count: 7
81
+ # Configuration parameters: AllowedConstants.
82
+ Style/Documentation:
83
+ Exclude:
84
+ - 'spec/**/*'
85
+ - 'test/**/*'
86
+ - 'lib/rspec/json_matcher.rb'
87
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
88
+ - 'lib/rspec/json_matcher/abstract_matcher.rb'
89
+ - 'lib/rspec/json_matcher/exact_comparer.rb'
90
+ - 'lib/rspec/json_matcher/exact_matcher.rb'
91
+ - 'lib/rspec/json_matcher/fuzzy_comparer.rb'
92
+ - 'lib/rspec/json_matcher/fuzzy_matcher.rb'
93
+
94
+ # Offense count: 2
95
+ # This cop supports safe auto-correction (--auto-correct).
96
+ Style/ExpandPathArguments:
97
+ Exclude:
98
+ - 'rspec-json_matcher.gemspec'
99
+ - 'spec/spec_helper.rb'
100
+
101
+ # Offense count: 13
102
+ # This cop supports safe auto-correction (--auto-correct).
103
+ # Configuration parameters: EnforcedStyle.
104
+ # SupportedStyles: always, always_true, never
105
+ Style/FrozenStringLiteralComment:
106
+ Exclude:
107
+ - 'Gemfile'
108
+ - 'lib/rspec-json_matcher.rb'
109
+ - 'lib/rspec/json_matcher.rb'
110
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
111
+ - 'lib/rspec/json_matcher/abstract_matcher.rb'
112
+ - 'lib/rspec/json_matcher/exact_comparer.rb'
113
+ - 'lib/rspec/json_matcher/exact_matcher.rb'
114
+ - 'lib/rspec/json_matcher/fuzzy_comparer.rb'
115
+ - 'lib/rspec/json_matcher/fuzzy_matcher.rb'
116
+ - 'lib/rspec/json_matcher/version.rb'
117
+ - 'rspec-json_matcher.gemspec'
118
+ - 'spec/rspec/json_matcher_spec.rb'
119
+ - 'spec/spec_helper.rb'
120
+
121
+ # Offense count: 1
122
+ # This cop supports safe auto-correction (--auto-correct).
123
+ # Configuration parameters: EnforcedStyle.
124
+ # SupportedStyles: literals, strict
125
+ Style/MutableConstant:
126
+ Exclude:
127
+ - 'lib/rspec/json_matcher/version.rb'
128
+
129
+ # Offense count: 1
130
+ # This cop supports unsafe auto-correction (--auto-correct-all).
131
+ # Configuration parameters: EnforcedStyle.
132
+ # SupportedStyles: short, verbose
133
+ Style/PreferredHashMethods:
134
+ Exclude:
135
+ - 'lib/rspec/json_matcher/abstract_comparer.rb'
136
+
137
+ # Offense count: 4
138
+ # This cop supports safe auto-correction (--auto-correct).
139
+ # Configuration parameters: EnforcedStyleForMultiline.
140
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
141
+ Style/TrailingCommaInArrayLiteral:
142
+ Exclude:
143
+ - 'spec/rspec/json_matcher_spec.rb'
144
+
145
+ # Offense count: 12
146
+ # This cop supports safe auto-correction (--auto-correct).
147
+ # Configuration parameters: EnforcedStyleForMultiline.
148
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
149
+ Style/TrailingCommaInHashLiteral:
150
+ Exclude:
151
+ - 'spec/rspec/json_matcher_spec.rb'
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ gemspec
6
6
  gem 'bundler'
7
7
  gem 'rake'
8
8
  gem 'rspec'
9
+ gem 'rubocop'
data/Gemfile.lock CHANGED
@@ -1,30 +1,59 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-json_matcher (0.2.0)
4
+ rspec-json_matcher (0.3.0)
5
5
  amazing_print
6
6
  json
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- amazing_print (1.4.0)
12
- diff-lcs (1.5.0)
13
- json (2.6.1)
14
- rake (13.0.6)
15
- rspec (3.11.0)
16
- rspec-core (~> 3.11.0)
17
- rspec-expectations (~> 3.11.0)
18
- rspec-mocks (~> 3.11.0)
19
- rspec-core (3.11.0)
20
- rspec-support (~> 3.11.0)
21
- rspec-expectations (3.11.0)
11
+ amazing_print (3.0.0)
12
+ ast (2.4.3)
13
+ diff-lcs (1.6.2)
14
+ json (3.1.0)
15
+ language_server-protocol (3.17.0.6)
16
+ lint_roller (1.1.0)
17
+ parallel (2.3.0)
18
+ parser (3.3.13.0)
19
+ ast (~> 2.4.1)
20
+ racc
21
+ prism (1.9.0)
22
+ racc (1.8.1)
23
+ rainbow (3.1.1)
24
+ rake (13.4.2)
25
+ regexp_parser (2.13.1)
26
+ rspec (3.13.2)
27
+ rspec-core (~> 3.13.0)
28
+ rspec-expectations (~> 3.13.0)
29
+ rspec-mocks (~> 3.13.0)
30
+ rspec-core (3.13.6)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-expectations (3.13.5)
22
33
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.11.0)
24
- rspec-mocks (3.11.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-mocks (3.13.8)
25
36
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.11.0)
27
- rspec-support (3.11.0)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-support (3.13.7)
39
+ rubocop (1.92.2)
40
+ json (>= 2.3)
41
+ language_server-protocol (~> 3.17.0.2)
42
+ lint_roller (~> 1.1.0)
43
+ parallel (>= 1.10)
44
+ parser (>= 3.3.0.2)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 2.11.3, < 3.0)
47
+ rubocop-ast (>= 1.49.0, < 2.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 2.4.0, < 4.0)
50
+ rubocop-ast (1.50.0)
51
+ parser (>= 3.3.7.2)
52
+ prism (~> 1.7)
53
+ ruby-progressbar (1.13.0)
54
+ unicode-display_width (3.3.0)
55
+ unicode-emoji (~> 4.3)
56
+ unicode-emoji (4.3.0)
28
57
 
29
58
  PLATFORMS
30
59
  x86_64-linux
@@ -34,6 +63,7 @@ DEPENDENCIES
34
63
  rake
35
64
  rspec
36
65
  rspec-json_matcher!
66
+ rubocop
37
67
 
38
68
  BUNDLED WITH
39
- 2.3.6
69
+ 4.0.20
data/README.md CHANGED
@@ -1,13 +1,20 @@
1
1
  # RSpec::JsonMatcher
2
2
 
3
- [![test](https://github.com/r7kamura/rspec-json_matcher/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/rspec-json_matcher/actions/workflows/test.yml)
4
-
5
3
  This library provides RSpec matcher for testing JSON string.
6
4
 
7
5
  * parsing a given value as JSON string
8
6
  * handy pattern matching with `#===` method like case-when statement
9
7
  * supporting nested pattern matching
10
8
 
9
+ ## Installation
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add rspec-json_matcher
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install rspec-json_matcher
11
18
  ## Usage
12
19
  ### Configuration
13
20
  ```ruby
@@ -22,19 +22,19 @@ module RSpec
22
22
  false
23
23
  end
24
24
 
25
- alias_method :===, :matches?
25
+ alias === matches?
26
26
 
27
27
  def compare(&reason)
28
28
  raise NotImplementedError, "You must implement #{self.class}#compare"
29
29
  end
30
30
 
31
31
  def description
32
- "be JSON"
32
+ 'be JSON'
33
33
  end
34
34
 
35
35
  def failure_message
36
36
  if has_parser_error?
37
- "expected value to be parsed as JSON, but failed"
37
+ 'expected value to be parsed as JSON, but failed'
38
38
  else
39
39
  inspection
40
40
  end
@@ -42,12 +42,12 @@ module RSpec
42
42
 
43
43
  def negative_failure_message
44
44
  if has_parser_error?
45
- "expected value not to be parsed as JSON, but succeeded"
45
+ 'expected value not to be parsed as JSON, but succeeded'
46
46
  else
47
- inspection("not ")
47
+ inspection('not ')
48
48
  end
49
49
  end
50
- alias :failure_message_when_negated :negative_failure_message
50
+ alias failure_message_when_negated negative_failure_message
51
51
 
52
52
  private
53
53
 
@@ -60,8 +60,8 @@ module RSpec
60
60
  end
61
61
 
62
62
  def inspection(prefix = nil)
63
- messages = ["expected #{prefix}to match:", expected.ai(indent: -2), "", "actual:", parsed.ai(indent: -2), ""]
64
- messages.push "reason: #{reasons.reverse.join(".")}" unless reasons.empty?
63
+ messages = ["expected #{prefix}to match:", expected.ai(indent: -2), '', 'actual:', parsed.ai(indent: -2), '']
64
+ messages.push "reason: #{reasons.reverse.join('.')}" unless reasons.empty?
65
65
  messages.join("\n")
66
66
  end
67
67
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module JsonMatcher
3
- VERSION = "0.2.0"
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -1,12 +1,12 @@
1
- require "rspec/json_matcher/version"
2
- require "rspec/json_matcher/abstract_comparer"
3
- require "rspec/json_matcher/exact_comparer"
4
- require "rspec/json_matcher/fuzzy_comparer"
5
- require "rspec/json_matcher/abstract_matcher"
6
- require "rspec/json_matcher/exact_matcher"
7
- require "rspec/json_matcher/fuzzy_matcher"
8
- require "json"
9
- require "amazing_print"
1
+ require 'rspec/json_matcher/version'
2
+ require 'rspec/json_matcher/abstract_comparer'
3
+ require 'rspec/json_matcher/exact_comparer'
4
+ require 'rspec/json_matcher/fuzzy_comparer'
5
+ require 'rspec/json_matcher/abstract_matcher'
6
+ require 'rspec/json_matcher/exact_matcher'
7
+ require 'rspec/json_matcher/fuzzy_matcher'
8
+ require 'json'
9
+ require 'amazing_print'
10
10
 
11
11
  module RSpec
12
12
  module JsonMatcher
@@ -1 +1 @@
1
- require "rspec/json_matcher"
1
+ require 'rspec/json_matcher'
@@ -1,23 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ require 'English'
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "rspec/json_matcher/version"
4
+ require 'rspec/json_matcher/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "rspec-json_matcher"
7
+ spec.name = 'rspec-json_matcher'
8
8
  spec.version = RSpec::JsonMatcher::VERSION
9
- spec.authors = ["Ryo Nakamura"]
10
- spec.email = ["r7kamura@gmail.com"]
11
- spec.description = "This library provides RSpec matcher for testing JSON string."
12
- spec.summary = "RSpec matcher for testing JSON string"
13
- spec.homepage = "https://github.com/r7kamura/rspec-json_matcher"
14
- spec.license = "MIT"
9
+ spec.authors = ['Ryo Nakamura']
10
+ spec.email = ['r7kamura@gmail.com']
11
+ spec.description = 'This library provides RSpec matcher for testing JSON string.'
12
+ spec.summary = 'RSpec matcher for testing JSON string'
13
+ spec.homepage = 'https://github.com/r7kamura/rspec-json_matcher'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.required_ruby_version = '>= 3.3'
17
+
18
+ spec.metadata['rubygems_mfa_required'] = 'true'
19
+
20
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
20
24
 
21
- spec.add_dependency "json"
22
- spec.add_dependency "amazing_print"
25
+ spec.add_dependency 'json'
26
+ spec.add_dependency 'amazing_print'
23
27
  end
@@ -1,15 +1,15 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe RSpec::JsonMatcher do
4
- describe "#be_json" do
5
- context "with invalid JSON" do
6
- it "does not match" do
7
- "".should_not be_json
4
+ describe '#be_json' do
5
+ context 'with invalid JSON' do
6
+ it 'does not match' do
7
+ ''.should_not be_json
8
8
  end
9
9
  end
10
10
 
11
- context "with valid JSON" do
12
- it "matches" do
11
+ context 'with valid JSON' do
12
+ it 'matches' do
13
13
  {}.to_json.should be_json
14
14
  end
15
15
  end
@@ -17,295 +17,295 @@ describe RSpec::JsonMatcher do
17
17
  context 'when used with a composable matcher' do
18
18
  it 'matches' do
19
19
  {
20
- "a" => {"b" => 1}.to_json
21
- }.should match("a" => be_json)
20
+ 'a' => { 'b' => 1 }.to_json
21
+ }.should match('a' => be_json)
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
- describe "#be_json_as" do
27
- context "with invalid JSON" do
28
- it "does not match" do
29
- "".should_not be_json_as("a" => "b")
26
+ describe '#be_json_as' do
27
+ context 'with invalid JSON' do
28
+ it 'does not match' do
29
+ ''.should_not be_json_as('a' => 'b')
30
30
  end
31
31
  end
32
32
 
33
- context "with few keys" do
34
- it "does not match" do
33
+ context 'with few keys' do
34
+ it 'does not match' do
35
35
  {
36
- "a" => 1,
37
- "b" => 2,
36
+ 'a' => 1,
37
+ 'b' => 2,
38
38
  }.to_json.should_not be_json_as(
39
- "a" => 1,
39
+ 'a' => 1
40
40
  )
41
41
  end
42
42
  end
43
43
 
44
- context "with too many keys" do
45
- it "does not match" do
44
+ context 'with too many keys' do
45
+ it 'does not match' do
46
46
  {
47
- "a" => 1,
47
+ 'a' => 1,
48
48
  }.to_json.should_not be_json_as(
49
- "a" => 1,
50
- "b" => 2,
49
+ 'a' => 1,
50
+ 'b' => 2
51
51
  )
52
52
  end
53
53
  end
54
54
 
55
- context "with different values" do
56
- it "does not match" do
55
+ context 'with different values' do
56
+ it 'does not match' do
57
57
  {
58
- "a" => 1,
59
- "b" => 2,
58
+ 'a' => 1,
59
+ 'b' => 2,
60
60
  }.to_json.should_not be_json_as(
61
- "a" => 2,
62
- "b" => 2,
61
+ 'a' => 2,
62
+ 'b' => 2
63
63
  )
64
64
  end
65
65
  end
66
66
 
67
- context "with same keys and values" do
68
- it "matches" do
67
+ context 'with same keys and values' do
68
+ it 'matches' do
69
69
  {
70
- "a" => 1,
71
- "b" => 2,
70
+ 'a' => 1,
71
+ 'b' => 2,
72
72
  }.to_json.should be_json_as(
73
- "a" => 1,
74
- "b" => 2,
73
+ 'a' => 1,
74
+ 'b' => 2
75
75
  )
76
76
  end
77
77
  end
78
78
 
79
- context "with nil values" do
80
- it "does not match" do
79
+ context 'with nil values' do
80
+ it 'does not match' do
81
81
  {
82
- "a" => nil,
82
+ 'a' => nil,
83
83
  }.to_json.should_not be_json_as(
84
- "b" => nil,
84
+ 'b' => nil
85
85
  )
86
86
  end
87
87
  end
88
88
 
89
- context "with subset array" do
90
- it "does not match" do
91
- [
92
- "a",
93
- "b",
89
+ context 'with subset array' do
90
+ it 'does not match' do
91
+ %w[
92
+ a
93
+ b
94
94
  ].to_json.should_not be_json_as(
95
95
  [
96
- "a",
97
- ],
96
+ 'a',
97
+ ]
98
98
  )
99
99
  end
100
100
  end
101
101
 
102
- context "with superset array" do
103
- it "does not match" do
104
- [
105
- "a",
106
- "b",
102
+ context 'with superset array' do
103
+ it 'does not match' do
104
+ %w[
105
+ a
106
+ b
107
107
  ].to_json.should_not be_json_as(
108
- [
109
- "a",
110
- "b",
111
- "c",
112
- ],
108
+ %w[
109
+ a
110
+ b
111
+ c
112
+ ]
113
113
  )
114
114
  end
115
115
  end
116
116
 
117
- context "with superset array with nil" do
118
- it "does not match" do
119
- [
120
- "a",
121
- "b",
117
+ context 'with superset array with nil' do
118
+ it 'does not match' do
119
+ %w[
120
+ a
121
+ b
122
122
  ].to_json.should_not be_json_as(
123
123
  [
124
- "a",
125
- "b",
124
+ 'a',
125
+ 'b',
126
126
  nil,
127
- ],
127
+ ]
128
128
  )
129
129
  end
130
130
  end
131
131
 
132
- context "with complex JSON" do
133
- it "matches" do
132
+ context 'with complex JSON' do
133
+ it 'matches' do
134
134
  [
135
135
  {
136
- "url" => "https://api.github.com/gists/17a07d0a27fd3f708f5f",
137
- "id" => "1",
138
- "description" => "description of gist",
139
- "public" => true,
140
- "user" => {
141
- "login" => "octocat",
142
- "id" => 1,
143
- "avatar_url" => "https://github.com/images/error/octocat_happy.gif",
144
- "gravatar_id" => "somehexcode",
145
- "url" => "https://api.github.com/users/octocat"
136
+ 'url' => 'https://api.github.com/gists/17a07d0a27fd3f708f5f',
137
+ 'id' => '1',
138
+ 'description' => 'description of gist',
139
+ 'public' => true,
140
+ 'user' => {
141
+ 'login' => 'octocat',
142
+ 'id' => 1,
143
+ 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
144
+ 'gravatar_id' => 'somehexcode',
145
+ 'url' => 'https://api.github.com/users/octocat'
146
146
  },
147
- "files" => {
148
- "ring.erl" => {
149
- "size" => 932,
150
- "filename" => "ring.erl",
151
- "raw_url" => "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
147
+ 'files' => {
148
+ 'ring.erl' => {
149
+ 'size' => 932,
150
+ 'filename' => 'ring.erl',
151
+ 'raw_url' => 'https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl'
152
152
  }
153
153
  },
154
- "comments" => 0,
155
- "comments_url" => "https://api.github.com/gists/6fb6af8cb6e26dbbc327/comments/",
156
- "html_url" => "https://gist.github.com/1",
157
- "git_pull_url" => "git://gist.github.com/1.git",
158
- "git_push_url" => "git@gist.github.com:1.git",
159
- "created_at" => "2010-04-14T02:15:15Z"
154
+ 'comments' => 0,
155
+ 'comments_url' => 'https://api.github.com/gists/6fb6af8cb6e26dbbc327/comments/',
156
+ 'html_url' => 'https://gist.github.com/1',
157
+ 'git_pull_url' => 'git://gist.github.com/1.git',
158
+ 'git_push_url' => 'git@gist.github.com:1.git',
159
+ 'created_at' => '2010-04-14T02:15:15Z'
160
160
  }
161
161
  ].to_json.should be_json_as([
162
- {
163
- "url" => /^https:/,
164
- "id" => /^\d+$/,
165
- "description" => /gist/,
166
- "public" => true,
167
- "user" => Hash,
168
- "files" => Hash,
169
- "comments" => Fixnum,
170
- "comments_url" => /^https:/,
171
- "html_url" => /^https:/,
172
- "git_pull_url" => /^git:/,
173
- "git_push_url" => /^git@/,
174
- "created_at" => /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/,
175
- }
176
- ])
162
+ {
163
+ 'url' => /^https:/,
164
+ 'id' => /^\d+$/,
165
+ 'description' => /gist/,
166
+ 'public' => true,
167
+ 'user' => Hash,
168
+ 'files' => Hash,
169
+ 'comments' => Integer,
170
+ 'comments_url' => /^https:/,
171
+ 'html_url' => /^https:/,
172
+ 'git_pull_url' => /^git:/,
173
+ 'git_push_url' => /^git@/,
174
+ 'created_at' => /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/,
175
+ }
176
+ ])
177
177
  end
178
178
  end
179
179
 
180
- context "with symbol keys expectation" do
181
- it "matches" do
182
- { "foo" => "bar" }.to_json.should be_json_as(foo: "bar")
180
+ context 'with symbol keys expectation' do
181
+ it 'matches' do
182
+ { 'foo' => 'bar' }.to_json.should be_json_as(foo: 'bar')
183
183
  end
184
184
  end
185
185
 
186
186
  context 'when used with a composable matcher' do
187
187
  it 'matches' do
188
188
  {
189
- "a" => {"b" => 1}.to_json
190
- }.should match("a" => be_json_as("b" => 1))
189
+ 'a' => { 'b' => 1 }.to_json
190
+ }.should match('a' => be_json_as('b' => 1))
191
191
  end
192
192
  end
193
193
  end
194
194
 
195
- describe "#be_json_including" do
196
- context "with invalid JSON" do
197
- it "does not match" do
198
- "".should_not be_json_including("a" => "b")
195
+ describe '#be_json_including' do
196
+ context 'with invalid JSON' do
197
+ it 'does not match' do
198
+ ''.should_not be_json_including('a' => 'b')
199
199
  end
200
200
  end
201
201
 
202
- context "with few keys" do
203
- it "matches" do
202
+ context 'with few keys' do
203
+ it 'matches' do
204
204
  {
205
- "a" => 1,
206
- "b" => 2,
205
+ 'a' => 1,
206
+ 'b' => 2,
207
207
  }.to_json.should be_json_including(
208
- "a" => 1,
208
+ 'a' => 1
209
209
  )
210
210
  end
211
211
  end
212
212
 
213
- context "with too many keys" do
214
- it "matches" do
213
+ context 'with too many keys' do
214
+ it 'matches' do
215
215
  {
216
- "a" => 1,
216
+ 'a' => 1,
217
217
  }.to_json.should_not be_json_including(
218
- "a" => 1,
219
- "b" => 2,
218
+ 'a' => 1,
219
+ 'b' => 2
220
220
  )
221
221
  end
222
222
  end
223
223
 
224
- context "with different values" do
225
- it "does not match" do
224
+ context 'with different values' do
225
+ it 'does not match' do
226
226
  {
227
- "a" => 1,
228
- "b" => 2,
227
+ 'a' => 1,
228
+ 'b' => 2,
229
229
  }.to_json.should_not be_json_including(
230
- "a" => 2,
231
- "b" => 2,
230
+ 'a' => 2,
231
+ 'b' => 2
232
232
  )
233
233
  end
234
234
  end
235
235
 
236
- context "with partially different set" do
237
- it "does not match" do
236
+ context 'with partially different set' do
237
+ it 'does not match' do
238
238
  {
239
- "a" => 1,
240
- "b" => 2,
239
+ 'a' => 1,
240
+ 'b' => 2,
241
241
  }.to_json.should_not be_json_including(
242
- "a" => 0,
243
- "b" => 2,
242
+ 'a' => 0,
243
+ 'b' => 2
244
244
  )
245
245
  end
246
246
  end
247
247
 
248
- context "with same keys and values" do
249
- it "matches" do
248
+ context 'with same keys and values' do
249
+ it 'matches' do
250
250
  {
251
- "a" => 1,
252
- "b" => 2,
251
+ 'a' => 1,
252
+ 'b' => 2,
253
253
  }.to_json.should be_json_including(
254
- "a" => 1,
255
- "b" => 2,
254
+ 'a' => 1,
255
+ 'b' => 2
256
256
  )
257
257
  end
258
258
  end
259
259
 
260
- context "with nil values" do
261
- it "does not match" do
260
+ context 'with nil values' do
261
+ it 'does not match' do
262
262
  {
263
- "a" => nil,
263
+ 'a' => nil,
264
264
  }.to_json.should_not be_json_including(
265
- "b" => nil,
265
+ 'b' => nil
266
266
  )
267
267
  end
268
268
  end
269
269
 
270
- context "with subset array" do
271
- it "does not match" do
272
- [
273
- "a",
274
- "b",
270
+ context 'with subset array' do
271
+ it 'does not match' do
272
+ %w[
273
+ a
274
+ b
275
275
  ].to_json.should be_json_including(
276
276
  [
277
- "a",
278
- ],
277
+ 'a',
278
+ ]
279
279
  )
280
280
  end
281
281
  end
282
282
 
283
- context "with superset array" do
284
- it "does not match" do
285
- [
286
- "a",
287
- "b",
283
+ context 'with superset array' do
284
+ it 'does not match' do
285
+ %w[
286
+ a
287
+ b
288
288
  ].to_json.should_not be_json_including(
289
- [
290
- "a",
291
- "b",
292
- "c",
293
- ],
289
+ %w[
290
+ a
291
+ b
292
+ c
293
+ ]
294
294
  )
295
295
  end
296
296
  end
297
297
 
298
- context "with superset array with nil" do
299
- it "does not match" do
300
- [
301
- "a",
302
- "b",
298
+ context 'with superset array with nil' do
299
+ it 'does not match' do
300
+ %w[
301
+ a
302
+ b
303
303
  ].to_json.should_not be_json_including(
304
304
  [
305
- "a",
306
- "b",
305
+ 'a',
306
+ 'b',
307
307
  nil,
308
- ],
308
+ ]
309
309
  )
310
310
  end
311
311
  end
@@ -313,8 +313,8 @@ describe RSpec::JsonMatcher do
313
313
  context 'when used with a composable matcher' do
314
314
  it 'matches' do
315
315
  {
316
- "a" => {"b" => 1, "c" => 2}.to_json
317
- }.should match("a" => be_json_including("b" => 1))
316
+ 'a' => { 'b' => 1, 'c' => 2 }.to_json
317
+ }.should match('a' => be_json_including('b' => 1))
318
318
  end
319
319
  end
320
320
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("../../lib/rspec/json_matcher", __FILE__)
1
+ require File.expand_path('../../lib/rspec/json_matcher', __FILE__)
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.treat_symbols_as_metadata_keys_with_true_values = true
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-json_matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: json
@@ -45,8 +44,15 @@ executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
47
+ - ".github/release.yml"
48
+ - ".github/workflows/actions.lock"
49
+ - ".github/workflows/bump-request.yml"
50
+ - ".github/workflows/release.yml"
51
+ - ".github/workflows/rubocop-todo-corrector.yml"
48
52
  - ".github/workflows/test.yml"
49
53
  - ".gitignore"
54
+ - ".rubocop.yml"
55
+ - ".rubocop_todo.yml"
50
56
  - CHANGELOG.md
51
57
  - Gemfile
52
58
  - Gemfile.lock
@@ -68,8 +74,8 @@ files:
68
74
  homepage: https://github.com/r7kamura/rspec-json_matcher
69
75
  licenses:
70
76
  - MIT
71
- metadata: {}
72
- post_install_message:
77
+ metadata:
78
+ rubygems_mfa_required: 'true'
73
79
  rdoc_options: []
74
80
  require_paths:
75
81
  - lib
@@ -77,15 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
83
  requirements:
78
84
  - - ">="
79
85
  - !ruby/object:Gem::Version
80
- version: '0'
86
+ version: '3.3'
81
87
  required_rubygems_version: !ruby/object:Gem::Requirement
82
88
  requirements:
83
89
  - - ">="
84
90
  - !ruby/object:Gem::Version
85
91
  version: '0'
86
92
  requirements: []
87
- rubygems_version: 3.1.4
88
- signing_key:
93
+ rubygems_version: 4.0.20
89
94
  specification_version: 4
90
95
  summary: RSpec matcher for testing JSON string
91
96
  test_files: