rspec-graphql_matchers 1.4.0 → 2.0.0.pre.rc.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: 7dae51bcd93df2cadbbc1f056f27246ffe9fc54fb046cd542bc0461e4caadac8
4
- data.tar.gz: dfa65482790aa2ca2ad4d7318679e0b80f13b9ba34c27ca7f7f525e699d7ea4a
3
+ metadata.gz: 984e7d05766f0502ee910f99f522cd81a873b87a9c64ba13b7b1441602c65e51
4
+ data.tar.gz: d21699dc04dde4843a7d9a109674f8b9d208b35adb39ccfa5a7c2560b209ce4e
5
5
  SHA512:
6
- metadata.gz: 280d14d08215126ef991443f1d786c5d15b2c5c82a34378f17d3c3cd1bd8ab0ab21efd9d1ff9870115c2aeca6d6b4d72dc80aecc760dbd52b6862807440e1f5b
7
- data.tar.gz: 571b16fe5f151501313b6a7e94ba32b4f431fa352f2cf11f0ae06af44f1a5e8143a68dc4961cdbcef359c081696391977483e1b65972bb574e2d3ab0029cfa26
6
+ metadata.gz: 3a1ab2cb2da43f52f17080065d9a4616459a4ce23b39bb3ea39259cc35599e0325c5fd90077d62e785262de19c92512e95c41742d62f5cd8e9372d7a834ce3a2
7
+ data.tar.gz: 9524fb181330f10eeb4dc7c7eb31888c48a3c97003c7f47579749a00b59672b2148b59d2579ee75a1ea11dcab4626641ce51b7986e714dc177290ea4a0c2ca73
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0 (April 16th, 2023)
4
+
5
+ - Adds compatibility with graphql-ruby 2.0+. If you're still using an earlier version, you should stick to 1.4.x.
6
+
7
+ ### Deprecations
8
+
9
+ - The usage of the `#types` helper when writing tests (if you're not including `RSpec::GraphqlMatchers::TypesHelper` anywhere, you shoudn't have to change anything). Use `GraphQL::Types::<TYPE_NAME>` instead
10
+ - The usage of type instances as expected value for a type comparison is deprecated. Instead,
11
+ use the string that represents the type specification. Examples:
12
+
13
+ ```
14
+ # Bad - These are deprecated:
15
+ expect(a_type).to have_a_field(:lorem).of_type(GraphQL::Types::ID)
16
+ expect(a_type).to have_a_field(:lorem).of_type(Types::MyCustomType)
17
+
18
+ # Good - Use these instead
19
+ expect(a_type).to have_a_field(:lorem).of_type('ID')
20
+ expect(a_type).to have_a_field(:lorem).of_type('MyCustomType')
21
+ ```
22
+
23
+ The reason behind this change relies on the fact that we should have a decoupling between the
24
+ internal constants used to define our API and the public names exposed through it. If we test
25
+ a published API using the internal constants, it is possible to perform breaking changes by
26
+ renaming the graphql names of our types or entities without actually breaking the tests.
27
+
28
+ If we're performing a breaking change to a public API, we want our tests to fail.
29
+
3
30
  ## 1.4.0 (April 16th, 2023)
4
31
 
5
32
  - 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)
data/README.md CHANGED
@@ -21,11 +21,9 @@ The matchers currently supported are:
21
21
  - `expect(a_field).to be_of_type(valid_type)`
22
22
  - `expect(an_input).to accept_argument(argument_name).of_type(valid_type)`
23
23
 
24
- Where a valid type for the expectation is either:
24
+ Where `valid_type` is a your type signature as a String: `"String!"`, `"Int!"`, `"[String]!"` (note the exclamation mark at the end, as required by the [GraphQL specifications](http://graphql.org/).
25
25
 
26
- - A reference to the actual type you expect;
27
- - [Recommended] A String representation of a type: `"String!"`, `"Int!"`, `"[String]!"`
28
- (note the exclamation mark at the end, as required by the [GraphQL specifications](http://graphql.org/).
26
+ Please note that using references to type instances is deprecated and will be removed in a future release.
29
27
 
30
28
  ## Examples
31
29
 
@@ -44,9 +42,9 @@ class PostType < GraphQL::Schema::Object
44
42
  field :published, Boolean, null: false, deprecation_reason: 'Use isPublished instead'
45
43
 
46
44
  field :subposts, PostType, null: true do
47
- argument :filter, types.String, required: false
48
- argument :id, types.ID, required: false
49
- argument :isPublished, types.Boolean, required: false
45
+ argument :filter, String, required: false
46
+ argument :id, ID, required: false
47
+ argument :isPublished, Boolean, required: false
50
48
  end
51
49
  end
52
50
  ```
@@ -57,7 +55,7 @@ end
57
55
  describe PostType do
58
56
  subject { described_class }
59
57
 
60
- it { is_expected.to have_field(:id).of_type(!types.ID) }
58
+ it { is_expected.to have_field(:id).of_type("ID!") }
61
59
  it { is_expected.to have_field(:comments).of_type("[String!]!") }
62
60
  it { is_expected.to have_field(:isPublished).of_type("Boolean") }
63
61
 
@@ -123,8 +121,6 @@ describe PostType do
123
121
  expect(subject).to implement('Node')
124
122
  end
125
123
 
126
- # Accepts arguments as an array and type objects directly
127
- it { is_expected.to implement(GraphQL::Types::Relay::Node) }
128
124
  it { is_expected.not_to implement('OtherInterface') }
129
125
  end
130
126
  ```
@@ -40,7 +40,7 @@ module RSpec
40
40
 
41
41
  def describe_arguments(what_args)
42
42
  what_args.sort.map do |arg_name, arg_type|
43
- "#{arg_name}(#{arg_type})"
43
+ "#{arg_name}(#{type_name(arg_type)})"
44
44
  end.join(', ')
45
45
  end
46
46
  end
@@ -17,7 +17,8 @@ module RSpec
17
17
  end
18
18
 
19
19
  def failure_message
20
- "expected field '#{member_name(sample)}' to be of type '#{expected}', " \
20
+ "expected field '#{member_name(sample)}' to " \
21
+ "be of type '#{type_name(expected)}', " \
21
22
  "but it was '#{type_name(sample.type)}'"
22
23
  end
23
24
 
@@ -103,9 +103,8 @@ module RSpec
103
103
 
104
104
  def matcher_name
105
105
  case @fields
106
- when :fields then 'have_a_field'
107
- when :input_fields then 'have_an_input_field'
108
- when :return_fields then 'have_a_return_field'
106
+ when :fields then 'have_a_field'
107
+ when :arguments then 'have_an_input_field'
109
108
  end
110
109
  end
111
110
 
@@ -5,7 +5,7 @@ module RSpec
5
5
  module HaveAFieldMatchers
6
6
  class OfType < RSpec::GraphqlMatchers::BeOfType
7
7
  def description
8
- "of type `#{expected}`"
8
+ "of type `#{type_name(expected)}`"
9
9
  end
10
10
 
11
11
  def failure_message
@@ -28,12 +28,12 @@ module RSpec
28
28
  alias have_field have_a_field
29
29
 
30
30
  def have_an_input_field(field_name)
31
- RSpec::GraphqlMatchers::HaveAField.new(field_name, :input_fields)
31
+ RSpec::GraphqlMatchers::HaveAField.new(field_name, :arguments)
32
32
  end
33
33
  alias have_input_field have_an_input_field
34
34
 
35
35
  def have_a_return_field(field_name)
36
- RSpec::GraphqlMatchers::HaveAField.new(field_name, :return_fields)
36
+ RSpec::GraphqlMatchers::HaveAField.new(field_name)
37
37
  end
38
38
  alias have_return_field have_a_return_field
39
39
  # rubocop:enable Naming/PredicateName
@@ -5,8 +5,20 @@ require 'graphql'
5
5
  module RSpec
6
6
  module GraphqlMatchers
7
7
  module TypesHelper
8
+ class << self
9
+ extend Gem::Deprecate
10
+
11
+ GraphQL::Types.constants.each do |constant_name|
12
+ klass = GraphQL::Types.const_get(constant_name)
13
+
14
+ define_method(constant_name) { klass }
15
+
16
+ deprecate constant_name, "GraphQL::Types::#{constant_name}", 2023, 10
17
+ end
18
+ end
19
+
8
20
  def types
9
- GraphQL::Define::TypeDefiner.instance
21
+ TypesHelper
10
22
  end
11
23
  end
12
24
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rspec
4
4
  module GraphqlMatchers
5
- VERSION = '1.4.0'.freeze
5
+ VERSION = '2.0.0-rc.0'.freeze
6
6
  end
7
7
  end
@@ -14,9 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/khamusa/rspec-graphql_matchers'
15
15
  spec.license = 'MIT'
16
16
 
17
- # raise 'RubyGems 2.0 or newer is required to protect against public gem ' \
18
- # 'pushes.'
19
-
20
17
  spec.files =
21
18
  `git ls-files -z`
22
19
  .split("\x0")
@@ -25,7 +22,7 @@ Gem::Specification.new do |spec|
25
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
23
  spec.require_paths = ['lib']
27
24
 
28
- spec.add_dependency 'graphql', '>= 1.10.12', '< 2.0'
25
+ spec.add_dependency 'graphql', '~> 2.0'
29
26
  spec.add_dependency 'rspec', '~> 3.0'
30
27
  spec.add_development_dependency 'bundler', '~> 2.0'
31
28
  # CodeClimate does not yet support SimpleCov 0.18
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-graphql_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0.pre.rc.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Brandão
@@ -14,20 +14,14 @@ dependencies:
14
14
  name: graphql
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.10.12
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '2.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.10.12
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
26
  version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
@@ -152,9 +146,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
146
  version: '0'
153
147
  required_rubygems_version: !ruby/object:Gem::Requirement
154
148
  requirements:
155
- - - ">="
149
+ - - ">"
156
150
  - !ruby/object:Gem::Version
157
- version: '0'
151
+ version: 1.3.1
158
152
  requirements: []
159
153
  rubygems_version: 3.3.7
160
154
  signing_key: