diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-16 16:04:41 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-05 21:47:42 +0300 |
commit | 9c6c17cbcdb8bf8185fc1b873dcfd08f723e4df5 (patch) | |
tree | 624dba30e87ed0ea39afa0535d92c37c7718daef /spec/support/matchers | |
parent | 67dc43db2f30095cce7fe01d7f475d084be936e8 (diff) |
Add a minimal GraphQL API
Diffstat (limited to 'spec/support/matchers')
-rw-r--r-- | spec/support/matchers/graphql_matchers.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb new file mode 100644 index 00000000000..c0ed16ecaba --- /dev/null +++ b/spec/support/matchers/graphql_matchers.rb @@ -0,0 +1,31 @@ +RSpec::Matchers.define :require_graphql_authorizations do |*expected| + match do |field| + authorizations = field.metadata[:authorize] + + expect(authorizations).to contain_exactly(*expected) + end +end + +RSpec::Matchers.define :have_graphql_fields do |*expected| + match do |kls| + expect(kls.fields.keys).to contain_exactly(*expected.map(&:to_s)) + end +end + +RSpec::Matchers.define :have_graphql_arguments do |*expected| + match do |field| + expect(field.arguments.keys).to contain_exactly(*expected.map(&:to_s)) + end +end + +RSpec::Matchers.define :have_graphql_type do |expected| + match do |field| + expect(field.type).to eq(expected) + end +end + +RSpec::Matchers.define :have_graphql_resolver do |expected| + match do |field| + expect(field.resolve_proc).to eq(expected) + end +end |