rspec-graphql_response 0.4.1 → 0.6.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: 647c52ffa5ae347bc9c2166bd94af15ee82556d10f37fa5a11a0cf0229d40b31
4
- data.tar.gz: a93873e4d4a40a9a4702026321d96d913056188dd51eec86836232add5e7c4b7
3
+ metadata.gz: 3d20c225bcb889589108bbd4523938d1788251b035c470c58a558e402e220881
4
+ data.tar.gz: 97e2843002042b969f022194069e169390167d7b5efaedfcfcc7d78a51cabbd6
5
5
  SHA512:
6
- metadata.gz: 9ad72db1bdd814a65f02cf4ee9a59c9836c452003fe840e9c28903aa805ab0553fcd7afa4558d610c63c5ae1959fea61690f037641bd3fa31b417c378ed1805a
7
- data.tar.gz: 46ec7e724d5784feb01e33fbb5024d9c8713ddb8df77a1efb2273f1dd94c2bf8c3658ecb1f11ad9065741119b6e4a71815f9911ba3e87a779caafe97563b2dd8
6
+ metadata.gz: 9c832fd141b73dffc2dd85ed9bde975221316cb099e70861e1c050374e63500fa2d2a8a60f032a3a285e078e08d7f49524014a25828d26e4936dd1a3b01ab2d5
7
+ data.tar.gz: f0aa94ec23124e526097dd60713e4d2846293ec98acfa9dc9d6bbddaed76b9baf737c18962fadcac1f354d9de2cf0bb26782e3125f304ba1c9d004d5894d56bd
@@ -0,0 +1,14 @@
1
+ # Please see the documentation for all configuration options:
2
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: bundler
7
+ directory: "/"
8
+ schedule: { interval: monthly }
9
+ cooldown: { default-days: 14 }
10
+ - package-ecosystem: github-actions
11
+ directory: "/"
12
+ schedule: { interval: monthly }
13
+ cooldown: { default-days: 14 }
14
+ groups: { github-actions: { patterns: ["*"] } }
@@ -1,14 +1,16 @@
1
1
  name: Test rspec-graphql_response
2
- on:
3
- push:
4
- branches: [ $default-branch ]
5
- pull_request:
2
+ on: [push, pull_request, workflow_dispatch]
6
3
  jobs:
7
4
  test:
8
5
  runs-on: ubuntu-latest
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ ruby: ["3.2", "3.3", "3.4", "4.0"]
9
10
  steps:
10
- - uses: actions/checkout@v2
11
- - uses: ruby/setup-ruby@v1
11
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
12
+ - uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
12
13
  with:
14
+ ruby-version: ${{ matrix.ruby }}
13
15
  bundler-cache: true
14
- - run: bin/rspec
16
+ - run: bin/rspec
data/Gemfile.lock CHANGED
@@ -1,52 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-graphql_response (0.4.1)
4
+ rspec-graphql_response (0.6.0)
5
5
  graphql (>= 1.0)
6
6
  rspec (>= 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- attr_extras (6.2.4)
12
- byebug (11.1.3)
11
+ attr_extras (7.1.0)
12
+ base64 (0.3.0)
13
+ byebug (13.0.0)
14
+ reline (>= 0.6.0)
13
15
  coderay (1.1.3)
14
- diff-lcs (1.4.4)
15
- graphql (1.12.6)
16
- method_source (1.0.0)
17
- optimist (3.0.1)
16
+ diff-lcs (1.6.2)
17
+ fiber-storage (1.0.1)
18
+ graphql (2.6.11)
19
+ base64
20
+ fiber-storage
21
+ logger
22
+ io-console (0.9.4)
23
+ logger (1.7.0)
24
+ method_source (1.1.0)
25
+ optimist (3.2.1)
18
26
  patience_diff (1.2.0)
19
27
  optimist (~> 3.0)
20
- pry (0.14.0)
28
+ pry (0.16.0)
21
29
  coderay (~> 1.1)
22
30
  method_source (~> 1.0)
23
- pry-byebug (3.8.0)
24
- byebug (~> 11.0)
25
- pry (~> 0.10)
26
- rake (13.0.3)
27
- rspec (3.10.0)
28
- rspec-core (~> 3.10.0)
29
- rspec-expectations (~> 3.10.0)
30
- rspec-mocks (~> 3.10.0)
31
- rspec-core (3.10.1)
32
- rspec-support (~> 3.10.0)
33
- rspec-expectations (3.10.1)
31
+ reline (>= 0.6.0)
32
+ pry-byebug (3.12.0)
33
+ byebug (~> 13.0)
34
+ pry (>= 0.13, < 0.17)
35
+ rake (13.4.2)
36
+ reline (0.7.0)
37
+ io-console (~> 0.5)
38
+ rspec (3.13.2)
39
+ rspec-core (~> 3.13.0)
40
+ rspec-expectations (~> 3.13.0)
41
+ rspec-mocks (~> 3.13.0)
42
+ rspec-core (3.13.6)
43
+ rspec-support (~> 3.13.0)
44
+ rspec-expectations (3.13.5)
34
45
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.10.0)
36
- rspec-mocks (3.10.2)
46
+ rspec-support (~> 3.13.0)
47
+ rspec-mocks (3.13.8)
37
48
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.10.0)
39
- rspec-support (3.10.2)
40
- super_diff (0.6.1)
41
- attr_extras (>= 6.2.4)
42
- diff-lcs
43
- patience_diff
49
+ rspec-support (~> 3.13.0)
50
+ rspec-support (3.13.7)
51
+ super_diff (0.19.0)
52
+ attr_extras (>= 6.2.4, < 8)
53
+ diff-lcs (~> 1.5)
54
+ patience_diff (~> 1.2)
44
55
 
45
56
  PLATFORMS
57
+ aarch64-linux
58
+ arm64-darwin
46
59
  ruby
60
+ x86_64-linux
47
61
 
48
62
  DEPENDENCIES
49
- bundler (~> 1.17)
50
63
  pry (~> 0.14)
51
64
  pry-byebug (~> 3.8)
52
65
  rake (>= 12.0)
@@ -54,4 +67,4 @@ DEPENDENCIES
54
67
  super_diff (~> 0.6)
55
68
 
56
69
  BUNDLED WITH
57
- 1.17.2
70
+ 2.5.22
data/README.md CHANGED
@@ -43,7 +43,7 @@ Configuration:
43
43
  Custom Matchers:
44
44
 
45
45
  - [have_errors](/docs/have_errors.md) - validates errors, or lack of, on the GraphQL response
46
- - [have_operation](/docs/have_operation.md) - validates the presence of a specified graphql operation in the graphql response
46
+ - [have_field](/docs/have_field.md) - validates the presence of a specified graphql operation in the graphql response
47
47
 
48
48
  Context / Describe Helper Methods:
49
49
 
@@ -85,7 +85,7 @@ does, and what methods and options are available.
85
85
 
86
86
  ## How We Got Here
87
87
 
88
- Executing a GraphQL call from RSpec is not the most challening code to write:
88
+ Executing a GraphQL call from RSpec is not the most challenging code to write:
89
89
 
90
90
  ```ruby
91
91
  let(:query) do
@@ -162,11 +162,11 @@ RSpec.describe Some::Thing, type: :graphql do
162
162
  end
163
163
  ```
164
164
 
165
- #### Retrieve operation results with `operation`
165
+ #### Retrieve response results with `response_data`
166
166
 
167
167
  Now that the GraphQL query has been executed and a response has been obtained, it's time to check for the results of a GraphQL
168
168
  operation. In the previous example, the spec is expecting to find `data` with `characters` in the response hash. To reduce the
169
- nested hash checking, use the built-in `operation` method to retrieve the `characters`:
169
+ nested hash checking, use the built-in `response_data` method to retrieve the `characters`:
170
170
 
171
171
  ```ruby
172
172
  RSpec.describe Some::Thing, type: :graphql do
@@ -180,18 +180,17 @@ RSpec.describe Some::Thing, type: :graphql do
180
180
  GQL
181
181
 
182
182
  it "executes the query" do
183
- characters = operation(:characters)
184
-
185
- expect(characters).to include(
183
+ expect(response_data :characters).to include(
186
184
  # ...
187
185
  )
188
186
  end
189
187
  end
190
188
  ```
191
189
 
192
- Note the lack of `response` use here. Internally, the `operation` method uses the `response` to obtain the data requested. This
190
+ Note the lack of `response` use here. Internally, the `response_data` method uses the `response` to obtain the data requested. This
193
191
  means the entire chain of operations from executing the GraphQL request, to converting the response into a hash, and digging
194
- through the results to find the correction operation, has been handled behind the scenes.
192
+ through the results to find the correction operation, has been handled behind the scenes. To see more examples of how to use
193
+ `response_data` dig through your response check out it's full documenation [here.](/docs/response_data.md)
195
194
 
196
195
  ## Development
197
196
 
data/RELEASE_NOTES.md CHANGED
@@ -4,6 +4,16 @@ Release notes for various versions of RSpec::GraphQLResponse
4
4
 
5
5
  See [the upgrade guide](/UPGRADE.md) for details on changes between versions and how to upgrade.
6
6
 
7
+ ## v0.6.0 - Ruby 3.2+ required
8
+
9
+ - **Breaking:** Requires Ruby 3.2 or newer.
10
+ - Fixes keyword argument handling for Ruby 3+ (`execute_graphql` and validators) [#12](https://github.com/testdouble/rspec-graphql_response/issues/12).
11
+
12
+ ## v0.5.0 - Helper API change
13
+
14
+ - Fully deprecates `operation`.
15
+ - Renames `have_operation` to `have_field` to clarify its use.
16
+
7
17
  ## v0.4.0 - Helper API change
8
18
 
9
19
  ### Breaking Changes
@@ -23,7 +23,7 @@ RSPec.describe Cool::Stuff, type: :graphql do
23
23
  }
24
24
  end
25
25
 
26
- grapql_context do
26
+ graphql_context do
27
27
  {
28
28
  current_user: user
29
29
  }
data/docs/have_errors.md CHANGED
@@ -18,7 +18,7 @@ Ensure there are no errors in the `response`
18
18
 
19
19
  ```ruby
20
20
  it "should not have errors" do
21
- expect(response).to_not have_errors
21
+ expect(response).not_to have_errors
22
22
  end
23
23
  ```
24
24
 
@@ -37,13 +37,13 @@ Ensure the response does not have a specific number of errors.
37
37
 
38
38
  ```ruby
39
39
  it "should not have 2 errors" do
40
- expect(response).to_not have_errors(2)
40
+ expect(response).not_to have_errors(2)
41
41
  end
42
42
  ```
43
43
 
44
44
  ### CAUTION: False Positives
45
45
 
46
- Using `.to have_errors(count)` and especially using `.to_not have_errors(count)` is
46
+ Using `.to have_errors(count)` and especially using `.not_to have_errors(count)` is
47
47
  potentially dangerous!
48
48
 
49
49
  Your test may be ensuring there are not 2 errors, but the underlying code may fail
@@ -70,13 +70,13 @@ This will ensure the `response["errors"]` contains a "User not found" error mess
70
70
 
71
71
  ```ruby
72
72
  it "does not raise User not found" do
73
- expect(response).to_not have_errors.with_messages("User not found")
73
+ expect(response).not_to have_errors.with_messages("User not found")
74
74
  end
75
75
  ```
76
76
 
77
77
  ### Fails if Specified Error Found in Array
78
78
 
79
- The `.to_not` form of `.with_messages` will ensure that none of the error messages
79
+ The `.not_to` form of `.with_messages` will ensure that none of the error messages
80
80
  specified are found withing the response.
81
81
 
82
82
  If, for example the response looks like this:
@@ -94,7 +94,7 @@ a test like this would fail:
94
94
 
95
95
  ```ruby
96
96
  it "looks for specific errors" do
97
- expect(response).to_not have_errors.with_messages("User not found", "Some other errors")
97
+ expect(response).not_to have_errors.with_messages("User not found", "Some other errors")
98
98
  end
99
99
  ```
100
100
 
@@ -104,7 +104,7 @@ messages would be ignored.
104
104
 
105
105
  ### CAUTION: False Positives
106
106
 
107
- Using `.to_not have_errors.with_messages("Some Message")` is a good way to
107
+ Using `.not_to have_errors.with_messages("Some Message")` is a good way to
108
108
  ensure your code is not throwing a specific error message. However, it should
109
109
  not be the only expectation against the response. If your code raises any errors
110
110
  other than the ones specified, it will result in a passing test but a response
@@ -1,4 +1,4 @@
1
- # Validate a response operation with `have_operation(name)`
1
+ # Validate a response operation with `have_field(name)`
2
2
 
3
3
  Check for the presence of an operation's results. Useful when you want to ensure an operation exists before
4
4
  retrieving the operation's results.
@@ -18,7 +18,7 @@ RSpec.describe My::Characters, type: :graphql do
18
18
 
19
19
  it "has the characters" do
20
20
 
21
- expect(response).to have_operation(:characters)
21
+ expect(response).to have_field(:characters)
22
22
 
23
23
  end
24
24
  end
@@ -39,7 +39,7 @@ RSpec.describe My::Characters, type: :graphql do
39
39
 
40
40
  it "does not have books" do
41
41
 
42
- expect(response).to_not have_operation(:books)
42
+ expect(response).to_not have_field(:books)
43
43
 
44
44
  end
45
45
  end
@@ -10,8 +10,9 @@ RSpec::GraphQLResponse.add_helper :execute_graphql do
10
10
  operation_context = graphql_context if respond_to? :graphql_context
11
11
  operation_context = self.instance_eval(&operation_context) if operation_context.is_a? Proc
12
12
 
13
- config.graphql_schema.execute(operation, {
13
+ config.graphql_schema.execute(
14
+ operation,
14
15
  variables: operation_vars,
15
16
  context: operation_context
16
- })
17
+ )
17
18
  end
@@ -46,6 +46,5 @@ require_relative "helpers/graphql_variables"
46
46
 
47
47
  # spec level helpers
48
48
  require_relative "helpers/execute_graphql"
49
- require_relative "helpers/operation"
50
49
  require_relative "helpers/response"
51
50
  require_relative "helpers/response_data"
@@ -1,6 +1,6 @@
1
- RSpec::GraphQLResponse.add_matcher :have_operation do |operation_name|
1
+ RSpec::GraphQLResponse.add_matcher :have_field do |operation_name|
2
2
  match do |response|
3
- validator = RSpec::GraphQLResponse.validator(:have_operation)
3
+ validator = RSpec::GraphQLResponse.validator(:have_field)
4
4
 
5
5
  @result = validator.validate(response, operation_name: operation_name)
6
6
  @result.valid?
@@ -11,7 +11,7 @@ RSpec::GraphQLResponse.add_matcher :have_operation do |operation_name|
11
11
  end
12
12
 
13
13
  match_when_negated do |response|
14
- validator = RSpec::GraphQLResponse.validator(:have_operation)
14
+ validator = RSpec::GraphQLResponse.validator(:have_field)
15
15
 
16
16
  @result = validator.validate_negated(response, operation_name: operation_name)
17
17
  @result.valid?
@@ -12,4 +12,4 @@ module RSpec
12
12
  end
13
13
 
14
14
  require_relative "matchers/have_errors"
15
- require_relative "matchers/have_operation"
15
+ require_relative "matchers/have_field"
@@ -1,4 +1,4 @@
1
- RSpec::GraphQLResponse.add_validator :have_operation do
1
+ RSpec::GraphQLResponse.add_validator :have_field do
2
2
  failure_message :nil, "Cannot evaluate operations on nil"
3
3
  failure_message :not_found, ->(expected, actual) { "Expected to find operation result named #{expected}, but did not find it\n\t#{actual}" }
4
4
 
@@ -17,18 +17,18 @@ module RSpec
17
17
  end
18
18
  end
19
19
 
20
- def validate(response, *args)
20
+ def validate(response, *args, **kwargs)
21
21
  validate_method = self.class.instance_variable_get(:@validate_method)
22
22
 
23
23
  runner = ValidationRunner.new(self)
24
- runner.instance_exec(response, *args, &validate_method)
24
+ runner.instance_exec(response, *args, **kwargs, &validate_method)
25
25
  end
26
26
 
27
- def validate_negated(response, *args)
27
+ def validate_negated(response, *args, **kwargs)
28
28
  validate_negated_method = self.class.instance_variable_get(:@validate_negated_method)
29
29
 
30
30
  runner = ValidationRunner.new(self)
31
- runner.instance_exec(response, *args, &validate_negated_method)
31
+ runner.instance_exec(response, *args, **kwargs, &validate_negated_method)
32
32
  end
33
33
 
34
34
  def failure_message(type)
@@ -23,4 +23,4 @@ module RSpec
23
23
  end
24
24
 
25
25
  require_relative "validators/have_errors"
26
- require_relative "validators/have_operation"
26
+ require_relative "validators/have_field"
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module GraphQLResponse
3
- VERSION = "0.4.1"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -23,9 +23,10 @@ Gem::Specification.new do |spec|
23
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  end
25
25
 
26
+ spec.required_ruby_version = ">= 3.2"
27
+
26
28
  spec.require_paths = ["lib"]
27
29
 
28
- spec.add_development_dependency "bundler", "~> 1.17"
29
30
  spec.add_development_dependency "rake", ">= 12.0"
30
31
  spec.add_development_dependency "pry", "~> 0.14"
31
32
  spec.add_development_dependency "pry-byebug", "~> 3.8"
metadata CHANGED
@@ -1,29 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-graphql_response
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - River Lynn Bailey
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-03-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.17'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.17'
27
12
  - !ruby/object:Gem::Dependency
28
13
  name: rake
29
14
  requirement: !ruby/object:Gem::Requirement
@@ -116,12 +101,12 @@ executables: []
116
101
  extensions: []
117
102
  extra_rdoc_files: []
118
103
  files:
104
+ - ".github/dependabot.yml"
119
105
  - ".github/workflows/test.yml"
120
106
  - ".gitignore"
121
107
  - ".gituprc"
122
108
  - ".pryrc"
123
109
  - ".rspec"
124
- - ".ruby-version"
125
110
  - CODE_OF_CONDUCT.md
126
111
  - Gemfile
127
112
  - Gemfile.lock
@@ -140,7 +125,7 @@ files:
140
125
  - docs/execute_graphql.md
141
126
  - docs/graphql_spec_type.md
142
127
  - docs/have_errors.md
143
- - docs/have_operation.md
128
+ - docs/have_field.md
144
129
  - docs/operation.md
145
130
  - docs/response.md
146
131
  - docs/response_data.md
@@ -152,15 +137,14 @@ files:
152
137
  - lib/rspec/graphql_response/helpers/graphql_context.rb
153
138
  - lib/rspec/graphql_response/helpers/graphql_operation.rb
154
139
  - lib/rspec/graphql_response/helpers/graphql_variables.rb
155
- - lib/rspec/graphql_response/helpers/operation.rb
156
140
  - lib/rspec/graphql_response/helpers/response.rb
157
141
  - lib/rspec/graphql_response/helpers/response_data.rb
158
142
  - lib/rspec/graphql_response/matchers.rb
159
143
  - lib/rspec/graphql_response/matchers/have_errors.rb
160
- - lib/rspec/graphql_response/matchers/have_operation.rb
144
+ - lib/rspec/graphql_response/matchers/have_field.rb
161
145
  - lib/rspec/graphql_response/validators.rb
162
146
  - lib/rspec/graphql_response/validators/have_errors.rb
163
- - lib/rspec/graphql_response/validators/have_operation.rb
147
+ - lib/rspec/graphql_response/validators/have_field.rb
164
148
  - lib/rspec/graphql_response/validators/validation_base.rb
165
149
  - lib/rspec/graphql_response/validators/validation_result.rb
166
150
  - lib/rspec/graphql_response/validators/validation_runner.rb
@@ -170,7 +154,6 @@ homepage: https://github.com/testdouble/rspec-graphql_response
170
154
  licenses:
171
155
  - MIT
172
156
  metadata: {}
173
- post_install_message:
174
157
  rdoc_options: []
175
158
  require_paths:
176
159
  - lib
@@ -178,15 +161,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
161
  requirements:
179
162
  - - ">="
180
163
  - !ruby/object:Gem::Version
181
- version: '0'
164
+ version: '3.2'
182
165
  required_rubygems_version: !ruby/object:Gem::Requirement
183
166
  requirements:
184
167
  - - ">="
185
168
  - !ruby/object:Gem::Version
186
169
  version: '0'
187
170
  requirements: []
188
- rubygems_version: 3.0.3
189
- signing_key:
171
+ rubygems_version: 4.0.21
190
172
  specification_version: 4
191
173
  summary: Verify ruby-graphql responses with a :graphql spec type
192
174
  test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.6.6
@@ -1,6 +0,0 @@
1
- RSpec::GraphQLResponse.add_helper :operation do |name|
2
- warn 'WARNING: operation has been deprecated in favor of response_data. This helper will be removed in v0.5'
3
- return nil unless response.is_a? Hash
4
-
5
- response.dig("data", name.to_s)
6
- end