rspec-graphql_response 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/docs/execute_graphql.md +13 -6
- data/lib/rspec/graphql_response/helpers.rb +4 -2
- data/lib/rspec/graphql_response/helpers/execute_graphql.rb +8 -3
- data/lib/rspec/graphql_response/helpers/graphql_context.rb +1 -1
- data/lib/rspec/graphql_response/helpers/graphql_query.rb +1 -1
- data/lib/rspec/graphql_response/helpers/graphql_variables.rb +1 -1
- data/lib/rspec/graphql_response/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e29dab7149a9ebfd23ce4ba769da4cc53cae5008c2c2125cfd958dbad39d1f0
|
4
|
+
data.tar.gz: 7e602e4c314336f7844e58bc195067229211a6a63dd99acee958982062c509c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3be27dabfaafee8b1bcd789e47828f1603095ed7757d19e89f0b60209e9a40328ecae0548f886815bd1fb00e74c07467459fdd49ab3b6a3e77ca7e8f29ad65f
|
7
|
+
data.tar.gz: f65e64010b9940b7eca6801f170190eb51bdfcae35f29705d45c1e3034b3151a941f29c7b13af8cb502aad0fc85d59d208fdb2b6e806a3fd9a7f7225f68942e1
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-graphql_response (0.2.
|
5
|
-
|
4
|
+
rspec-graphql_response (0.2.1)
|
5
|
+
graphql (>= 1.0)
|
6
|
+
rspec (>= 3.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -38,7 +39,6 @@ PLATFORMS
|
|
38
39
|
|
39
40
|
DEPENDENCIES
|
40
41
|
bundler (~> 1.17)
|
41
|
-
graphql (~> 1.12)
|
42
42
|
pry (~> 0.14)
|
43
43
|
pry-byebug (~> 3.8)
|
44
44
|
rake (>= 12.0)
|
data/docs/execute_graphql.md
CHANGED
@@ -5,6 +5,9 @@ methods for configuring the query.
|
|
5
5
|
|
6
6
|
```ruby
|
7
7
|
RSPec.describe Cool::Stuff, type: :graphql do
|
8
|
+
let(:user) { create(:graphql_user) }
|
9
|
+
let(:search_name) { "Pet" }
|
10
|
+
|
8
11
|
graphql_query <<-GQL
|
9
12
|
query SomeThing($name: String) {
|
10
13
|
characters(name: $name) {
|
@@ -14,13 +17,17 @@ RSPec.describe Cool::Stuff, type: :graphql do
|
|
14
17
|
}
|
15
18
|
GQL
|
16
19
|
|
17
|
-
graphql_variables
|
18
|
-
|
19
|
-
|
20
|
+
graphql_variables do
|
21
|
+
{
|
22
|
+
name: search_name
|
23
|
+
}
|
24
|
+
end
|
20
25
|
|
21
|
-
grapql_context
|
22
|
-
|
23
|
-
|
26
|
+
grapql_context do
|
27
|
+
{
|
28
|
+
current_user: user
|
29
|
+
}
|
30
|
+
end
|
24
31
|
|
25
32
|
it "executes and does the thing with the vars and context" do
|
26
33
|
# ... expect things here
|
@@ -6,13 +6,14 @@ module RSpec
|
|
6
6
|
|
7
7
|
def self.add_helper(name, scope: :spec, &helper)
|
8
8
|
helper_module = Module.new do |mod|
|
9
|
-
mod.define_method(name) do |*args|
|
9
|
+
mod.define_method(name) do |*args, &block|
|
10
10
|
instance_var = "@#{name}".to_sym
|
11
11
|
|
12
12
|
if self.instance_variables.include? instance_var
|
13
13
|
return self.instance_variable_get(instance_var)
|
14
14
|
end
|
15
15
|
|
16
|
+
args << block
|
16
17
|
result = self.instance_exec(*args, &helper)
|
17
18
|
self.instance_variable_set(instance_var, result)
|
18
19
|
end
|
@@ -20,7 +21,8 @@ module RSpec
|
|
20
21
|
|
21
22
|
RSpec.configure do |config|
|
22
23
|
config.after(:each) do
|
23
|
-
|
24
|
+
instance_var = "@#{name}".to_sym
|
25
|
+
helper_module.instance_variable_set(instance_var, nil)
|
24
26
|
end
|
25
27
|
|
26
28
|
module_method = if scope == :spec
|
@@ -1,9 +1,14 @@
|
|
1
1
|
RSpec::GraphQLResponse.add_helper :execute_graphql do
|
2
2
|
config = RSpec::GraphQLResponse.configuration
|
3
3
|
|
4
|
-
query =
|
5
|
-
|
6
|
-
|
4
|
+
query = graphql_query if respond_to? :graphql_query
|
5
|
+
query = self.instance_eval(&graphql_query) if query.is_a? Proc
|
6
|
+
|
7
|
+
query_vars = graphql_variables if respond_to? :graphql_variables
|
8
|
+
query_vars = self.instance_eval(&graphql_variables) if query_vars.is_a? Proc
|
9
|
+
|
10
|
+
query_context = graphql_context if respond_to? :graphql_context
|
11
|
+
query_context = self.instance_eval(&query_context) if query_context.is_a? Proc
|
7
12
|
|
8
13
|
config.graphql_schema.execute(query, {
|
9
14
|
variables: query_vars,
|
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.3.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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|