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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 647c52ffa5ae347bc9c2166bd94af15ee82556d10f37fa5a11a0cf0229d40b31
4
- data.tar.gz: a93873e4d4a40a9a4702026321d96d913056188dd51eec86836232add5e7c4b7
3
+ metadata.gz: 7104f657d559b5617486876024bc92367f177b94734ac8f224452cf6e4917f3e
4
+ data.tar.gz: f9c0df4206c1dd6c02f7b744b5edaa91c877a2e0be5c1ee235d6a05e0c3df9f0
5
5
  SHA512:
6
- metadata.gz: 9ad72db1bdd814a65f02cf4ee9a59c9836c452003fe840e9c28903aa805ab0553fcd7afa4558d610c63c5ae1959fea61690f037641bd3fa31b417c378ed1805a
7
- data.tar.gz: 46ec7e724d5784feb01e33fbb5024d9c8713ddb8df77a1efb2273f1dd94c2bf8c3658ecb1f11ad9065741119b6e4a71815f9911ba3e87a779caafe97563b2dd8
6
+ metadata.gz: 71ef7903cb4b46d5588b03402a5c3e44d6c61e13b898f8269f44ec3acd3b976cd3c77f921b68fc050dab0a20700f5846007c79cacfef8acfe1516f6af1a2045d
7
+ data.tar.gz: e9bbad747532e9fca29ed6e0bf8b4299be8896344f9541527bff4f71242ecfe4117f02d9946d0aece0215ec1952ce391bb5bfe74eccce747c167da52fe06acb2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-graphql_response (0.4.1)
4
+ rspec-graphql_response (0.5.0)
5
5
  graphql (>= 1.0)
6
6
  rspec (>= 3.0)
7
7
 
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
 
@@ -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,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 `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
@@ -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"
@@ -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,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?
@@ -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,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
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module GraphQLResponse
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  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.1
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-03-16 00:00:00.000000000 Z
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/have_operation.md
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/have_operation.rb
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/have_operation.rb
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
@@ -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