rspec_n 1.2.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d086a277cdeda572b3358f254048ed4e7efa7028
4
- data.tar.gz: b17c3463cece7279db187d9469c3ec280efe605b
2
+ SHA256:
3
+ metadata.gz: 0d531fc0cb07d13bf1700f6809c0566cc72dfe887af684b5493821a1d60e0956
4
+ data.tar.gz: 6bfe142183b285877bb067b1049bcc02139050d69ea123352904db52b34cfce7
5
5
  SHA512:
6
- metadata.gz: 3717ceab5cd0fe798eddacebcfc66ad1ceccad082bec1c15f0843ced97179df37ceff80d24c8ff0fc47b2079408d5ec02eebbae41746fe044212e35dc8a4c9e7
7
- data.tar.gz: 2f2b6d24ee1e683dd312554560e0c1af09aae7da2f3dd81741fa24ea939b66c66792720463d6fd0517c4ac8b9ac1c8c4446c2b741c4828ab2496674f3516ec31
6
+ metadata.gz: ab882b6d984ef3565d26c4d72357802a6daf058374c175e10b267f1bfcfb825e50f4ddcbda66d96dbebadeeecee7d4ac2f4c89d53276b217804436adbc300ef6
7
+ data.tar.gz: 681e5b4f42152b285174535231ef0d07054fefa57c9fcbabdc1e23ad466ebcf3d8e84dd5829afd8b91db733636fd9d6e50b5d4986d99493b17122a6406a8092b
@@ -0,0 +1,54 @@
1
+ # This workflow will download prebuilt Ruby versions, install dependencies and run checks against Pull Requests.
2
+
3
+ name: Check Pull Request
4
+ on:
5
+ pull_request:
6
+ branches: [ master ]
7
+ env:
8
+ # The pull request can have less than, or equal to, this number of rubocop issues and pass.
9
+ RUBOCOP_ISSUE_THRESHOLD: 5
10
+ jobs:
11
+ rspec:
12
+ name: Run RSpec
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.7', '3.0', '3.1']
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
26
+ - name: Execute rspec command
27
+ run: bundle exec rspec
28
+ rubocop:
29
+ name: Run Rubocop
30
+ runs-on: ubuntu-latest
31
+ strategy:
32
+ matrix:
33
+ ruby-version: ['2.7']
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - name: Set up Ruby
37
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
38
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby-version }}
42
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
43
+ - name: Execute rubo command
44
+ run: bundle exec rubo
45
+ - name: Evaluate rubo threshold
46
+ run: |
47
+ count=$(cat rubocop/total-violations-count.txt)
48
+ if [[ "$count" -gt $RUBOCOP_ISSUE_THRESHOLD ]]; then
49
+ echo "Failure: Found $count RuboCop issue(s). It must have $RUBOCOP_ISSUE_THRESHOLD or less. \
50
+ Run 'rubo' and resolve the issues listed in rubocop/style-issues.html"
51
+ exit 1
52
+ else
53
+ echo "Success: Found $count RuboCop issue(s), which is less than the limit of $RUBOCOP_ISSUE_THRESHOLD"
54
+ fi
data/.gitignore CHANGED
@@ -11,3 +11,5 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  Gemfile.lock
14
+
15
+ rspec_n_iteration.*
data/.rubocop.yml CHANGED
@@ -1,8 +1,21 @@
1
+ # DO NOT MODIFY THIS FILE unless you want to deviate from the rubocop_plus ruleset.
2
+
3
+ # This file defines the settings used by rubocop when it runs. You would normally add your customizations directly to this
4
+ # file, but this file has been pre configured to read settings out of the rubocop_plus gem instead.
5
+
6
+ # Tell rubocop to load its settings from the rubocop_plus gem.
7
+
1
8
  inherit_gem:
2
9
  rubocop_plus: config/rubocop.yml
3
10
 
11
+ # Place custom settings below this comment. All customizations will OVERRIDE rubocop_plus rules. rubocop_plus & rubocop
12
+ # do not attempt to merge these settings with their defaults. Long term changes should be ported to the rubocop_plus gem.
13
+
4
14
  AllCops:
5
- TargetRubyVersion: 2.3
15
+ TargetRubyVersion: 2.7
6
16
 
7
17
  Style/Documentation:
8
18
  Enabled: false
19
+
20
+ Rails:
21
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,29 +1,52 @@
1
1
  # CHANGELOG
2
2
 
3
- ## Next Release
3
+ Issues are tracked at https://github.com/roberts1000/rspec_n/issues. Issues marked as **(Internal)** only affect development.
4
4
 
5
- 1. (New) Add Gemfile usage instructions to the README. ([Issue #36](https://github.com/roberts1000/rspec_n/issues/36))
6
- 1. (New) Remove locking to a specify version of Ruby in development. ([Issue #41](https://github.com/roberts1000/rspec_n/issues/41))
7
- 1. (New) Use pry 0.12.x for development. ([Issue #43](https://github.com/roberts1000/rspec_n/issues/43))
8
- 1. (New) Stop `--order rand` from being added to the final command when a custom order is specified. ([Issue #38](https://github.com/roberts1000/rspec_n/issues/38))
5
+ ## 1.5.0 (Aug 28, 2022)
6
+
7
+ 1. [#87](../../issues/87): Add GitHub action workflow to check pull requests. **(Internal)**
8
+ 1. [#93](../../issues/93): Make Ruby 2.7.0 the min supported Ruby.
9
+ 1. [#97](../../issues/97): Add Ruby 3.1 support.
10
+
11
+ ## 1.4.0 (May 16, 2021)
12
+
13
+ 1. [#64](../../issues/64): Use `pry` `~> 0.14.0`. **(Internal)**
14
+ 1. [#66](../../issues/66): Update ruby & bundler versions in `.travis.yml`. **(Internal)**
15
+ 1. [#68](../../issues/68): Make Ruby 2.6.0 the minimum supported version.
16
+ 1. [#73](../../issues/73): Use `rake` `~> 13.0`. **(Internal)**
17
+ 1. [#78](../../issues/78): Require `Pathname`.
18
+ 1. [#83](../../issues/83): Use `rubocop_plus` `~> 2.0`. **(Internal)**
19
+
20
+ ## 1.3.0 (Jan 13, 2020)
21
+
22
+ 1. [#49](../../issues/49): Make `--order project` work.
23
+ 1. [#55](../../issues/55): Add `--dir` and `--timestamp` output options.
24
+ 1. [#57](../../issues/57): Redesign the `CHANGELOG.md`.
25
+
26
+ ## 1.2.2 (Jun 22, 2019)
27
+
28
+ 1. [#36](../../issues/36): Add instructions for installing `rspec_n` in project Gemfiles.
29
+ 1. [#38](../../issues/38): Stop `--order rand` from being added to the final command when a custom order is specified.
30
+ 1. [#41](../../issues/41): Remove locking to a specify version of Ruby in development. **(Internal)**
31
+ 1. [#43](../../issues/43): Use `pry` `0.12.x` for development. **(Internal)**
9
32
 
10
33
  ## 1.2.1 (Mar 06, 2019)
11
34
 
12
- 1. (Fix) Make `-v` and `--version` work again. ([Issue #30](https://github.com/roberts1000/rspec_n/issues/30))
35
+ 1. [#30](../../issues/30): Make `-v` and `--version` work again.
13
36
 
14
37
  ## 1.2.0 (Mar 03, 2019)
15
38
 
16
- 1. (New) Write the command that was used to run rspec_n to the output files. ([Issue #26](https://github.com/roberts1000/rspec_n/issues/26))
39
+ 1. [#26](../../issues/26): Write the command that was used to run rspec_n to the output files.
17
40
 
18
41
  ## 1.1.0 (Mar 03, 2019)
19
42
 
20
- 1. (New) Add **Result Counts** column which shows the result counts for each run (e.g. "400 examples, 2 failures, 3 pending"). ([Issue #19](https://github.com/roberts1000/rspec_n/issues/19))
21
- 1. (New) Allow an optional path argument, that is passed to RSpec, to target specs (e.g. `rspec_n 3 spec/features/example_spec.rb`, `rspec_n spec/features/example_spec.rb:5`, `rspec_n spec/features 4`). ([Issue #20](https://github.com/roberts1000/rspec_n/issues/20))
22
- 1. (New) Rename the `Result Counts` column to `Results` and remove the existing `Results` column. ([Issue #23](https://github.com/roberts1000/rspec_n/issues/23))
43
+ 1. [#19](../../issues/19): Add **Result Counts** column which shows the result counts for each run (e.g. "400 examples, 2 failures, 3 pending").
44
+ 1. [#20](../../issues/20): Accept an optional path argument, that is passed to RSpec, to target specs (e.g. `rspec_n 3 spec/features/example_spec.rb`, `rspec_n spec/features/example_spec.rb:5`, `rspec_n spec/features 4`).
45
+ 1. [#23](../../issues/23): Rename the `Result Counts` column to `Results` and remove the existing `Results` column.
23
46
 
24
47
  ## 1.0.0 (Feb 18, 2019)
25
48
 
26
- 1. (New) Add initial core logic. ([Issue #1](https://github.com/roberts1000/rspec_n/issues/1))
27
- 1. (New) Add initial CLI. ([Issue #4](https://github.com/roberts1000/rspec_n/issues/4))
28
- 1. (New) Write results of each iteration to a separate file. ([Issue #5](https://github.com/roberts1000/rspec_n/issues/5))
29
- 1. (New) Add `-s` option to stop on first failure. ([Issue #6](https://github.com/roberts1000/rspec_n/issues/6))
49
+ 1. [#1](../../issues/1): Add initial core logic.
50
+ 1. [#4](../../issues/4): Add initial CLI.
51
+ 1. [#5](../../issues/5): Write results of each iteration to a separate file.
52
+ 1. [#6](../../issues/6): Add `-s` option to stop on first failure.
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'rubocop_plus', "~> 1.0", require: false
7
+ gem 'rubocop_plus', '~> 2.0', require: false
8
8
  end
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2019 roberts1000
3
+ Copyright (c) 2021 roberts1000
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,32 +1,38 @@
1
1
  # rspec_n
2
2
 
3
- rspec_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 or flakiness issues in automated test suites.
3
+ rspec_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.
4
4
 
5
5
  ![example](https://user-images.githubusercontent.com/2053901/53691471-c6956880-3d4c-11e9-8248-68bbb4c24786.png)
6
6
 
7
- ## Version Strategy
7
+ ## Versioning Strategy
8
8
 
9
- Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html).
9
+ Releases are versioned using [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html) with the following caveats:
10
10
 
11
- ## Supported Rubies
11
+ 1. Support for Ruby versions, that reach EOL, can be removed in a major **or** minor release.
12
12
 
13
- Ruby 2.3.0+ is supported.
13
+ ## Supported Ruby Versions
14
+
15
+ Ruby 2.7, 3.0 and 3.1.
14
16
 
15
17
  ## Installation
16
18
 
17
- Install by executing
19
+ Install by executing:
18
20
 
19
21
  $ gem install rspec_n
20
22
 
21
- The gem will install an exectuable called `rspec_n` on your system. You may also want to add `rspec_n_iteration.*` to your `.gitignore` to exclude the output generated by rspec_n from your project's repo.
23
+ The gem will install an executable called `rspec_n`.
24
+
25
+ Add the following to your project's `.gitignore` to exclude the output generated by rspec_n from your project's repo:
26
+
27
+ rspec_n_iteration.*
22
28
 
23
- #### Using in a Gemfile
29
+ #### Usage in a Gemfile
24
30
 
25
- If you want to add rspec_n to your Gemfile, make sure you use the `require: false` option so rspec_n files aren't loaded into your application. rspec_n doesn't provide any runtime benefit to an app and requiring it will add unnecessary code to your project. Also, rspec_n is designed as a standalone commandline tool and isn't tested for compatibility inside other apps.
31
+ If 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 commandline tool and isn't tested for compatibility inside other apps.
26
32
 
27
- ```ruby
28
- gem 'rspec_n', require: false
29
- ```
33
+ ```ruby
34
+ gem 'rspec_n', require: false
35
+ ```
30
36
 
31
37
  ## Usage
32
38
 
@@ -34,70 +40,107 @@ The simplest way to run rspec_n is to give it a positive integer which tells it
34
40
 
35
41
  $ rspec_n 5
36
42
 
37
- As each iteration completes, output will be sent to the screen and dumped to a file. If you need to examine the detailed output of a run, it is available in the output files.
43
+ As iterations complete, summary output is sent to the screen and detailed output is written to files (in the project's root).
38
44
 
39
- You can also list one or more paths to target specs. You can do anything you would normally do when giving RSpec paths:
45
+ To target specific specs, provide one or more paths. You can do anything you would normally do when giving paths to RSpec:
40
46
 
41
47
  $ rspec_n 5 spec/path/to/something_spec.rb
42
48
  $ rspec_n 5 spec/path/to/folder spec/path/to/some/other/file_spec.rb
43
49
  $ rspec_n 5 spec/path/to/folder
44
50
  $ rspec_n 5 spec/path/to/something_spec.rb:5
45
51
 
46
- By default, `--order rand` is sent to RSpec to force it to run specs in random order. You can use a `defined` order if you don't want randomness:
52
+ By 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:
47
53
 
48
54
  $ rspec_n 5 --order defined
49
55
 
50
- Or, let the configuration files in the project determine the order:
56
+ Or, let the RSpec configuration in the project determine the order:
51
57
 
52
58
  $ rspec_n 5 --order project
53
59
 
60
+ #### Config file
61
+
62
+ You 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/* && bundle exec rspec"` won't.
63
+
64
+ Example file format:
65
+
66
+ ```
67
+ --no-file
68
+ -s
69
+ --order defined
70
+ -c "rm -rf tmp && bundle exec rspec"
71
+ ```
72
+
73
+ The config file can be multi line or single line.
74
+
54
75
  #### Automatic Command Selection
55
76
 
56
- rspec_n will inspect the files in your project and pick 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:
77
+ rspec_n inspects files in your project so it can pick 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:
57
78
 
58
79
  1. Ruby on Rails Applications: `DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:migrate && bundle exec rspec`.
59
80
  2. Everything else: `bundle exec rspec`.
60
81
 
61
- #### Use Custom Command to Start RSpec
82
+ #### Use a Custom Command to Start RSpec
62
83
 
63
- If you don't want rspec_n to automatically pick the best command, you can use the `-c` option and specify a command. The following example deletes the `tmp` folder before starting RSpec:
84
+ Use the `-c` option if you want to specify your own command. The following example deletes the `tmp` folder before starting RSpec:
64
85
 
65
86
  $ rspec_n 5 -c 'rm -rf tmp && bundle exec rspec'
66
87
 
67
- There are couple points to consider:
88
+ There are a couple points to consider:
68
89
 
69
- 1. Wrap your entire command in a single or double quoted string so rspec_n can acturately determine the command.
70
- 1. You can use the `&&` operator to join commands.
71
- 1. rspec_n was partially created to help discover flaky test suites so it will add `--order rand` to a custom command even if don't specify the order. You must explicitly use `--order defined` or `--order project` if you want something else.
90
+ 1. Wrap your entire command in a single or double quoted string.
91
+ 1. Use `&&` to create compound commands.
92
+ 1. Avoid trying to change test order within a custom command. rspec_n was created to help discover flaky test suites so it adds `--order rand` to your custom command. Use the `--order defined` or `--order project` options to the control the order.
72
93
 
73
94
  #### Control File Output
74
95
 
75
- rspec_n writes output for each iteration in a sequence of files `rspec_n_iteration.1`, `rspec_n_iteration.2`, etc... This saves you from having to rerun your test suite when you find a particular seed that causes your test suite to fail. If you want to disable this, add the `--no-file` option to the command.
96
+ rspec_n writes output for each iteration to files with the iteration number (`rspec_n_iteration.1`, `rspec_n_iteration.2`, etc...). If you want to disable this, add the `--no-file` option to the command.
76
97
 
77
98
  $ rspec_n 5 --no-file
78
99
 
79
- **Note:** rspec_n deletes all files matching `rspec_n_iteration.*` when it starts so be sure tomove those files to another location if you want to save them.
100
+ **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.
80
101
 
81
102
  #### Stop on First Failure
82
103
 
83
- You can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. Any remaining iterations will be skipped.
104
+ You can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. All remaining iterations are skipped.
84
105
 
85
106
  ## Understanding the Results
86
107
 
87
- rspec_n uses the STDOUT, STDERR and EXIT STATUS of the `rspec` command to figure out what to show in the **Results** column. The general results are determined by finding the line in RSpec's STDOUT that says `xyz examples, xyz failures, xyz pending`. rspec_n considers the run to be successful if RSpec returns an EXIT STATUS of 0 **regardless of any content in the STDERR stream**; it considers the run to be a failure if RSpec's EXIT STATUS > 0.
108
+ rspec_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` `> 0`.
109
+
110
+ There 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.
88
111
 
89
- There are times when RSpec's STDERR might have content, even though it returns an EXIT STATUS of 0. This frequently happens with deprecation notices and RSpec itself will pass the test suite in this situation. Unfortunately, it's not uncommon for code to write messages that look like errors to STDERR, but not actually raise an error and cause RSpec to fail a spec example. rspec_n reports this situation by adding a `(Warning)` label to the results to indicate there's something extra in the STDERR that you might want to investigate.
112
+ The 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`.
90
113
 
91
114
  ## Development
92
115
 
93
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for a Pry console, or `rake console` for an IRB console, that will allow you to experiment.
116
+ ### Setup
94
117
 
95
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
118
+ Install dependencies:
96
119
 
97
- ## Contributing
120
+ $ bin/setup
121
+
122
+ That's it!
123
+
124
+ ### Run Automated Tests
125
+
126
+ Run the automated test suite with:
127
+
128
+ $ rspec
98
129
 
99
- Bug reports and pull requests are welcome on GitHub at https://github.com/roberts1000/rspec_n.
130
+ ### Start a Console
131
+
132
+ Choose one of the following to start a console with the gem loaded:
133
+
134
+ ```bash
135
+ $ bin/console # for Pry
136
+ $ rake console # for IRB
137
+ ```
138
+
139
+ ## Contributing
100
140
 
101
- ## License
141
+ Contributions are welcome. Please us the following process when submitting work:
102
142
 
103
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
143
+ 1. 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.
144
+ 1. Fork the project.
145
+ 1. Create a branch. The name of the branch should start with the issue number that the branch will address.
146
+ 1. 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] `.
data/Rakefile CHANGED
@@ -5,7 +5,8 @@ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
7
 
8
+ desc "Start an irb console"
8
9
  task :console do
9
- # exec "pry -r rspec_n -I ./lib"
10
- exec "irb -r rspec_n -I ./lib"
10
+ exec "pry -r rspec_n -I ./lib"
11
+ # exec "irb -r rspec_n -I ./lib"
11
12
  end
data/bin/console CHANGED
@@ -6,8 +6,7 @@ require "rspec_n"
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- require "pry"
10
- Pry.start
9
+ # Run 'rake console' to start a pry console.
11
10
 
12
- # require "irb"
13
- # IRB.start(__FILE__)
11
+ require "irb"
12
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/exe/rspec_n CHANGED
@@ -15,19 +15,21 @@ lib = File.expand_path('../lib', __dir__)
15
15
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
16
16
 
17
17
  require "cri"
18
+ require "fileutils"
18
19
  require "rspec_n/version"
19
20
  require "rspec_n/constants"
21
+ require "rspec_n/helpers/arguments_helper"
20
22
  require "rspec_n/errors/bad_option"
21
23
 
22
24
  # rubocop:disable Metrics/BlockLength
23
25
  command = Cri::Command.define do
24
26
  usage 'rspec_n [iterations] [options]'
25
27
  description "rspec_n is an executable installed by the rspec_n Ruby gem. It provides a " \
26
- "way to re-run an RSpec test suite 'N' times, which is useful when determining " \
27
- "if a test suite is consistent.\n\n" \
28
- "STATUS CODES\n\n" \
29
- "0 - rspec_n ran successfully \u00A0\n" \
30
- "1 - problem with the commandline options \u00A0"
28
+ "way to re-run an RSpec test suite 'N' times, which is useful when determining " \
29
+ "if a test suite is consistent.\n\n" \
30
+ "STATUS CODES\n\n" \
31
+ "0 - rspec_n ran successfully \u00A0\n" \
32
+ "1 - problem with the commandline options \u00A0"
31
33
 
32
34
  flag :h, :help, 'show help' do |_value, cmd|
33
35
  puts cmd.help
@@ -35,12 +37,19 @@ command = Cri::Command.define do
35
37
  end
36
38
 
37
39
  command_description = "By default, rspec_n will guess the best command to run RSpec; " \
38
- "override it by setting a custom command; wrap the entire command in single or double quotes; " \
39
- "join multiple commands with '&&'"
40
+ "override it by setting a custom command; wrap the entire command in single or double quotes; " \
41
+ "join multiple commands with '&&'"
40
42
  option :c, :command, command_description, argument: :required
41
43
 
42
44
  flag nil, "no-file", "Do not write iteration output to files"
43
45
 
46
+ flag nil, "timestamp", "Write iteration output to a timestamped directory, which can " \
47
+ "prevent accidental loss. NOTE: It is up to the user to periodically clean up files."
48
+
49
+ command_description = "Write iteration output to files in the provided directory " \
50
+ "rather than the current working directory. Can be used along with the timestamp flag."
51
+ option :d, :dir, command_description, argument: :required
52
+
44
53
  flag :s, "stop-fast", "Stop when an iteration reports a failure."
45
54
 
46
55
  command_description =
@@ -63,7 +72,7 @@ end
63
72
  # rubocop:enable Metrics/BlockLength
64
73
 
65
74
  begin
66
- command.run(ARGV)
75
+ command.run(ArgumentsHelper.arguments)
67
76
  exit 0
68
77
  rescue RspecN::BadOption => e
69
78
  warn e.message.colorize(:red)
@@ -3,7 +3,7 @@ module RspecN
3
3
  DEFAULT_ITERATIONS = 10
4
4
  DEFAULT_COMMAND = 'bundle exec rspec'.freeze
5
5
  DEFAULT_RSPEC_STARTER_COMMAND = 'bin/start_rspec'.freeze
6
- # rubocop:disable Metrics/LineLength
6
+ # rubocop:disable Layout/LineLength
7
7
  DEFAULT_RAILS_COMMAND = 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:migrate && bundle exec rspec'.freeze
8
- # rubocop:enable Metrics/LineLength
8
+ # rubocop:enable Layout/LineLength
9
9
  end
@@ -6,7 +6,7 @@ module RspecN
6
6
  end
7
7
 
8
8
  def message
9
- allowed = RspecN::ALLOWED_ORDER_OPTIONS.collect { |val| "'" + val + "'" }
9
+ allowed = RspecN::ALLOWED_ORDER_OPTIONS.collect { |val| "'#{val}'" }
10
10
  "Order must be #{allowed.to_sentence}. '#{@details}' is not allowed.\n"
11
11
  end
12
12
  end
@@ -12,16 +12,19 @@ module RspecN
12
12
  end
13
13
 
14
14
  def delete_all_files
15
- Dir.glob("#{BASE_FILE_NAME}.**").each { |file| File.delete(file) }
15
+ log_directory = Pathname.new(@runner.input.log_path)
16
+ Dir.glob(log_directory.join("#{BASE_FILE_NAME}.**")).each { |file| File.delete(file) }
16
17
  end
17
18
 
18
19
  def write(run, command)
19
20
  return if run.skipped?
20
21
  return unless @runner.input.write_files?
21
22
 
22
- file_name = "#{BASE_FILE_NAME}.#{run.iteration}"
23
+ log_directory = Pathname.new(@runner.input.log_path)
24
+ FileUtils.mkdir_p(log_directory)
25
+ file_path = log_directory.join("#{BASE_FILE_NAME}.#{run.iteration}")
23
26
 
24
- File.open(file_name, "w") do |f|
27
+ File.open(file_path, "w") do |f|
25
28
  f.write("Iteration: #{run.iteration}\n")
26
29
  f.write("Start Time: #{run.formatted_start_time(@format)}\n")
27
30
  f.write("Finish Time: #{run.formatted_finish_time(@format)}\n")
@@ -62,7 +62,7 @@ module RspecN
62
62
  end
63
63
 
64
64
  def padded_header_column_labels
65
- columns.collect { |name, max_width| padded_header_column_label(name, max_width) }.join("")
65
+ columns.collect { |name, max_width| padded_header_column_label(name, max_width) }.join
66
66
  end
67
67
 
68
68
  def max_column_width_for(name)
@@ -92,10 +92,8 @@ module RspecN
92
92
 
93
93
  def result_color_symbol(run)
94
94
  case run.status_string
95
- when "Pass (Warnings)" then :green
96
- when "Pass" then :green
95
+ when "Pass", "Pass (Warnings)" then :green
97
96
  when "Fail" then :red
98
- when "Skip" then :yellow
99
97
  else :yellow
100
98
  end
101
99
  end
@@ -0,0 +1,26 @@
1
+ require 'shellwords'
2
+
3
+ class ArgumentsHelper
4
+ class << self
5
+ def arguments
6
+ if File.exist?(".rspec_n") && no_options_in_arguments?
7
+ options = read_options_from_file
8
+ if options.any?
9
+ print "Reading options from `.rspec_n` file\n"
10
+ return ARGV + options
11
+ end
12
+ end
13
+ ARGV
14
+ end
15
+
16
+ # Read arguments from the config file only if no arguments are provided by user
17
+ def no_options_in_arguments?
18
+ ARGV.grep(/^-/).empty? # Match args that start with - (or --). Those are the options.
19
+ end
20
+
21
+ # Options can be listed on a single line in the config file, or listed on separate lines.
22
+ def read_options_from_file
23
+ Shellwords.shellwords File.read(".rspec_n").to_s.gsub(/\n|\r\n/, " ")
24
+ end
25
+ end
26
+ end
@@ -1,7 +1,7 @@
1
1
  class String
2
2
  # https://stackoverflow.com/questions/39743299/check-if-a-string-contains-only-digits-in-ruby
3
3
  def all_digits?
4
- self =~ /\A\d+\z/ ? true : false
4
+ match?(/\A\d+\z/)
5
5
  end
6
6
 
7
7
  def remove_color
data/lib/rspec_n/input.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module RspecN
2
2
  class Input
3
- attr_accessor :iterations, :command, :stop_fast, :write_files
3
+ attr_accessor :iterations, :command, :stop_fast, :write_files, :log_path
4
+
4
5
  def initialize(options, args)
5
6
  @args = args
6
7
  @unprocessed_args_array = args.entries
@@ -12,6 +13,8 @@ module RspecN
12
13
  @command = determine_command
13
14
  @stop_fast = options.fetch(:"stop-fast", false)
14
15
  @write_files = !options.fetch(:'no-file', false)
16
+ @timestamp = options.fetch(:timestamp, false)
17
+ @log_path = determine_log_path
15
18
  end
16
19
 
17
20
  def write_files?
@@ -21,7 +24,8 @@ module RspecN
21
24
  private
22
25
 
23
26
  def validate_order
24
- return unless (order = @options.fetch(:order, nil))
27
+ order = @options.fetch(:order, nil)
28
+ return unless order
25
29
 
26
30
  raise BadOption, order unless RspecN::ALLOWED_ORDER_OPTIONS.include?(order)
27
31
  end
@@ -43,8 +47,8 @@ module RspecN
43
47
 
44
48
  def determine_command
45
49
  command = @options.fetch(:command, guessed_command)
46
- command += " " + @spec_path if @spec_path
47
- command += " --order " + @order if should_append_order?(command)
50
+ command += " #{@spec_path}" if @spec_path
51
+ command += " --order #{@order}" if should_append_order?(command)
48
52
  command
49
53
  end
50
54
 
@@ -66,7 +70,18 @@ module RspecN
66
70
  end
67
71
 
68
72
  def should_append_order?(command)
69
- command.match(/--order/).nil?
73
+ return false if @order == "project"
74
+
75
+ !command.include?("--order")
76
+ end
77
+
78
+ def determine_log_path
79
+ log_path = Pathname.new(@options.fetch(:dir, Dir.pwd))
80
+ return log_path unless @timestamp
81
+
82
+ directory_name = File.basename($PROGRAM_NAME)
83
+ directory_name << "-#{Time.now.getlocal.strftime('%Y%m%d%H%M%S%L')}"
84
+ log_path.join(directory_name)
70
85
  end
71
86
  end
72
87
  end
@@ -25,15 +25,15 @@ module RspecN
25
25
  end
26
26
 
27
27
  def total_passed
28
- @runs.values.select(&:passed?).size
28
+ @runs.values.count(&:passed?)
29
29
  end
30
30
 
31
31
  def total_failed
32
- @runs.values.select(&:failed?).size
32
+ @runs.values.count(&:failed?)
33
33
  end
34
34
 
35
35
  def total_skipped
36
- @runs.values.select(&:skipped?).size
36
+ @runs.values.count(&:skipped?)
37
37
  end
38
38
 
39
39
  private
@@ -1,3 +1,3 @@
1
1
  module RspecN
2
- VERSION = "1.2.2".freeze
2
+ VERSION = "1.5.0".freeze
3
3
  end
data/lib/rspec_n.rb CHANGED
@@ -3,6 +3,7 @@ require "rspec_n/version"
3
3
  require "colorize"
4
4
  require "cri"
5
5
  require "open3"
6
+ require "pathname"
6
7
 
7
8
  require "rspec_n/helpers/time_helpers"
8
9
  require "rspec_n/helpers/core_ext/array"
@@ -20,9 +21,9 @@ require "rspec_n/formatters/table_formatter"
20
21
  # Setup pry for development when running "rake console". Guard against load
21
22
  # errors in production (since pry is only loaded as a DEVELOPMENT dependency
22
23
  # in the .gemspec)
23
- # rubocop:disable Lint/HandleExceptions
24
+ # rubocop:disable Lint/SuppressedException
24
25
  begin
25
26
  require "pry"
26
27
  rescue LoadError
27
28
  end
28
- # rubocop:enable Lint/HandleExceptions
29
+ # rubocop:enable Lint/SuppressedException
data/rspec_n.gemspec CHANGED
@@ -2,7 +2,6 @@ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "rspec_n/version"
4
4
 
5
- # rubocop:disable Metrics/BlockLength
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "rspec_n"
8
7
  spec.version = RspecN::VERSION
@@ -22,7 +21,7 @@ Gem::Specification.new do |spec|
22
21
  spec.metadata["changelog_uri"] = "https://github.com/roberts1000/rspec_n/blob/master/CHANGELOG.md"
23
22
  else
24
23
  raise "RubyGems 2.0 or newer is required to protect against " \
25
- "public gem pushes."
24
+ "public gem pushes."
26
25
  end
27
26
 
28
27
  # Specify which files should be added to the gem when it is released.
@@ -33,14 +32,13 @@ Gem::Specification.new do |spec|
33
32
  spec.bindir = "exe"
34
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
34
  spec.require_paths = ["lib"]
36
- spec.required_ruby_version = '>= 2.3.0'
35
+ spec.required_ruby_version = '>= 2.7.0'
37
36
 
38
37
  spec.add_development_dependency "bundler", "~> 2.0"
39
- spec.add_development_dependency "pry", "~> 0.12.0"
40
- spec.add_development_dependency "rake", "~> 12.0"
38
+ spec.add_development_dependency "pry", "~> 0.14.0"
39
+ spec.add_development_dependency "rake", "~> 13.0"
41
40
  spec.add_development_dependency "rspec", "~> 3.0"
42
41
 
43
42
  spec.add_dependency "colorize", "~> 0.8.0"
44
43
  spec.add_dependency "cri", "~> 2.15.3"
45
44
  end
46
- # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - roberts1000
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-22 00:00:00.000000000 Z
11
+ date: 2022-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.0
33
+ version: 0.14.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.0
40
+ version: 0.14.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,10 +102,10 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".github/workflows/check_pull_request.yml"
105
106
  - ".gitignore"
106
107
  - ".rspec"
107
108
  - ".rubocop.yml"
108
- - ".travis.yml"
109
109
  - CHANGELOG.md
110
110
  - Gemfile
111
111
  - LICENSE.md
@@ -119,6 +119,7 @@ files:
119
119
  - lib/rspec_n/errors/bad_option.rb
120
120
  - lib/rspec_n/formatters/file_formatter.rb
121
121
  - lib/rspec_n/formatters/table_formatter.rb
122
+ - lib/rspec_n/helpers/arguments_helper.rb
122
123
  - lib/rspec_n/helpers/core_ext/array.rb
123
124
  - lib/rspec_n/helpers/core_ext/string.rb
124
125
  - lib/rspec_n/helpers/time_helpers.rb
@@ -142,15 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
143
  requirements:
143
144
  - - ">="
144
145
  - !ruby/object:Gem::Version
145
- version: 2.3.0
146
+ version: 2.7.0
146
147
  required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  requirements:
148
149
  - - ">="
149
150
  - !ruby/object:Gem::Version
150
151
  version: '0'
151
152
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.14
153
+ rubygems_version: 3.3.20
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: A ruby gem that runs RSpec N times.
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3.8
7
- - 2.4.5
8
- - 2.5.5
9
- - 2.6.3
10
- before_install: gem install bundler -v 2.0.2
11
- notifications:
12
- email:
13
- on_success: never # default: change
14
- on_failure: never # default: always