Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Create Tests automatically from a Requests file. Perfect to be used with the result from importing a Swagger file using the open_api_import gem. Now we are supporting RSpec.
More info about the Request Hashes: https://github.com/MarioRuiz/Request-Hash
If you want to know how to import Swagger / Open API files in just a couple of seconds and transform them into Request Ruby Hashes: https://github.com/MarioRuiz/open_api_import
We strongly recommend to use nice_http gem for your tests: https://github.com/MarioRuiz/nice_http
Install it yourself as:
$ gem install create_tests
Take in consideration create_tests gem is using the 'rufo' gem that executes in command line the rufo
command. In case you experience any trouble with it, visit: https://github.com/ruby-formatter/rufo
After installation you can run using command line executable or just from Ruby.
The execution will create an spec folder where you will have all the RSpec tests. Also it will be added to that file a helper.rb
file.
Also a settings
folder that will contain a general.rb
file that will be required by the tests.
For help and see the options, run in command line / bash: create_tests -h
Example:
create_tests ./requests/uber.yaml.rb
Write your ruby code on a file and in command line/bash: ruby my_file.rb
This is an example:
require 'create_tests'
CreateTests.from "./requests/uber.yaml.rb"
On this example we will be creating tests for the Uber API using the Swagger / Open API file.
Create a folder in your computer called for example create_tests_example
Copy the file that we have on ./example/requests/uber.yaml
into a folder called requests
inside create_tests_example folder
.
First we will convert this Swagger file into Requests Hashes by running from create_tests_example
folder:
open_api_import ./requests/uber.yaml -fT
Now all the Request files were created on the requests
folder:
** Generated files that contain the code of the requests after importing the Swagger file:
- requests/uber.yaml_Products.rb
- requests/uber.yaml_Estimates.rb
- requests/uber.yaml_User.rb
** File that contains all the requires for all Request files:
- requests/uber.yaml.rb
create_tests ./requests/uber.yaml.rb
spec
folder, and a general.rb
file inside settings
folder was created and also take a look at your helper.rb
file on spec
folder.- Logs: ./requests/uber.yaml.rb_create_tests.log
** Pay attention, if any of the test files exist or the help file exist only will be added the tests, methods that are missing.
- Settings: ./settings/general.rb
- Test created: ./spec/User/profile_user_spec.rb
- Test created: ./spec/User/activity_user_spec.rb
- Test created: ./spec/Products/list_products_spec.rb
- Test created: ./spec/Estimates/price_estimates_spec.rb
- Test created: ./spec/Estimates/time_estimates_spec.rb
- Helper: ./spec/helper.rb
You can see a reproduction of what we did before on here: https://github.com/MarioRuiz/create_tests/tree/master/example
The parameters can be supplied alone or with other parameters. In case a parameter is not supplied then it will be used the default value.
Accepts three different options: :overwrite, :dont_overwrite and :append. By default :append.
append: In case the test file already exists will be only adding those tests that are missing from that file. If the test file doesn't exist, will be created and added all tests.
dont_overwrite: In case the test file exists any change will be done. If it doesn't exist then it will be created.
overwrite: In case the file exist you will loose the current code and a new code will be created. Take in consideration that all previous content will be deleted. If it doesn't exist the test file then it will be created.
require 'create_tests'
CreateTests.from "./requests/uber.yaml.rb", mode: :overwrite
Bug reports and pull requests are welcome on GitHub at https://github.com/marioruiz/create_tests.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that create_tests demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.