-
-
Save paulomcnally/a0c82e83846cd5fde8af812f6034377a to your computer and use it in GitHub Desktop.
Acceptance test example for https://github.com/howtographql/graphql-ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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