rspec-graphql_response 0.3.0 → 0.4.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +27 -22
- data/RELEASE_NOTES.md +18 -12
- data/UPGRADE.md +5 -1
- data/docs/add_helper.md +4 -5
- data/docs/execute_graphql.md +3 -3
- data/docs/have_operation.md +2 -2
- data/lib/rspec/graphql_response/helpers.rb +1 -1
- data/lib/rspec/graphql_response/helpers/execute_graphql.rb +9 -9
- data/lib/rspec/graphql_response/helpers/graphql_operation.rb +3 -0
- data/lib/rspec/graphql_response/version.rb +1 -1
- metadata +3 -3
- data/lib/rspec/graphql_response/helpers/graphql_query.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c5814d390ff22a3d15ddc35b4679614cc1f18211daf647121e6ca6b04156e4
|
4
|
+
data.tar.gz: 1a9c6ea2c3cc642ed2df3b2efd4108906934fdb696a48e5e37eed4b4b7567245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cc7e794a155fbeb8c1c485b46aa4c625e242f307234a51dde9323532041c9e8edac065300a5ac650105c605c8d65283b0cea967147b5b842b152fb90612eac7
|
7
|
+
data.tar.gz: b2f520c30cd95c28169323821045f796d806647e076518e8c406f6f8257b2cf635ce0623fd1ef75c1d3336ae45028d9f82977b7598de750183c757390d3d49cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-graphql_response (0.
|
4
|
+
rspec-graphql_response (0.4.0)
|
5
5
|
graphql (>= 1.0)
|
6
6
|
rspec (>= 3.0)
|
7
7
|
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
byebug (11.1.3)
|
12
12
|
coderay (1.1.3)
|
13
13
|
diff-lcs (1.4.4)
|
14
|
-
graphql (1.12.
|
14
|
+
graphql (1.12.5)
|
15
15
|
method_source (1.0.0)
|
16
16
|
pry (0.14.0)
|
17
17
|
coderay (~> 1.1)
|
data/README.md
CHANGED
@@ -30,40 +30,45 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
## Full Documentation
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
- [Release Notes](/RELEASE_NOTES.md)
|
34
|
+
- [Upgrade Guide](/UPGRADE.md)
|
35
35
|
|
36
36
|
The full documentation for RSpec::GraphQLResponse can be found in the `/docs` folder.
|
37
37
|
|
38
38
|
Configuration:
|
39
|
-
|
40
|
-
|
39
|
+
|
40
|
+
- [RSpec::GraphQLResponse.configure](/docs/configuration.md)
|
41
|
+
- [Spec Type :graphql](/docs/graphql_spec_type.md)
|
41
42
|
|
42
43
|
Custom Matchers:
|
43
|
-
|
44
|
-
|
44
|
+
|
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
|
45
47
|
|
46
48
|
Context / Describe Helper Methods:
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
|
50
|
+
- [graphql_operation](/docs/execute_graphql.md) - the operation to execute (i.e query or mutation)
|
51
|
+
- [graphql_variables](/docs/execute_graphql.md) - a hash of variables the query expects
|
52
|
+
- [graphql_context](/docs/execute_graphql.md) - the `context` of a query or mutation's resolver
|
50
53
|
|
51
54
|
Spec Helper Methods:
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
|
56
|
+
- [execute_graphql](/docs/execute_graphql.md) - executes a graphql call with the registered schema, query, variables and context
|
57
|
+
- [response](/docs/response.md) - the response, as JSON, of the executed graphql query
|
58
|
+
- [operation](/docs/operation.md) - retrieves the results of a named operation from the GraphQL response
|
55
59
|
|
56
60
|
API / Development
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
|
62
|
+
- [.add_matcher](/docs/add_matcher.md) - add a custom RSpec matcher to the GraphQLResponse matchers
|
63
|
+
- [.add_validator](/docs/add_validator.md) - add a custom validator to be used by the custom matchers
|
64
|
+
- [.add_helper](/docs/add_helper.md) - add helper methods to your specs, made avialable in `it` or `describe` / `context` blocks
|
60
65
|
|
61
66
|
## Getting Started
|
62
67
|
|
63
|
-
There are only a couple of bits you need to get started:
|
68
|
+
There are only a couple of bits you need to get started:
|
64
69
|
|
65
|
-
|
66
|
-
|
70
|
+
- configuration of a GraphQL Schema in [`RSpec::GraphQLResponse.configure`](/docs/configuration.md)
|
71
|
+
- the inclusion of [`type: :graphql`](/docs/graphql_spec_type.md) in your `RSpec.describe` call
|
67
72
|
|
68
73
|
```ruby
|
69
74
|
RSpec::GraphQLResponse.configure do |config|
|
@@ -114,7 +119,7 @@ in your specs.
|
|
114
119
|
|
115
120
|
```ruby
|
116
121
|
RSpec.describe Some::Thing, type: :graphql do
|
117
|
-
|
122
|
+
graphql_operation <<-GQL
|
118
123
|
query ListCharacters{
|
119
124
|
characters {
|
120
125
|
id
|
@@ -138,7 +143,7 @@ way. The reduce this, `RSpec::GraphQLResponse` provides a built-in `response` he
|
|
138
143
|
|
139
144
|
```ruby
|
140
145
|
RSpec.describe Some::Thing, type: :graphql do
|
141
|
-
|
146
|
+
graphql_operation <<-GQL
|
142
147
|
query ListCharacters{
|
143
148
|
characters {
|
144
149
|
id
|
@@ -165,7 +170,7 @@ nested hash checking, use the built-in `operation` method to retrieve the `chara
|
|
165
170
|
|
166
171
|
```ruby
|
167
172
|
RSpec.describe Some::Thing, type: :graphql do
|
168
|
-
|
173
|
+
graphql_operation <<-GQL
|
169
174
|
query ListCharacters{
|
170
175
|
characters {
|
171
176
|
id
|
@@ -178,7 +183,7 @@ RSpec.describe Some::Thing, type: :graphql do
|
|
178
183
|
characters = operation(:characters)
|
179
184
|
|
180
185
|
expect(characters).to include(
|
181
|
-
# ...
|
186
|
+
# ...
|
182
187
|
)
|
183
188
|
end
|
184
189
|
end
|
data/RELEASE_NOTES.md
CHANGED
@@ -4,6 +4,12 @@ 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.4.0 - Helper API change
|
8
|
+
|
9
|
+
### Breaking Changes
|
10
|
+
|
11
|
+
The helper `graphql_query` was renamed to `graphql_operation` to better communicate the use of the helper. Naming the helper with `_query` lead to an association that its use was meant for GraphQL query operations and could not also be used for a mutation.
|
12
|
+
|
7
13
|
## v0.2.0 - GraphQL Configuration DSL and Refactorings
|
8
14
|
|
9
15
|
Misc changes and corrections, some new features, and generally trying to create a more robust
|
@@ -11,13 +17,13 @@ and usable experience, right out of the box.
|
|
11
17
|
|
12
18
|
### New Features
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
- Significantly improved documentation
|
21
|
+
- `have_operation` matcher
|
22
|
+
- GraphQL configuration DSL
|
23
|
+
- `graphql_query`
|
24
|
+
- `graphql_variables`
|
25
|
+
- `graphql_context`
|
26
|
+
- Describe/Context level RSpec helper methods via `.add_context_helper` DSL
|
21
27
|
|
22
28
|
### Breaking Changes
|
23
29
|
|
@@ -32,8 +38,8 @@ Lots of misc bug fixes, including caching of values, ensuring things work in nes
|
|
32
38
|
|
33
39
|
Early beta work to get this out the door and begin adoption
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
- `have_errors` matcher
|
42
|
+
- `operation` helper
|
43
|
+
- `response` helper
|
44
|
+
- `execute_graphql` helper
|
45
|
+
- DSL for adding custom matchers, validators, and helpers
|
data/UPGRADE.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Upgrade Guide
|
2
2
|
|
3
|
+
## v0.3.0 to v0.4.0
|
4
|
+
|
5
|
+
There is a breaking change between v0.3.0 and v0.4.0 where the helper `graphql_query` was renamed to `graphql_operation`. In order to migrate to v0.4.0 all references to `graphql_query` can be replaced with `graphql_operation`.
|
6
|
+
|
3
7
|
## v0.1.0 to v0.2.0
|
4
8
|
|
5
|
-
There is a breaking change between v0.1.0 and v0.2.0 regarding the configuration of graphql queries, variables and context.
|
9
|
+
There is a breaking change between v0.1.0 and v0.2.0 regarding the configuration of graphql queries, variables and context.
|
6
10
|
Previously, you defined these three items with `let` in rspec:
|
7
11
|
|
8
12
|
```ruby
|
data/docs/add_helper.md
CHANGED
@@ -23,7 +23,7 @@ it "does stuff" do
|
|
23
23
|
end
|
24
24
|
```
|
25
25
|
|
26
|
-
It's not a huge difference, but when you consider how well the `operation` method handles `nil` and
|
26
|
+
It's not a huge difference, but when you consider how well the `operation` method handles `nil` and
|
27
27
|
operation results that are not found, it's well worth the few lines of savings.
|
28
28
|
|
29
29
|
There are many other helpers available for your test suites, as well. Be sure to check the full
|
@@ -51,15 +51,14 @@ RSpec::GraphQLResponse.add_helper :operation do |operation_name|
|
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
54
|
-
In this example, the `response` helper is used, which guarantees the graphql has been executed and a response
|
54
|
+
In this example, the `response` helper is used, which guarantees the graphql has been executed and a response
|
55
55
|
is available, assuming there were no exceptions preventing that.
|
56
56
|
|
57
57
|
## Add a Context Helper
|
58
58
|
|
59
59
|
In addition to Spec level helpers, RSpec::GraphQLResponse allows you to add custom helpers at the context
|
60
60
|
level. This means you can add configuration and other bits that can be called outside of an `it` block.
|
61
|
-
The existing `
|
62
|
-
context level helpers.
|
61
|
+
The existing `graphql_operation` and other DSL methods for configuring graphql calls are a great example of context level helpers.
|
63
62
|
|
64
63
|
To create a context helper, call `RSpec::GraphQLResponse.add_context_helper(name, &helper_block)`. The params
|
65
64
|
are the same as `.add_helper`, but the resulting method will be made available in `describe` and `context`
|
@@ -73,7 +72,7 @@ end
|
|
73
72
|
|
74
73
|
In this simple example, a method called `my_setting` is created, and it stores a value in the instance variable
|
75
74
|
`@my_setting`. This takes advantage of RSpec's native ability to handle instance variables in describe and
|
76
|
-
context blocks, allowing the variable to exist withing the hierarchy of objects for a given spec.
|
75
|
+
context blocks, allowing the variable to exist withing the hierarchy of objects for a given spec.
|
77
76
|
|
78
77
|
With that defined, it can be used within a spec:
|
79
78
|
|
data/docs/execute_graphql.md
CHANGED
@@ -8,7 +8,7 @@ RSPec.describe Cool::Stuff, type: :graphql do
|
|
8
8
|
let(:user) { create(:graphql_user) }
|
9
9
|
let(:search_name) { "Pet" }
|
10
10
|
|
11
|
-
|
11
|
+
graphql_operation <<-GQL
|
12
12
|
query SomeThing($name: String) {
|
13
13
|
characters(name: $name) {
|
14
14
|
id
|
@@ -16,7 +16,7 @@ RSPec.describe Cool::Stuff, type: :graphql do
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
GQL
|
19
|
-
|
19
|
+
|
20
20
|
graphql_variables do
|
21
21
|
{
|
22
22
|
name: search_name
|
@@ -37,7 +37,7 @@ end
|
|
37
37
|
|
38
38
|
## Available Configuration Methods
|
39
39
|
|
40
|
-
### `
|
40
|
+
### `graphql_operation`
|
41
41
|
|
42
42
|
A string - most commonly a ruby heredoc - for the graphql query to execute
|
43
43
|
|
data/docs/have_operation.md
CHANGED
@@ -7,7 +7,7 @@ retrieving the operation's results.
|
|
7
7
|
|
8
8
|
```ruby
|
9
9
|
RSpec.describe My::Characters, type: :graphql do
|
10
|
-
|
10
|
+
graphql_operation <<-GQL
|
11
11
|
query CharacterList {
|
12
12
|
characters {
|
13
13
|
id
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
RSpec.describe My::Characters, type: :graphql do
|
31
|
-
|
31
|
+
graphql_operation <<-GQL
|
32
32
|
query CharacterList {
|
33
33
|
characters {
|
34
34
|
id
|
@@ -1,17 +1,17 @@
|
|
1
1
|
RSpec::GraphQLResponse.add_helper :execute_graphql do
|
2
2
|
config = RSpec::GraphQLResponse.configuration
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
operation = graphql_operation if respond_to? :graphql_operation
|
5
|
+
operation = self.instance_eval(&graphql_operation) if operation.is_a? Proc
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
operation_vars = graphql_variables if respond_to? :graphql_variables
|
8
|
+
operation_vars = self.instance_eval(&graphql_variables) if operation_vars.is_a? Proc
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
operation_context = graphql_context if respond_to? :graphql_context
|
11
|
+
operation_context = self.instance_eval(&operation_context) if operation_context.is_a? Proc
|
12
12
|
|
13
|
-
config.graphql_schema.execute(
|
14
|
-
variables:
|
15
|
-
context:
|
13
|
+
config.graphql_schema.execute(operation, {
|
14
|
+
variables: operation_vars,
|
15
|
+
context: operation_context
|
16
16
|
})
|
17
17
|
end
|
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.4.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-03-
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ files:
|
|
134
134
|
- lib/rspec/graphql_response/helpers.rb
|
135
135
|
- lib/rspec/graphql_response/helpers/execute_graphql.rb
|
136
136
|
- lib/rspec/graphql_response/helpers/graphql_context.rb
|
137
|
-
- lib/rspec/graphql_response/helpers/
|
137
|
+
- lib/rspec/graphql_response/helpers/graphql_operation.rb
|
138
138
|
- lib/rspec/graphql_response/helpers/graphql_variables.rb
|
139
139
|
- lib/rspec/graphql_response/helpers/operation.rb
|
140
140
|
- lib/rspec/graphql_response/helpers/response.rb
|