{"id":14991267,"url":"https://github.com/roberts1000/rspec_n","last_synced_at":"2025-05-07T17:49:07.792Z","repository":{"id":45551728,"uuid":"170625026","full_name":"roberts1000/rspec_n","owner":"roberts1000","description":"A ruby gem that runs RSpec N times.","archived":false,"fork":false,"pushed_at":"2025-03-01T04:59:05.000Z","size":131,"stargazers_count":49,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-27T09:28:49.706Z","etag":null,"topics":["gem","rspec","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"","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/roberts1000.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-02-14T04:06:19.000Z","updated_at":"2025-03-01T04:59:07.000Z","dependencies_parsed_at":"2024-03-09T01:29:46.554Z","dependency_job_id":"fd7a9a2d-4b5e-4107-b7ba-b5debd7c13ac","html_url":"https://github.com/roberts1000/rspec_n","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberts1000%2Frspec_n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberts1000%2Frspec_n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberts1000%2Frspec_n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberts1000%2Frspec_n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roberts1000","download_url":"https://codeload.github.com/roberts1000/rspec_n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931218,"owners_count":21827102,"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":["gem","rspec","ruby","ruby-gem"],"created_at":"2024-09-24T14:22:03.655Z","updated_at":"2025-05-07T17:49:07.761Z","avatar_url":"https://github.com/roberts1000.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rspec_n\n\nrspec_n is a Ruby gem that makes it easy to run a project's RSpec test suite N times. You can customize the command that is used to start RSpec, or let rspec_n guess the best command (based on the files in your project). rspec_n is useful for finding repeatability issues in RSpec test suites.\n\n![example](https://user-images.githubusercontent.com/2053901/53691471-c6956880-3d4c-11e9-8248-68bbb4c24786.png)\n\n#### Automatic Command Selection\n\nrspec_n inspects files in your project and determines the best way to start RSpec. If it can't make an educated guess, it will use `bundle exec rspec` as the base command and add any extra information you've entered on the command line (like the order or paths). The following is a list of project types that rspec_n can identify and the associated commands it will try to execute:\n\n1. Ruby on Rails Applications: `DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load \u0026\u0026 bundle exec rspec`.\n2. Everything else: `bundle exec rspec`.\n\n**Note:** You can override this behavior by using the `-c` option, which lets you specify your own command. See the [Use a Custom Command to Start RSpec](#Use-a-Custom-Command-to-Start-RSpec) section for more info.\n\n## Versioning Strategy\n\nReleases are versioned using [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html) with the following caveats:\n\n1. Support for Ruby versions, that reach EOL, can be removed in a major **or** minor release.\n\n## Supported Ruby Versions\n\nRuby 3.1+ is supported.\n\n## Installation\n\nInstall by executing:\n\n    $ gem install rspec_n\n\nThe gem will install an executable called `rspec_n`.\n\nAdd the following to your project's `.gitignore` to exclude the output generated by rspec_n from your project's repo:\n\n    rspec_n_iteration.*\n\n#### Usage in a Gemfile\n\nIf you add rspec_n to your Gemfile, use the `require: false` option so rspec_n isn't loaded into your app. rspec_n doesn't provide any runtime benefit to apps and requiring it will add unnecessary code to your project. Also, rspec_n is designed as a standalone command line tool and isn't tested for compatibility inside other apps.\n\n```ruby\ngem 'rspec_n', require: false\n```\n\n## Usage\n\n### Considerations\n\n#### Ruby on Rails\n\n1. By default, rspec_n will attempt to prepare the test database by executing the following code **before each run**:\n\n    ```\n    DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load rake db:drop db:create db:schema:load\n    ```\n    \n    1. `DISABLE_DATABASE_ENVIRONMENT_CHECK=1` disables a Rails check that can prevent the test database from being dropped.\n    1. Since `db:schema:load` is used to prepare the test database, projects must have a correct `schema.rb` or `structure.sql`.\n1. By default, rspec_n tries to ensure an empty database **before each run** so it does not load seed files. If your test suite depends on seeded data, or other special setup, you will need to specify the exact command that rspec_n uses to invoke each run. See the [Use a Custom Command to Start RSpec](#Use-a-Custom-Command-to-Start-RSpec) section for more info.\n\n### Basic Usage\n\nThe simplest way to run rspec_n is to give it a positive integer which tells it how many times to run RSpec:\n\n    $ rspec_n 5\n\nAs iterations complete, summary output is sent to the screen and detailed output is written to files (in the project's root).\n\nTo target specific specs, provide one or more paths. You can do anything you would normally do when passing paths to RSpec:\n\n    $ rspec_n 5 spec/path/to/something_spec.rb\n    $ rspec_n 5 spec/path/to/folder spec/path/to/some/other/file_spec.rb\n    $ rspec_n 5 spec/path/to/folder\n    $ rspec_n 5 spec/path/to/something_spec.rb:5\n\nBy default, `--order rand` is always sent to RSpec to force it to run specs in random order. You can use a `defined` order if you don't want randomness:\n\n    $ rspec_n 5 --order defined\n\nOr, let the RSpec configuration in the project determine the order:\n\n    $ rspec_n 5 --order project\n\n### Use a Custom Command to Start RSpec\n\nUse the `-c` option if you want to specify your own command. The following example deletes the `tmp` folder before starting RSpec:\n\n    $ rspec_n 5 -c 'rm -rf tmp \u0026\u0026 bundle exec rspec'\n\nThere are a couple points to consider:\n\n1. Wrap your entire command in a single or double quoted string.\n1. Use `\u0026\u0026` to create compound commands.\n1. rspec_n was created to help discover flaky test suites so it will add `--order rand` to your custom command (which gets passed to RSpec and causes RSpec to run tests randomly). If you need to change the test order, you must add the `--order defined` or `--order project` options to the control the order like this:\n\n    ```\n    $ rspec_n 5 -c 'rm -rf tmp \u0026\u0026 bundle exec rspec' --order defined\n    ```\n   \n### Control the File Output\n\nrspec_n writes output to the project's root folder, for each iteration, to files with the iteration number in the name (`rspec_n_iteration.1`, `rspec_n_iteration.2`, etc...). If you want to disable this, add the `--no-file` option to the command.\n\n    $ rspec_n 5 --no-file\n\n**Note:** rspec_n deletes all files matching `rspec_n_iteration.*` when it starts, so be sure to move those files to another location if you want to save them.\n\n### Stop on First Failure\n\nYou can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. All remaining iterations are skipped.\n\n### Run Specs in Parallel\n\nrspec_n doesn't directly support running specs in parallel, however, you should be able to use the `-c` option to pass a rspec_n the command you use to run parallel specs.\n\n## Configuration\n\nYou can create a `.rspec_n` file in your project's root and add command line options to it. They'll be used if `rspec_n` is run without options. Options are any arguments that start with `-` or `--`. For example, `rspec_n 10` or `rspec_n 10 spec/some_spec.rb` will make rspec_n consider `.rspec_n`, but `rspec_n 10 -c \"rm -rf /tmp/* \u0026\u0026 bundle exec rspec\"` won't.\n\nExample file format:\n\n```text\n--no-file\n-s\n--order defined\n-c \"rm -rf tmp \u0026\u0026 bundle exec rspec\"\n```\n\nThe config file can be multi line or single line.\n\n## Understanding the Results\n\nrspec_n uses the `STDOUT`, `STDERR` and `EXIT STATUS` of the `rspec` command to decide if the run passed or failed. The run is considered successful if RSpec returns an `EXIT STATUS` of `0` **regardless of any content in the STDERR stream**. rspec_n considers the run to be a failure if RSpec's `EXIT STATUS` `\u003e 0`.\n\nThere are times when `STDERR` has content, even though RSpec returns an `EXIT STATUS` of `0`. This frequently happens with deprecation notices and RSpec itself will pass the test suite in this situation. Also, it's not uncommon for code to write messages to `STDERR` that look like errors, but not actually cause RSpec to fail a spec example. If rspec_n is able to detect this situation, it adds `(Warning)` to the results to indicate there's something extra in the `STDERR` that you might want to investigate.\n\nThe results of each run (number of tests, number of failures, etc...) are determined by parsing `STDOUT` and extracting information from the line that says `xyz examples, xyz failures, xyz pending`.\n\n## Development\n\n### Setup\n\nInstall dependencies:\n\n    $ bin/setup\n\nThat's it!\n\n### Run Automated Tests\n\nRun the automated test suite with:\n\n    $ rspec\n\n### Start a Console\n\nChoose one of the following to start a console with the gem loaded:\n\n```bash\n$ bin/console  # for Pry\n$ rake console # for IRB\n```\n\n## Contributing\n\nContributions are welcome. Please us the following process when submitting work:\n\n1. Create an issue on the [issue page](https://github.com/roberts1000/rspec_n/issues) that targets a single problem/enhancement. All PRs should be tied to an issue.\n1. Fork the project.\n1. Create a branch. The name of the branch should start with the issue number that the branch will address.\n1. Submit the PR. In the PR comment (in the UI), add `Closes #xyz` or `Supports #xyz` where `xyz` is the issue number that the PR addresses. The title of the PR (in the UI) should start with `[PR for #xyz] `.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froberts1000%2Frspec_n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froberts1000%2Frspec_n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froberts1000%2Frspec_n/lists"}