spec/graphql/query/context_spec.rb in graphql-0.12.1 vs spec/graphql/query/context_spec.rb in graphql-0.13.0
- old
+ new
@@ -20,33 +20,41 @@
describe "access to passed-in values" do
let(:query_string) { %|
query getCtx { context(key: "some_key") }
|}
- it 'passes context to fields' do
+ it "passes context to fields" do
expected = {"data" => {"context" => "some value"}}
assert_equal(expected, result)
end
end
describe "access to the AST node" do
let(:query_string) { %|
query getCtx { contextAstNodeName }
|}
- it 'provides access to the AST node' do
+ it "provides access to the AST node" do
expected = {"data" => {"contextAstNodeName" => "GraphQL::Language::Nodes::Field"}}
assert_equal(expected, result)
end
end
describe "access to the query" do
let(:query_string) { %|
query getCtx { queryName }
|}
- it 'provides access to the AST node' do
+ it "provides access to the AST node" do
expected = {"data" => {"queryName" => "GraphQL::Query"}}
assert_equal(expected, result)
+ end
+ end
+
+ describe "empty values" do
+ let(:context) { GraphQL::Query::Context.new(query: OpenStruct.new(schema: schema), values: nil) }
+
+ it "returns nil for any key" do
+ assert_equal(nil, context[:some_key])
end
end
end