rspec-graphql_types 1.0.2 → 1.0.5

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: 11f73ac9e786a08627ae1afbd8fbc58309604d990290c5a5b7e20650e9ba8c63
4
- data.tar.gz: 6204c42cb10b3008f2f5bb25afe6f101dfa9661c70416e9bdaace47213c16cd3
3
+ metadata.gz: 71d9e4107a617bb6b00c6510139162fd5334b56bbc2bdba1969f8ea30570c204
4
+ data.tar.gz: 8a067ac01ce90d84db19807c907b95d40c1576b2a47ebdad96b0a88a4b6a7fa6
5
5
  SHA512:
6
- metadata.gz: 2f5b269d2510d38015e1019eb644103fc7c053b8b8b876a5ab0c593caa85ddb1bb4c1c00c614de1564cdf922777ce2ff71e5fdc6c4bff631109858a2885e7212
7
- data.tar.gz: a2cda1ae737bf004e587df3b46e686a3b7d45cd3b6b6fe35cfabe3f0369558d351428153aa7702a45d2ef83d0bc6088899c27f6c9c57b0cf0c2b1039b4faf3cc
6
+ metadata.gz: ab7ebe43158db7914e77c84760b7f89caf3e943d1453abd9c0463ad03302f688c44a514b904e72b1f080f15901000f593c6bc53c1d1adda48a279e50cfa2b077
7
+ data.tar.gz: 7a7d5f28f2df92b424a27378800aed6c8349445aff0325b626facce4699d27522471126ab51e39f37556d897c6ccfb68680d8b47ea7e3d17ba0548279666b969
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ rspec-graphql_types.iml
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-graphql_types (1.0.2)
4
+ rspec-graphql_types (1.0.3)
5
5
  activesupport
6
6
  graphql
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.4)
11
+ activesupport (6.1.4.1)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
@@ -16,7 +16,7 @@ GEM
16
16
  zeitwerk (~> 2.3)
17
17
  concurrent-ruby (1.1.9)
18
18
  diff-lcs (1.4.4)
19
- graphql (1.12.14)
19
+ graphql (1.12.16)
20
20
  i18n (1.8.10)
21
21
  concurrent-ruby (~> 1.0)
22
22
  minitest (5.14.4)
@@ -40,6 +40,7 @@ GEM
40
40
 
41
41
  PLATFORMS
42
42
  arm64-darwin-20
43
+ x86_64-darwin-20
43
44
 
44
45
  DEPENDENCIES
45
46
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Rspec::GraphqlTypes
1
+ # Rspec::GraphQLTypes
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec/graphql_types`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This library can be used to unit test GraphQL types from the 'graphql' library.
6
4
 
7
5
  ## Installation
8
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rspec
4
4
  module GraphQLTypes
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
@@ -16,10 +16,15 @@ module Rspec
16
16
  def multiplex
17
17
  nil
18
18
  end
19
+
20
+ def warden
21
+ @warden
22
+ end
19
23
  end
20
24
 
21
25
  included do
22
- let(:context) { GraphQL::Query::Context.new(query: TestQuery.new, values: nil, object: nil, schema: GraphQLTypes.schema_class.new) }
26
+ let(:context_values) { nil }
27
+ let(:context) { GraphQL::Query::Context.new(query: TestQuery.new, values: context_values, object: nil, schema: GraphQLTypes.schema_class.new) }
23
28
  end
24
29
 
25
30
  def graphql_object(type, value)
@@ -36,6 +41,8 @@ module Rspec
36
41
  type.coerce_result(value, context)
37
42
  when 'LIST'
38
43
  value.map { |v| graphql_object(type.of_type, v) }
44
+ when 'ENUM'
45
+ type.coerce_result(value, context)
39
46
  else
40
47
  raise "Unknown type kind #{type.kind.name}"
41
48
  end
@@ -49,6 +56,7 @@ module Rspec
49
56
  value = context.dataloader.run_isolated do
50
57
  graphql_field.resolve(object, arguments, context)
51
58
  end
59
+ raise value if value.is_a?(Exception)
52
60
  graphql_object(graphql_field.type, value)
53
61
  end
54
62
 
@@ -65,7 +73,7 @@ module Rspec
65
73
  end
66
74
 
67
75
  def self.schema_class
68
- schemas = GraphQL::Schema.subclasses
76
+ schemas = GraphQL::Schema.subclasses.filter { |schema| !schema.name.start_with?("GraphQL::") }
69
77
  raise "Could not find valid schema. Please ensure that GraphQL::Schema.subclasses returns a single schema" unless schemas.length == 1
70
78
  schemas.first
71
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-graphql_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tejas Dinkar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.2.3
85
+ rubygems_version: 3.2.32
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Test out types in ruby graphql