summaryrefslogtreecommitdiff
path: root/spec/support/matchers/graphql_matchers.rb
blob: c0ed16ecaba7a1b9c7776cd80c9380c77f330ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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