Skip to content

Commit

Permalink
Merge pull request #4541 from RicardoTrindade/patch-1
Browse files Browse the repository at this point in the history
Update context_spec.rb
  • Loading branch information
rmosolgo authored Jul 4, 2023
2 parents b228964 + 18f27de commit 4b85eff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spec/graphql/query/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class ContextSchema < GraphQL::Schema
refute(context.key?(expected_key))
assert_raises(KeyError) { context.fetch(expected_key) }
assert_nil(context.fetch(expected_key, nil))
assert_nil(context.dig(expected_key)) if RUBY_VERSION >= '2.3.0'
assert_nil(context.dig(expected_key))

context.scoped_merge!(expected_key => nil)
context[expected_key] = expected_value
Expand All @@ -410,23 +410,23 @@ class ContextSchema < GraphQL::Schema
assert_equal({ expected_key => nil }, context.to_h)
assert(context.key?(expected_key))
assert_nil(context.fetch(expected_key))
assert_nil(context.dig(expected_key)) if RUBY_VERSION >= '2.3.0'
assert_nil(context.dig(expected_key))

dummy_runtime.current_result = OpenStruct.new(path: ["something", "new"])

assert_equal(expected_value, context[expected_key])
assert_equal({ expected_key => expected_value}, context.to_h)
assert(context.key?(expected_key))
assert_equal(expected_value, context.fetch(expected_key))
assert_equal(expected_value, context.dig(expected_key)) if RUBY_VERSION >= '2.3.0'
assert_equal(expected_value, context.dig(expected_key))

# Enter a child field:
dummy_runtime.current_result = OpenStruct.new(path: ["somewhere", "child"])
assert_nil(context[expected_key])
assert_equal({ expected_key => nil }, context.to_h)
assert(context.key?(expected_key))
assert_nil(context.fetch(expected_key))
assert_nil(context.dig(expected_key)) if RUBY_VERSION >= '2.3.0'
assert_nil(context.dig(expected_key))

# And a grandchild field
dummy_runtime.current_result = OpenStruct.new(path: ["somewhere", "child", "grandchild"])
Expand All @@ -436,7 +436,7 @@ class ContextSchema < GraphQL::Schema
assert_equal({ expected_key => :something_else, another_key: :another_value }, context.to_h)
assert(context.key?(expected_key))
assert_equal(:something_else, context.fetch(expected_key))
assert_equal(:something_else, context.dig(expected_key)) if RUBY_VERSION >= '2.3.0'
assert_equal(:something_else, context.dig(expected_key))
end

it "sets a value using #scoped_set!" do
Expand Down

0 comments on commit 4b85eff

Please sign in to comment.