Last active
June 6, 2019 22:54
-
-
Save RStankov/8740088ce776856af0d01a8500d3e774 to your computer and use it in GitHub Desktop.
Acceptance test example for https://github.com/howtographql/graphql-ruby
This file contains 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