Skip to content

Instantly share code, notes, and snippets.

@RStankov
Last active June 6, 2019 22:54
Show Gist options
  • Save RStankov/8740088ce776856af0d01a8500d3e774 to your computer and use it in GitHub Desktop.
Save RStankov/8740088ce776856af0d01a8500d3e774 to your computer and use it in GitHub Desktop.
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