Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulomcnally/a0c82e83846cd5fde8af812f6034377a to your computer and use it in GitHub Desktop.
Save paulomcnally/a0c82e83846cd5fde8af812f6034377a to your computer and use it in GitHub Desktop.
Acceptance test example for https://github.com/howtographql/graphql-ruby
require 'spec_helper'
describe 'GraphQL acceptance' do
describe 'allLinks' do
it 'returns all links' do
link1 = create :link, description: 'first'
link2 = create :link, description: 'second'
query = %(
{
allLinks {
id
description
}
}
)
expect_query_result(query).to eq(
allLinks: [
{ id: link1.id, description: link1.description },
{ id: link2.id, description: link2.description },
]
)
end
def expect_query_result(query, variables: {}, context: {})
expect(GraphqlTutorialSchema.execute(query, variables: variables, context: context, operation_name: 'Test'))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment