diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/support_specs/graphql/var_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/support_specs/graphql/var_spec.rb')
-rw-r--r-- | spec/support_specs/graphql/var_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/support_specs/graphql/var_spec.rb b/spec/support_specs/graphql/var_spec.rb new file mode 100644 index 00000000000..f708f01a11e --- /dev/null +++ b/spec/support_specs/graphql/var_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Graphql::Var do + subject(:var) { described_class.new('foo', 'Int') } + + it 'associates a name with a type and an initially empty value' do + expect(var).to have_attributes( + name: 'foo', + type: 'Int', + value: be_nil + ) + end + + it 'has a correct signature' do + expect(var).to have_attributes(sig: '$foo: Int') + end + + it 'implements to_graphql_value as $name' do + expect(var.to_graphql_value).to eq('$foo') + end + + it 'can set a value using with, returning a new object' do + with_value = var.with(42) + + expect(with_value).to have_attributes(name: 'foo', type: 'Int', value: 42) + expect(var).to have_attributes(value: be_nil) + end + + it 'returns an object suitable for passing to post_graphql(variables:)' do + expect(var.with(17).to_h).to eq('foo' => 17) + end +end |