{"id":13879647,"url":"https://github.com/nareshnavinash/Graber-Ruby","last_synced_at":"2025-07-16T15:32:42.878Z","repository":{"id":46742340,"uuid":"238855490","full_name":"nareshnavinash/Graber-Ruby","owner":"nareshnavinash","description":"Automation framework for Graphql with snapshot feature","archived":false,"fork":false,"pushed_at":"2023-01-20T21:01:00.000Z","size":146,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-06T19:50:29.126Z","etag":null,"topics":["automation","framework","grahpql","graphql-automation","ruby","snap-mode","test-automation"],"latest_commit_sha":null,"homepage":"https://nareshnavinash.github.io/Graber-Ruby/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nareshnavinash.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-07T06:07:48.000Z","updated_at":"2020-07-20T04:10:15.000Z","dependencies_parsed_at":"2023-02-12T05:16:50.901Z","dependency_job_id":null,"html_url":"https://github.com/nareshnavinash/Graber-Ruby","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareshnavinash%2FGraber-Ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareshnavinash%2FGraber-Ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareshnavinash%2FGraber-Ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareshnavinash%2FGraber-Ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nareshnavinash","download_url":"https://codeload.github.com/nareshnavinash/Graber-Ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","framework","grahpql","graphql-automation","ruby","snap-mode","test-automation"],"created_at":"2024-08-06T08:02:27.680Z","updated_at":"2024-11-24T08:31:35.027Z","avatar_url":"https://github.com/nareshnavinash.png","language":"Ruby","readme":"# Graber - Ruby\n\nGraber is a framework for Graphql automation using Cucumber in Ruby language. Graphql automation can be done just by defining the query, query variable and other requirements from cucumber's feature file itself. All the core logics are covered in step definition file. Graber also includes snap feature which helps to replace the exisiting JSON's (which is used to compare with the response JSON) with the new response JSON's. This helps greatly in data centric applications.\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](LICENSE)\n[![Made with Ruby](https://img.shields.io/badge/Made%20with-Ruby-red.svg)](https://www.ruby-lang.org/en/)\n[![StackOverflow](http://img.shields.io/badge/Stack%20Overflow-Ask-blue.svg)]( https://stackoverflow.com/users/10505289/naresh-sekar )\n[![Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](CONTRIBUTING.md)\n[![email me](https://img.shields.io/badge/Contact-Email-green.svg)](mailto:nareshnavinash@gmail.com)\n\n\n![alt text](features/libraries/Graber-Ruby.png)\n\n\n## Supports\n* Graphql automation\n* No code scripting\n* Allure reports\n* Jenkins Integration\n* Modes of run via CLI command\n* Headless run\n* Snap feature to change test data in one shot\n\n## Setup\n* Clone this repository\n* Navigate to the cloned folder\n* Install bundler using `gem install bundler`\n* Install the dependencies by `bundle install`\n\n## To Run the tests\nFor a simple run of all the feature files in normal mode, try\n```\ncucumber\n```\nTo Run the tests in Snap mode for the available feature files, try\n\n```\ncucumber snap=1\n```\nThis will take the response JSON and save it to the test data file if any of the test case failed. Be cautious while using this mode and never commit the changes made after this run blindly. This mode will change only the files available in the `graphql/expected_jsons` folder and will never change any other files in the project.\n\nTo Run the tests in snap mode along with tags, try\n```\ncucumber -t \"@scenario_001\" snap=1\n```\n\n## To open allure results\nAllure is a open source framework for reporting the test runs. To install allure in mac, use the following steps\n\n```\nbrew cask install adoptopenjdk\nbrew install allure\n```\n\nTo open the generated allure results,\n\n```\nallure serve reports/allure\n```\n\n## Jenkins Integration with Docker images\nGet any of the linux with ruby docker image as the slaves in jenkins and use the same for executing the UI automation with this framework (Sample docker image - `https://hub.docker.com/_/ruby`). From the jenkins bash Execute the following to get the testcases to run,\n```\n#!/bin/bash -l\nrvm list\nls\ncd \u003cpath_to_the_project\u003e\nbundle install\ncucumber #or custom commands\n```\nfor complete guide to setup in linux check [Cloud Setup for Ruby](https://github.com/nareshnavinash/Cloud-Setup-Ruby)\n\nIn Jenkins pipeline, try to add the following snippet to execute the tests,\n```\npipeline {\n    agent { docker { image 'ruby' } }\n    stages {\n        stage('build') {\n            steps {\n                sh 'cd project/'\n                sh 'gem install bundler'\n                sh 'bundle install'\n                sh 'cucumber' # or custom methods\n            }\n        }\n    }\n}\n```\n\n## Break down into end to end tests\n\n## Defining Query, Query Variable and Response files\n\nFor all the test case it is mandatory to create a file for query file and a response file. If the query needs query variable then it is mandatory to create variable file.\n\n### Query file\n\nCreate a file with `.graphql` extention inside the folder `graphql/query`and place the graphql query inside it. The query should be a working one and we should not have custom name next to the `query` term. Even for mutation same rule applies.\n\n```\nquery{\n    customer(searchkey: \"na\"){\n        firstname\n        lastname\n    }\n}\n```\n\n```\nmutation{\n    createcustomer(firstname: \"Naresh\", lastname: \"Sekar\"){\n        id\n        createddate\n    }\n}\n```\n\n### Query Variable file\n\nIf a query is in need of variables that is to be passed, we need to create a JSON file under `graphql/variable` folder and have the query variables inside it. For static query variable directly mention the values inside the variable JSON file. For dynamic query variable (variable which will be given through feature file) give the dynamic variable name with prefix `$`.\n\n#### For static Query Variable\nFor static query variable following structure would be enough to automate.\n\nQuery:\n```\nquery($searchkey: String!){\n    customer(searchkey: $searchkey){\n        firstname\n        lastname\n    }\n}\n```\nVariable:\n```\n{\n    \"searchkey\": \"na\"\n}\n```\n\n#### For Dynamic Query Variable\nFor dynamic query variable one has to undergo the following steps to give the variable from feature file.\n\nQuery:\n```\nquery($searchkey: String!){\n    customer(searchkey: $searchkey){\n        firstname\n        lastname\n    }\n}\n```\nVariable:\n```\n{\n    \"searchkey\": \"$dynamicValueFromFeatureFile\"\n}\n```\nScenario Feature File:\n```\nScenario: Sample plain query automation\n    Given I set query variables\n        | configKey                     | configValue         |\n        | dynamicValueFromFeatureFile   | na                  |\n    When ...\n    Then ... \n```\nScenario Outline Feature File:\n```\nScenario Outline: Sample single query multi variable automation\n    Given I set query variables\n        | configKey                     | configValue         |\n        | dynamicValueFromFeatureFile   | \u003csearchKey\u003e         |\n    When ...\n    Then ... \n\n    Examples:\n        | searchKey |\n        | na        |\n        | ua        |\n        | ka        |\n```\nIn the above example, same query will run three times with the search key mentioned in the examples section. Thus reducing an ample amount of time in creating multiple query variable files for a single query.\n\n### Response file:\n\nCreate a response file under `graphql/expected_jsons` folder and place the expected json for a query. Use this file in the feature file to compare and with the query response.\n\nFor Scenario Feature File:\n```\nGiven ...\nWhen ...\nThen I validated the response as against stored validated JSON data\n    | ExpectedJson      |\n    | sample            |\n```\n\nFor Scenario Outline feature file:\n```\nGiven ...\nWhen ...\nThen I validated the response as against stored validated JSON data\n    | ExpectedJson      |\n    | \u003cresponse_file\u003e   |\n\nExamples:\n    | response_file |\n    | sample        |\n    | sample1       |\n    | sample2       |\n```\n\n## Defining the feature file:\n\nOnce Query, Variable and Response files are created, we need to start defining the feature file. No code is involded here, just mapping of query file, variable file and the response file. In addition to that some of the additional steps are added.\n\nSimple Scenario:\n```\nScenario: Simple query only scenario\n    When I execute the query \"sample query\"\n        | Query    |\n        | sample   |\n    Then I validated the response as against stored validated JSON data\n        | ExpectedJson |\n        | sample       |\n```\n\nSimple Scenario with query and variable\n```\nScenario: Simple query with variable scenario\n    When I execute the query \"sample query\"\n        | Query    | QueryVariable |\n        | sample   | sample        |\n    Then I validated the response as against stored validated JSON data\n        | ExpectedJson |\n        | sample       |\n```\n\nScenario outline with query and variable scenario:\n```\nScenario Outline: Sample graphql query with query variable in scenario outline design\n    Given I set query variables\n        | configKey              | configValue         |\n        | dynamicvariable1       | \u003cdynamicvariable1\u003e  |\n    When I execute the query \"sample query\"\n        | Query    | QueryVariable |\n        | sample   | sample        |\n    Then I validated the response as against stored validated JSON data\n        | ExpectedJson      |\n        | \u003cexpected_json\u003e   |\n    \n    Examples:\n        | dynamicvariable1 | expected_json |\n        | var1             | sample1       |\n        | var2             | sample2       |\n        | var3             | sample3       |\n```\n\nScenario outline with query and variable and looping through with the value from the response scenario:\n```\nScenario Outline: Sample graphql query with query variable in scenario outline design\n    Given I set query variables\n        | configKey              | configValue         |\n        | dynamicvariable1       | \u003cdynamicvariable1\u003e  |\n    When I execute the query \"sample query\"\n        | Query    | QueryVariable |\n        | sample   | sample        |\n    Then I store the values from the response\n        | VariableName             | JsonPath                                  |\n        | dynamicvariable_runtime  | data,instruments,nodes,0,currency,isoCode |\n    Then I validated the response as against stored validated JSON data\n        | ExpectedJson      |\n        | \u003cexpected_json\u003e   |\n    \n    Examples:\n        | dynamicvariable1 | expected_json |\n        | var1             | sample1       |\n        | var2             | sample2       |\n        | var3             | sample3       |\n```\n\nScenario Outline with query, variable and validating response by ignoring some keys in the comparison:\n```\nScenario Outline: Sample graphql query with query variable in scenario outline design\n    Given I set query variables\n        | configKey              | configValue         |\n        | dynamicvariable1       | \u003cdynamicvariable1\u003e  |\n    When I execute the query \"sample query\"\n        | Query    | QueryVariable |\n        | sample   | sample        |\n    Then I store the values from the response\n        | VariableName             | JsonPath                                  |\n        | dynamicvariable_runtime  | data,instruments,nodes,0,currency,isoCode |\n    Then I ignore the few keys from comparison\n        | IgnoreKeys               |\n        | ignore_key1              |\n        | ignore_key2              |\n    Then I validated the response as against stored validated JSON data\n        | ExpectedJson      |\n        | \u003cexpected_json\u003e   |\n    \n    Examples:\n        | dynamicvariable1 | expected_json |\n        | var1             | sample1       |\n        | var2             | sample2       |\n        | var3             | sample3       |\n```\n\n## First time test case creation\n\nWhile creating the test cases for the first time, we no need to create the expected json file for all the cases. Just create Query file, Query Variable file and then draft the Scenario Outline and then run the test with `snap=1`, this will automatically create the expected JSON files in the `graphql/expected_jsons` folder. Review the changes and then commit.\n\nNote: Query added in this project structure is dummy query and the endpoint is also a mock one. Kindly try with your own query and endpoint.\n\n## Rakefile\n\nRakefile has been added to mail the report status once the run is completed. This will be useful once we integrate with CI and helpful in debugging which commit has caused the actual problem. For more details you could visit the [Rakefile](Rakefile). (Code refactoring is yet to be done in that file). In Jenkins you could get the following values as environment variables.\n\n```\n$BUILD_URL #Directly fetched from ENV variable\n$GIT_URL #Directly fetched from ENV variable\n$GIT_BRANCH #Directly fetched from ENV variable\n$GIT_COMMIT #Directly fetched from ENV variable\n$GIT_COMMITER_EMAIL=$(git --no-pager show -s --format='%ae' $GIT_COMMIT)\n$REPORTS_EMAIL_RECEIVERS=\"nareshnavinash@gmail.com;nareshsekar@zoho.com\" #Or can be taken from parameterized build\n\n#Run the rake task by,\nrake email[$BUILD_URL,$GIT_URL,$GIT_BRANCH,$GIT_COMMIT,$GIT_COMMITER_EMAIL,$REPORTS_EMAIL_RECEIVERS]\n```\n\n## Built With\n\n* [Cucumber](https://rubygems.org/gems/cucumber/versions/3.1.2) - Automation core framework\n* [Graphql_Client](https://github.com/github/graphql-client) - Client used to do Graphql actions\n* [Allure Cucumber](https://rubygems.org/gems/allure-cucumber/versions/0.6.1) - For Detailed reporting.\n\n## Contributing\n\n1. Clone the repo!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Create a pull request.\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on code of conduct, and the process for submitting pull requests.\n\n## Authors\n\n* **[Naresh Sekar](https://github.com/nareshnavinash)**\n\n## License\n\nThis project is licensed under the GNU GPL-3.0 License - see the [LICENSE](LICENSE) file for details\n\n## Acknowledgments\n\n* To all the open source contributors whose code has been referred in this project.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnareshnavinash%2FGraber-Ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnareshnavinash%2FGraber-Ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnareshnavinash%2FGraber-Ruby/lists"}