rspec-graphql_matchers 1.3.1 → 1.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/.github/workflows/rspec.yml +3 -3
- data/CHANGELOG.md +11 -0
- data/Gemfile +0 -8
- data/README.md +7 -32
- data/lib/rspec/graphql_matchers/accept_argument.rb +6 -2
- data/lib/rspec/graphql_matchers/base_matcher.rb +1 -1
- data/lib/rspec/graphql_matchers/be_of_type.rb +2 -2
- data/lib/rspec/graphql_matchers/have_a_field.rb +7 -3
- data/lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb +5 -1
- data/lib/rspec/graphql_matchers/version.rb +1 -1
- data/rspec-graphql_matchers.gemspec +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dae51bcd93df2cadbbc1f056f27246ffe9fc54fb046cd542bc0461e4caadac8
|
4
|
+
data.tar.gz: dfa65482790aa2ca2ad4d7318679e0b80f13b9ba34c27ca7f7f525e699d7ea4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 280d14d08215126ef991443f1d786c5d15b2c5c82a34378f17d3c3cd1bd8ab0ab21efd9d1ff9870115c2aeca6d6b4d72dc80aecc760dbd52b6862807440e1f5b
|
7
|
+
data.tar.gz: 571b16fe5f151501313b6a7e94ba32b4f431fa352f2cf11f0ae06af44f1a5e8143a68dc4961cdbcef359c081696391977483e1b65972bb574e2d3ab0029cfa26
|
data/.github/workflows/rspec.yml
CHANGED
@@ -2,7 +2,7 @@ name: RSpec
|
|
2
2
|
|
3
3
|
# Controls when the action will run. Triggers the workflow on push or pull request
|
4
4
|
# events but only for the master branch
|
5
|
-
on: [
|
5
|
+
on: [push, pull_request]
|
6
6
|
|
7
7
|
jobs:
|
8
8
|
# This workflow contains a single job "rspec"
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
ruby_version: [
|
15
|
+
ruby_version: [2.6, 2.7, 3.0, 3.1, 3.2]
|
16
16
|
|
17
17
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
18
18
|
steps:
|
@@ -36,6 +36,6 @@ jobs:
|
|
36
36
|
key: ${{ runner.os }}-${{ matrix.ruby_version }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
37
37
|
restore-keys: |
|
38
38
|
${{ runner.os }}-${{ matrix.ruby_version }}-gems-
|
39
|
-
|
39
|
+
|
40
40
|
- name: Run RSpec
|
41
41
|
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.4.0 (April 16th, 2023)
|
4
|
+
|
5
|
+
- Removal of deprecated calls to #to_graphql, replacing them with #to_type_signature that was added in graphql-ruby 1.8.3 (https://github.com/khamusa/rspec-graphql_matchers/pull/43 @RobinDaugherty)
|
6
|
+
- Dropped support for legacy .define API
|
7
|
+
- Dropped support to old relay interfaces
|
8
|
+
- Fixed with_hash_key matcher for newer versions of graphql-ruby
|
9
|
+
- Fixed errors that occured in some edge cases when generating descriptions for accept_argument and have_a_field matchers
|
10
|
+
- Documentations improvement and general cleanup
|
11
|
+
- Dropped support to graphql-ruby versions before 1.10.12.
|
12
|
+
|
3
13
|
## 1.3.1 (Aug 2nd, 2021)
|
14
|
+
|
4
15
|
- Corrected gem dependencies so it properly requires RSpec when loaded (thanks to @itay-grudev)
|
5
16
|
|
6
17
|
## 1.3.0 (May 7th, 2020)
|
data/Gemfile
CHANGED
@@ -4,11 +4,3 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in rspec-graphql_matchers.gemspec
|
6
6
|
gemspec
|
7
|
-
|
8
|
-
# rubocop:disable Bundle/DuplicatedGem
|
9
|
-
if ENV['GRAPHQL_GEM_VERSION'] == '1.8'
|
10
|
-
gem 'graphql', '~> 1.8.0'
|
11
|
-
elsif ENV['GRAPHQL_GEM_VERSION'] == '1.9'
|
12
|
-
gem 'graphql', '~> 1.9.0'
|
13
|
-
end
|
14
|
-
# rubocop:enable Bundle/DuplicatedGem
|
data/README.md
CHANGED
@@ -25,12 +25,7 @@ Where a valid type for the expectation is either:
|
|
25
25
|
|
26
26
|
- A reference to the actual type you expect;
|
27
27
|
- [Recommended] A String representation of a type: `"String!"`, `"Int!"`, `"[String]!"`
|
28
|
-
(note the exclamation mark at the end, as required by the [GraphQL
|
29
|
-
|
30
|
-
For objects defined with the legacy `#define` api, testing `:property`, `:hash_key` and _metadata_ is also possible by chaining `.with_property`, `.with_hash_key` and `.with_metadata`. For example:
|
31
|
-
|
32
|
-
- `expect(a_graphql_object).to have_a_field(field_name).with_property(property_name).with_metadata(metadata_hash)`
|
33
|
-
- `expect(a_graphql_object).to have_a_field(field_name).with_hash_key(hash_key)`
|
28
|
+
(note the exclamation mark at the end, as required by the [GraphQL specifications](http://graphql.org/).
|
34
29
|
|
35
30
|
## Examples
|
36
31
|
|
@@ -41,7 +36,7 @@ class PostType < GraphQL::Schema::Object
|
|
41
36
|
graphql_name "Post"
|
42
37
|
description "A blog post"
|
43
38
|
|
44
|
-
implements GraphQL::Relay::Node
|
39
|
+
implements GraphQL::Types::Relay::Node
|
45
40
|
|
46
41
|
field :id, ID, null: false
|
47
42
|
field :comments, [String], null: false
|
@@ -97,27 +92,7 @@ describe PostType do
|
|
97
92
|
end
|
98
93
|
```
|
99
94
|
|
100
|
-
### 3)
|
101
|
-
|
102
|
-
```ruby
|
103
|
-
PostTypeWithDefineApi = GraphQL::ObjectType.define do
|
104
|
-
name "DefinedPost"
|
105
|
-
|
106
|
-
interfaces [GraphQL::Relay::Node.interface]
|
107
|
-
|
108
|
-
field :id, !types.ID, property: :post_id
|
109
|
-
field :comments, !types[types.String], hash_key: :post_comments
|
110
|
-
field :isPublished, admin_only: true
|
111
|
-
end
|
112
|
-
|
113
|
-
describe PostTypeWithDefineApi do
|
114
|
-
it { is_expected.to have_a_field(:id).of_type('ID!').with_property(:post_id) }
|
115
|
-
it { is_expected.to have_a_field(:comments).with_hash_key(:post_comments) }
|
116
|
-
it { is_expected.to have_a_field(:isPublished).with_metadata(admin_only: true) }
|
117
|
-
end
|
118
|
-
```
|
119
|
-
|
120
|
-
### 4) Test the arguments accepted by a field with `accept_argument` matcher:
|
95
|
+
### 3) Test the arguments accepted by a field with `accept_argument` matcher:
|
121
96
|
|
122
97
|
```ruby
|
123
98
|
describe PostType do
|
@@ -138,7 +113,7 @@ describe PostType do
|
|
138
113
|
end
|
139
114
|
```
|
140
115
|
|
141
|
-
###
|
116
|
+
### 4) Test an object's interface implementations:
|
142
117
|
|
143
118
|
```ruby
|
144
119
|
describe PostType do
|
@@ -149,12 +124,12 @@ describe PostType do
|
|
149
124
|
end
|
150
125
|
|
151
126
|
# Accepts arguments as an array and type objects directly
|
152
|
-
it { is_expected.to implement(GraphQL::Relay::Node
|
127
|
+
it { is_expected.to implement(GraphQL::Types::Relay::Node) }
|
153
128
|
it { is_expected.not_to implement('OtherInterface') }
|
154
129
|
end
|
155
130
|
```
|
156
131
|
|
157
|
-
###
|
132
|
+
### 5) Using camelize: false on field names
|
158
133
|
|
159
134
|
By default the graphql gem camelizes field names. This gem deals with it transparently:
|
160
135
|
|
@@ -162,7 +137,7 @@ By default the graphql gem camelizes field names. This gem deals with it transpa
|
|
162
137
|
class ObjectMessingWithCamelsAndSnakesType < GraphQL::Schema::Object
|
163
138
|
graphql_name 'ObjectMessingWithCamelsAndSnakes'
|
164
139
|
|
165
|
-
implements GraphQL::Relay::Node
|
140
|
+
implements GraphQL::Types::Relay::Node
|
166
141
|
|
167
142
|
field :me_gusta_los_camellos, ID, null: false
|
168
143
|
|
@@ -59,11 +59,11 @@ module RSpec
|
|
59
59
|
private
|
60
60
|
|
61
61
|
def descriptions
|
62
|
-
|
62
|
+
results.map(&:description)
|
63
63
|
end
|
64
64
|
|
65
65
|
def failure_messages
|
66
|
-
|
66
|
+
results.map(&:failure_message)
|
67
67
|
end
|
68
68
|
|
69
69
|
def field_arguments
|
@@ -74,6 +74,10 @@ module RSpec
|
|
74
74
|
'matcher. It does not seem to be a valid GraphQL object type.'
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
def results
|
79
|
+
@results ||= []
|
80
|
+
end
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
@@ -28,9 +28,9 @@ module RSpec
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def to_graphql(field_sample)
|
31
|
-
return field_sample unless field_sample.respond_to?(:
|
31
|
+
return field_sample unless field_sample.respond_to?(:to_type_signature)
|
32
32
|
|
33
|
-
field_sample.
|
33
|
+
field_sample.to_type_signature
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -80,16 +80,16 @@ module RSpec
|
|
80
80
|
field = field_collection[@expected_field_name]
|
81
81
|
field ||= field_collection[@expected_camel_field_name]
|
82
82
|
|
83
|
-
field.respond_to?(:
|
83
|
+
field.respond_to?(:to_type_signature) ? field.to_type_signature : field
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
def descriptions
|
88
|
-
|
88
|
+
results.map(&:description)
|
89
89
|
end
|
90
90
|
|
91
91
|
def failure_messages
|
92
|
-
|
92
|
+
results.map(&:failure_message)
|
93
93
|
end
|
94
94
|
|
95
95
|
def field_collection
|
@@ -108,6 +108,10 @@ module RSpec
|
|
108
108
|
when :return_fields then 'have_a_return_field'
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
def results
|
113
|
+
@results ||= []
|
114
|
+
end
|
111
115
|
end
|
112
116
|
end
|
113
117
|
end
|
@@ -28,7 +28,11 @@ module RSpec
|
|
28
28
|
return actual_field.hash_key.to_sym if actual_field.hash_key
|
29
29
|
end
|
30
30
|
|
31
|
-
actual_field.metadata
|
31
|
+
if actual_field.respond_to?(:metadata)
|
32
|
+
return actual_field.metadata[:type_class].method_sym
|
33
|
+
end
|
34
|
+
|
35
|
+
actual_field.method_sym
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.add_dependency 'graphql', '>= 1.
|
28
|
+
spec.add_dependency 'graphql', '>= 1.10.12', '< 2.0'
|
29
29
|
spec.add_dependency 'rspec', '~> 3.0'
|
30
30
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
31
31
|
# CodeClimate does not yet support SimpleCov 0.18
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-graphql_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Brandão
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.10.12
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.10.12
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
@@ -100,7 +100,7 @@ dependencies:
|
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0.71'
|
103
|
-
description:
|
103
|
+
description:
|
104
104
|
email:
|
105
105
|
- gb.samuel@gmail.com
|
106
106
|
executables: []
|
@@ -141,7 +141,7 @@ homepage: https://github.com/khamusa/rspec-graphql_matchers
|
|
141
141
|
licenses:
|
142
142
|
- MIT
|
143
143
|
metadata: {}
|
144
|
-
post_install_message:
|
144
|
+
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|
147
147
|
- lib
|
@@ -156,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
159
|
+
rubygems_version: 3.3.7
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Collection of rspec matchers to test your graphQL api schema.
|
163
163
|
test_files: []
|