Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 815 Bytes

have_field.md

File metadata and controls

46 lines (35 loc) · 815 Bytes

Validate a response operation with have_field(name)

Check for the presence of an operation's results. Useful when you want to ensure an operation exists before retrieving the operation's results.

Validate an Operation is Present

RSpec.describe My::Characters, type: :graphql do
  graphql_operation <<-GQL
    query CharacterList {
      characters {
        id
        name
      }
    }
  GQL

  it "has the characters" do

    expect(response).to have_field(:characters)

  end
end

Validate an operation is NOT Present

RSpec.describe My::Characters, type: :graphql do
  graphql_operation <<-GQL
    query CharacterList {
      characters {
        id
        name
      }
    }
  GQL

  it "does not have books" do

    expect(response).to_not have_field(:books)

  end
end