rspec-graphql_response 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -8
- data/RELEASE_NOTES.md +5 -0
- data/docs/{have_operation.md → have_field.md} +3 -3
- data/lib/rspec/graphql_response/helpers.rb +0 -1
- data/lib/rspec/graphql_response/matchers.rb +1 -1
- data/lib/rspec/graphql_response/matchers/{have_operation.rb → have_field.rb} +3 -3
- data/lib/rspec/graphql_response/validators.rb +1 -1
- data/lib/rspec/graphql_response/validators/{have_operation.rb → have_field.rb} +1 -1
- data/lib/rspec/graphql_response/version.rb +1 -1
- metadata +5 -6
- data/lib/rspec/graphql_response/helpers/operation.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7104f657d559b5617486876024bc92367f177b94734ac8f224452cf6e4917f3e
|
4
|
+
data.tar.gz: f9c0df4206c1dd6c02f7b744b5edaa91c877a2e0be5c1ee235d6a05e0c3df9f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ef7903cb4b46d5588b03402a5c3e44d6c61e13b898f8269f44ec3acd3b976cd3c77f921b68fc050dab0a20700f5846007c79cacfef8acfe1516f6af1a2045d
|
7
|
+
data.tar.gz: e9bbad747532e9fca29ed6e0bf8b4299be8896344f9541527bff4f71242ecfe4117f02d9946d0aece0215ec1952ce391bb5bfe74eccce747c167da52fe06acb2
|
data/Gemfile.lock
CHANGED
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
|
-
- [
|
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
|
|
@@ -162,11 +162,11 @@ RSpec.describe Some::Thing, type: :graphql do
|
|
162
162
|
end
|
163
163
|
```
|
164
164
|
|
165
|
-
#### Retrieve
|
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 `
|
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
|
-
|
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 `
|
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,11 @@ 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.5.0 - Helper API change
|
8
|
+
|
9
|
+
- Fully deprecates `operation`.
|
10
|
+
- Renames `have_operation` to `have_field` to clarify its use.
|
11
|
+
|
7
12
|
## v0.4.0 - Helper API change
|
8
13
|
|
9
14
|
### Breaking Changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Validate a response operation with `
|
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
|
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
|
42
|
+
expect(response).to_not have_field(:books)
|
43
43
|
|
44
44
|
end
|
45
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
RSpec::GraphQLResponse.add_matcher :
|
1
|
+
RSpec::GraphQLResponse.add_matcher :have_field do |operation_name|
|
2
2
|
match do |response|
|
3
|
-
validator = RSpec::GraphQLResponse.validator(:
|
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(:
|
14
|
+
validator = RSpec::GraphQLResponse.validator(:have_field)
|
15
15
|
|
16
16
|
@result = validator.validate_negated(response, operation_name: operation_name)
|
17
17
|
@result.valid?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
RSpec::GraphQLResponse.add_validator :
|
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
|
|
metadata
CHANGED
@@ -1,14 +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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- River Lynn Bailey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -140,7 +140,7 @@ files:
|
|
140
140
|
- docs/execute_graphql.md
|
141
141
|
- docs/graphql_spec_type.md
|
142
142
|
- docs/have_errors.md
|
143
|
-
- docs/
|
143
|
+
- docs/have_field.md
|
144
144
|
- docs/operation.md
|
145
145
|
- docs/response.md
|
146
146
|
- docs/response_data.md
|
@@ -152,15 +152,14 @@ files:
|
|
152
152
|
- lib/rspec/graphql_response/helpers/graphql_context.rb
|
153
153
|
- lib/rspec/graphql_response/helpers/graphql_operation.rb
|
154
154
|
- lib/rspec/graphql_response/helpers/graphql_variables.rb
|
155
|
-
- lib/rspec/graphql_response/helpers/operation.rb
|
156
155
|
- lib/rspec/graphql_response/helpers/response.rb
|
157
156
|
- lib/rspec/graphql_response/helpers/response_data.rb
|
158
157
|
- lib/rspec/graphql_response/matchers.rb
|
159
158
|
- lib/rspec/graphql_response/matchers/have_errors.rb
|
160
|
-
- lib/rspec/graphql_response/matchers/
|
159
|
+
- lib/rspec/graphql_response/matchers/have_field.rb
|
161
160
|
- lib/rspec/graphql_response/validators.rb
|
162
161
|
- lib/rspec/graphql_response/validators/have_errors.rb
|
163
|
-
- lib/rspec/graphql_response/validators/
|
162
|
+
- lib/rspec/graphql_response/validators/have_field.rb
|
164
163
|
- lib/rspec/graphql_response/validators/validation_base.rb
|
165
164
|
- lib/rspec/graphql_response/validators/validation_result.rb
|
166
165
|
- lib/rspec/graphql_response/validators/validation_runner.rb
|