{"id":18524441,"url":"https://github.com/stelligent/aws-int-test-rspec-helper","last_synced_at":"2025-04-09T11:32:03.517Z","repository":{"id":56842708,"uuid":"52028174","full_name":"stelligent/aws-int-test-rspec-helper","owner":"stelligent","description":"RSpec helper for doing AWS SDK integration testing","archived":false,"fork":false,"pushed_at":"2020-01-07T21:32:37.000Z","size":18,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-23T13:26:57.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stelligent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-18T18:17:14.000Z","updated_at":"2020-03-23T20:54:01.000Z","dependencies_parsed_at":"2022-08-29T12:40:40.611Z","dependency_job_id":null,"html_url":"https://github.com/stelligent/aws-int-test-rspec-helper","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Faws-int-test-rspec-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Faws-int-test-rspec-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Faws-int-test-rspec-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Faws-int-test-rspec-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stelligent","download_url":"https://codeload.github.com/stelligent/aws-int-test-rspec-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248026755,"owners_count":21035583,"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":[],"created_at":"2024-11-06T17:41:41.302Z","updated_at":"2025-04-09T11:32:02.729Z","avatar_url":"https://github.com/stelligent.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-int-test-rspec-helper\n\n## Description\n\nThis is just a little bit of code to help make integration testing AWS SDK code more convenient in RSpec. \n\nTo elaborate, it provides a method to create parameterised Cloudformation stacks from [cfndsl](https://github.com/stevenjack/cfndsl)\nspecifications in the course of an RSpec test.\n\nThe idea is to avoid having to write before/setup and after/cleanup code in AWS SDK that is just as complicated as the code under test\n(and to avoid the pain of JSON).\n\n## Usage\n\n1. To use it, (after installing the gem) first require it from your `spec_helper.rb`:\n\n        require 'aws-int-test-rspec-helper'\n\n2. Define a cfndsl stack (save as spec/cfndsl_test_templates/security_group_cfndsl.rb).  Note that `vpc_id` isn't defined yet.\n\n        CloudFormation {\n          Description 'Create a security group for int testing'\n        \n          EC2_SecurityGroup('securityGroup1') {\n            GroupDescription 'inttest Security Group'\n            VpcId vpc_id\n          }\n        \n          Output(:sgId1,\n                 Ref('securityGroup1'))\n        }\n\n3. Write your test:\n    \n        require 'awspec'\n        context 'security group exists' do\n          before(:all) do\n            @stack_name = stack(stack_name: 'securitygroupstack',\n                                path_to_stack: 'spec/cfndsl_test_templates/security_group_cfndsl.rb',\n                                bindings: { vpc_id: 'vpc-12345678' })\n          end\n        \n          it 'does something useful' do\n    \n            do_something stack_outputs['sgId']\n    \n            # make some kind of assertion about do_something\n            expect(security_group(stack_outputs['sgId'])).to_not be_opened\n          end\n        \n          after(:all) do\n            cleanup(@stack_name)\n          end\n        end\n\nThere are a few items of note in the test code:\n\n  * The `stack` method is called in the before block to create the necessary AWS resources\n  * The value of the `vpc_id` is passed in through the bindings argument\n  * The `path_to_stack` needs to line up with where the cfndsl was saved from step #2.\n  * The `stack_outputs` method is used to reference the created security group's id\n  * The expectation is using a library [awspec](https://github.com/k1LoW/awspec) to test the features of the security group.\n    It does a great job of insulating assertion code from the details of the AWS SDK, making it a bit more\n    declarative.\n  * The call to `cleanup` in the after removes the created stack\n  \n## LICENSE\n\nCopyright (c) 2016 Stelligent Systems LLC\n\nMIT LICENSE\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Faws-int-test-rspec-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstelligent%2Faws-int-test-rspec-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Faws-int-test-rspec-helper/lists"}