nulogy_graphql_api 4.0.0 → 4.1.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: 667ac64c08f68824afa3a9295655e83673e5368f7698183ad2ec915511e07ca7
4
- data.tar.gz: 47aad12c518ddf7384ec1b72a986d4195e11246780be5f865da50141cd0f6f4b
3
+ metadata.gz: e5df22536e696922579485014185d836121aa098afc60af021145dbd448c4950
4
+ data.tar.gz: baa28072000c782dea03575731a953de6b2473dfd50d09ee681849c0295bdac2
5
5
  SHA512:
6
- metadata.gz: d9198a3f63dba4a251caa0c271f118d14aa517ad0f76c89f0398459a8c98b513bb994930fd998016d9d980700db8ff3a2e995549b6eda4d7e30648c5c87f84cd
7
- data.tar.gz: e55542aad8ed580489783ea890914304e4a98e4f02a7518d6689038977fdeefae3618b927a84486157bb1f057f6680da0c78000394724c97e6c408ed54844615
6
+ metadata.gz: 5b4450d8522bb45ed1408acc116e3a817e1962e057d25e617241fce82248c95f8dece65736d0d177141019c9a3683cc7d72e67a6b9b932ae342f9d5240138dc3
7
+ data.tar.gz: 7632b36bcd21830c6e6a8390b484838bdddbec73cb4dd9bf35e7b1bbb981bd830a410cc6038fc34131e080df19c1f8ba3d7f7b58a97bf834c1938394d3fc9212
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.4
1
+ 3.2.4
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.1.4
1
+ ruby 3.2.4
data/Appraisals CHANGED
@@ -2,7 +2,12 @@ appraise "rails-6-1" do
2
2
  gem "rails", "6.1.4"
3
3
  end
4
4
 
5
- appraise "rails-7" do
6
- gem "rails", "7.0.4"
7
- gem "sprockets-rails", "3.4.2"
5
+ appraise "rails-7-0" do
6
+ gem "rails", "7.0.8.6"
7
+ gem "sprockets-rails", "3.5.2"
8
+ end
9
+
10
+ appraise "rails-7-1" do
11
+ gem "rails", "7.1.4.2"
12
+ gem "sprockets-rails", "3.5.2"
8
13
  end
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  _none_
6
6
 
7
+ ## 4.1.0 (2024-10-25)
8
+
9
+ * Add support for Rails 7.1
10
+ * Improve `have_graphql_data` RSpec matcher
11
+ * Match array values in any order
12
+
7
13
  ## 4.0.0 (2024-05-28)
8
14
 
9
15
  **Changes**
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "7.0.4"
6
- gem "sprockets-rails", "3.4.2"
5
+ gem "rails", "7.0.8.6"
6
+ gem "sprockets-rails", "3.5.2"
7
7
 
8
8
  gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "7.1.4.2"
6
+ gem "sprockets-rails", "3.5.2"
7
+
8
+ gemspec path: "../"
@@ -4,43 +4,72 @@ require "rspec/expectations"
4
4
  module NulogyGraphqlApi
5
5
  module GraphqlMatchers
6
6
  RSpec::Matchers.define :have_graphql_data do |expected_data|
7
- match do |graphql_response|
8
- @expected_response = { data: expected_data }
9
- expect(graphql_response).to match(@expected_response)
7
+ match do |actual_data|
8
+ # Allow the expected data to be passed without the root :data key.
9
+ @actual = actual_data[:data]
10
+ @expected = expected_data
11
+
12
+ deep_match(@expected, @actual)
10
13
  end
11
14
 
12
- failure_message do |actual_response|
13
- <<~MSG
14
- expected: #{@expected_response.pretty_inspect}
15
+ diffable
15
16
 
16
- got: #{actual_response.pretty_inspect}
17
- MSG
17
+ failure_message do
18
+ "Expected GraphQL data to match (ignoring array ordering) but found differences."
18
19
  end
19
- end
20
20
 
21
- RSpec::Matchers.define :have_graphql_error do |message|
22
- match do |actual_response|
23
- expect(actual_response.fetch(:errors, nil)).to contain_exactly(a_hash_including(
24
- message: include(message)
25
- ))
21
+ failure_message_when_negated do
22
+ "Expected GraphQL data not to match (ignoring array ordering) but found no differences."
26
23
  end
27
- end
28
24
 
29
- RSpec::Matchers.define :have_network_error do |message, error_extensions = {}|
30
- match do |actual_response|
31
- expect(actual_response).to match({
32
- data: {},
33
- errors: [{ message: message }.merge(error_extensions)]
34
- })
25
+ def actual
26
+ @actual
35
27
  end
36
- end
37
28
 
38
- RSpec::Matchers.define :include_graphql_error do |message|
39
- match do |actual_response|
40
- expect(actual_response.fetch(:errors, nil)).to include(a_hash_including(
41
- message: include(message)
42
- ))
29
+ def expected
30
+ @expected
43
31
  end
32
+
33
+ def deep_match(expected, actual)
34
+ case expected
35
+ when Hash
36
+ return false unless actual.is_a?(Hash) && expected.keys.sort == actual.keys.sort
37
+
38
+ expected.all? { |key, value| deep_match(value, actual[key]) }
39
+ when Array
40
+ return false unless actual.is_a?(Array) && expected.size == actual.size
41
+
42
+ # Sort both arrays before comparing them element by element.
43
+ expected.sort_by(&:to_s) == actual.sort_by(&:to_s)
44
+ else
45
+ expected == actual
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ RSpec::Matchers.define :have_graphql_error do |message|
52
+ match do |actual_response|
53
+ expect(actual_response.fetch(:errors, nil)).to contain_exactly(a_hash_including(
54
+ message: include(message)
55
+ ))
56
+ end
57
+ end
58
+
59
+ RSpec::Matchers.define :have_network_error do |message, error_extensions = {}|
60
+ match do |actual_response|
61
+ expect(actual_response).to match({
62
+ data: {},
63
+ errors: [{ message: message }.merge(error_extensions)]
64
+ })
65
+ end
66
+ end
67
+
68
+ RSpec::Matchers.define :include_graphql_error do |message|
69
+ match do |actual_response|
70
+ expect(actual_response.fetch(:errors, nil)).to include(a_hash_including(
71
+ message: include(message)
72
+ ))
44
73
  end
45
74
  end
46
75
  end
@@ -1,3 +1,3 @@
1
1
  module NulogyGraphqlApi
2
- VERSION = "4.0.0"
2
+ VERSION = "4.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nulogy_graphql_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-29 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -224,7 +224,8 @@ files:
224
224
  - bin/console
225
225
  - bin/setup
226
226
  - gemfiles/rails_6_1.gemfile
227
- - gemfiles/rails_7.gemfile
227
+ - gemfiles/rails_7_0.gemfile
228
+ - gemfiles/rails_7_1.gemfile
228
229
  - lib/nulogy_graphql_api.rb
229
230
  - lib/nulogy_graphql_api/error_handling.rb
230
231
  - lib/nulogy_graphql_api/graphql_error.rb
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
267
  - !ruby/object:Gem::Version
267
268
  version: '0'
268
269
  requirements: []
269
- rubygems_version: 3.3.26
270
+ rubygems_version: 3.4.19
270
271
  signing_key:
271
272
  specification_version: 4
272
273
  summary: Standard tooling for building GraphQL apis