Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot specs for countries query #55

Merged
merged 6 commits into from
Dec 13, 2019
Merged

Conversation

AlessioRocco
Copy link
Contributor

@AlessioRocco AlessioRocco commented Dec 6, 2019

Change specs to use snapshot results instead of test the nodes one by one.

@AlessioRocco AlessioRocco self-assigned this Dec 6, 2019
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 2 times, most recently from 6a44be5 to 6d0604b Compare December 6, 2019 08:05
@AlessioRocco AlessioRocco changed the base branch from master to improve-execute_query-spec-helper December 6, 2019 08:06
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 3 times, most recently from 52f0810 to ecccb92 Compare December 6, 2019 09:56
@AlessioRocco AlessioRocco force-pushed the improve-execute_query-spec-helper branch from d7f543a to 3f70203 Compare December 6, 2019 10:07
@AlessioRocco AlessioRocco changed the base branch from improve-execute_query-spec-helper to master December 6, 2019 10:20
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 3 times, most recently from b78e869 to 366b5ee Compare December 6, 2019 10:32
@AlessioRocco AlessioRocco marked this pull request as ready for review December 6, 2019 11:41
@AlessioRocco AlessioRocco added the WIP Work in progress label Dec 13, 2019
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 4 times, most recently from d0b450c to b14d09a Compare December 13, 2019 10:40
@AlessioRocco AlessioRocco added this to In progress in solidus_graphql_api Dec 13, 2019
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 9 times, most recently from 465f091 to 343f385 Compare December 13, 2019 12:04
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 2 times, most recently from 194be47 to 7172b66 Compare December 13, 2019 13:04
@AlessioRocco AlessioRocco removed the WIP Work in progress label Dec 13, 2019
@AlessioRocco AlessioRocco changed the title Add snapshot specs Add snapshot specs for countries query Dec 13, 2019
@AlessioRocco AlessioRocco force-pushed the add-snapshot-specs branch 3 times, most recently from 9ac20a1 to 18215d3 Compare December 13, 2019 13:58
Copy link
Contributor

@ChristianRimondi ChristianRimondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This custom RSpec matcher compares the result of a Graphql query
with a JSON file that is stored in the folder spec/support/query_results/.
The result files must have the 'json.erb' extension and
supports 'erb', the variables can be set by using the method chain
'with_args', and the format can be set with 'as', for example:

'match_response('countries').with_args(current_time: current_time).as(Hash)'
The aliases are 'describe_query', 'connection_field' and 'field'.
They can be used in the specs to explain better the result of a
Graphql query, and they are of type "graphql_query".
This type sets the subject by default through the "graphql query"
shared context.
The subject query can be set using a "let(:query)" or with the "query"
metadata, and also the 'context' and 'variables' can be set in the same
way.
It also adds the "freeze_date" metadata that freeze the date with
Timecop, if set to false the date will be the one set with the
"DEFAULT_FREEZE_DATE" constant, instead if it is a String will be set
by the given date parsed with "DateTime#parse".
Uses the 'describe_query' and 'connection_field' example groups to
set the subject query and to freeze the time, and the 'match_response'
custom matcher to compare the query with the result.
It also adds a spec to verify the result when the countries don't exist.
All the code now is covered by the integration specs.
@AlessioRocco AlessioRocco merged commit 8098a01 into master Dec 13, 2019
@AlessioRocco AlessioRocco moved this from To review to Done in solidus_graphql_api Dec 13, 2019
@AlessioRocco AlessioRocco deleted the add-snapshot-specs branch December 13, 2019 15:18
@aldesantis aldesantis removed this from Done in solidus_graphql_api Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants