rspec_n 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +3 -0
- data/.github/workflows/check_pull_request.yml +2 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile +7 -0
- data/README.md +56 -30
- data/lib/rspec_n/constants.rb +1 -1
- data/lib/rspec_n/runner.rb +1 -1
- data/lib/rspec_n/version.rb +1 -1
- data/rspec_n.gemspec +2 -7
- metadata +7 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2a6b63db25d81b062d933b0f9db3ba46e9f858869c3a3d2d3274ab1f8a8666
|
4
|
+
data.tar.gz: a8821b81e6d853f588245792739b362ed10ed18bc64b56650e1ec0c923387867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9877b9317ef9dbda4a6c1c0806660276c6273a079cfe61206194dfc651b8b7dea7b33afc2a773c58fa2df70654b428f6da74c43e34e74b687b8fedc250cd7faa
|
7
|
+
data.tar.gz: 57c47323728e63b50c0a3d1530b3e6e3d99c39eb295838871cd57185652a62b017ab88579ddd291d8d38093bd2f46e0c636e3cc4beffb9478b6fa4136e877536
|
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version: ['
|
16
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
17
17
|
steps:
|
18
18
|
- uses: actions/checkout@v2
|
19
19
|
- name: Set up Ruby
|
@@ -30,7 +30,7 @@ jobs:
|
|
30
30
|
runs-on: ubuntu-latest
|
31
31
|
strategy:
|
32
32
|
matrix:
|
33
|
-
ruby-version: ['
|
33
|
+
ruby-version: ['3.0']
|
34
34
|
steps:
|
35
35
|
- uses: actions/checkout@v2
|
36
36
|
- name: Set up Ruby
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,21 @@
|
|
2
2
|
|
3
3
|
Issues are tracked at https://github.com/roberts1000/rspec_n/issues. Issues marked as **(Internal)** only affect development.
|
4
4
|
|
5
|
+
## 2.0.0 (Mar 08, 2024)
|
6
|
+
|
7
|
+
1. [#118](../../issues/118): Use `db:schema:load` to prepare databases instead of `db:migrate`.
|
8
|
+
|
9
|
+
## 1.6.0 (Feb 19, 2024)
|
10
|
+
|
11
|
+
1. [#105](../../issues/105): Use `colorize ~> 1.1.0`. **(Internal)**
|
12
|
+
1. [#108](../../issues/108): Remove Ruby 2.7 support.
|
13
|
+
1. [#110](../../issues/110): Add simple PR template.
|
14
|
+
1. [#112](../../issues/112): Add Ruby 3.2 support.
|
15
|
+
1. [#114](../../issues/114): Add Ruby 3.3 support.
|
16
|
+
|
5
17
|
## 1.5.0 (Aug 28, 2022)
|
6
18
|
|
19
|
+
1. [#53](../../issues/53): Add support for a config file.
|
7
20
|
1. [#87](../../issues/87): Add GitHub action workflow to check pull requests. **(Internal)**
|
8
21
|
1. [#93](../../issues/93): Make Ruby 2.7.0 the min supported Ruby.
|
9
22
|
1. [#97](../../issues/97): Add Ruby 3.1 support.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,15 @@ rspec_n is a Ruby gem that makes it easy to run a project's RSpec test suite N t
|
|
4
4
|
|
5
5
|
![example](https://user-images.githubusercontent.com/2053901/53691471-c6956880-3d4c-11e9-8248-68bbb4c24786.png)
|
6
6
|
|
7
|
+
#### Automatic Command Selection
|
8
|
+
|
9
|
+
rspec_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:
|
10
|
+
|
11
|
+
1. Ruby on Rails Applications: `DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load && bundle exec rspec`.
|
12
|
+
2. Everything else: `bundle exec rspec`.
|
13
|
+
|
14
|
+
**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.
|
15
|
+
|
7
16
|
## Versioning Strategy
|
8
17
|
|
9
18
|
Releases are versioned using [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html) with the following caveats:
|
@@ -12,7 +21,7 @@ Releases are versioned using [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html)
|
|
12
21
|
|
13
22
|
## Supported Ruby Versions
|
14
23
|
|
15
|
-
Ruby
|
24
|
+
Ruby 3.0+ is supported.
|
16
25
|
|
17
26
|
## Installation
|
18
27
|
|
@@ -28,7 +37,7 @@ Add the following to your project's `.gitignore` to exclude the output generated
|
|
28
37
|
|
29
38
|
#### Usage in a Gemfile
|
30
39
|
|
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
|
40
|
+
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 command line tool and isn't tested for compatibility inside other apps.
|
32
41
|
|
33
42
|
```ruby
|
34
43
|
gem 'rspec_n', require: false
|
@@ -36,13 +45,29 @@ gem 'rspec_n', require: false
|
|
36
45
|
|
37
46
|
## Usage
|
38
47
|
|
48
|
+
### Considerations
|
49
|
+
|
50
|
+
#### Ruby on Rails
|
51
|
+
|
52
|
+
1. By default, rspec_n will attempt to prepare the test database by executing the following code **before each run**:
|
53
|
+
|
54
|
+
```
|
55
|
+
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
|
56
|
+
```
|
57
|
+
|
58
|
+
1. `DISABLE_DATABASE_ENVIRONMENT_CHECK=1` disables a Rails check that can prevent the test database from being dropped.
|
59
|
+
1. Since `db:schema:load` is used to prepare the test database, projects must have a correct `schema.rb` or `structure.sql`.
|
60
|
+
1. 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.
|
61
|
+
|
62
|
+
### Basic Usage
|
63
|
+
|
39
64
|
The simplest way to run rspec_n is to give it a positive integer which tells it how many times to run RSpec:
|
40
65
|
|
41
66
|
$ rspec_n 5
|
42
67
|
|
43
68
|
As iterations complete, summary output is sent to the screen and detailed output is written to files (in the project's root).
|
44
69
|
|
45
|
-
To target specific specs, provide one or more paths. You can do anything you would normally do when
|
70
|
+
To target specific specs, provide one or more paths. You can do anything you would normally do when passing paths to RSpec:
|
46
71
|
|
47
72
|
$ rspec_n 5 spec/path/to/something_spec.rb
|
48
73
|
$ rspec_n 5 spec/path/to/folder spec/path/to/some/other/file_spec.rb
|
@@ -57,29 +82,7 @@ Or, let the RSpec configuration in the project determine the order:
|
|
57
82
|
|
58
83
|
$ rspec_n 5 --order project
|
59
84
|
|
60
|
-
|
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
|
-
|
75
|
-
#### Automatic Command Selection
|
76
|
-
|
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:
|
78
|
-
|
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`.
|
80
|
-
2. Everything else: `bundle exec rspec`.
|
81
|
-
|
82
|
-
#### Use a Custom Command to Start RSpec
|
85
|
+
### Use a Custom Command to Start RSpec
|
83
86
|
|
84
87
|
Use the `-c` option if you want to specify your own command. The following example deletes the `tmp` folder before starting RSpec:
|
85
88
|
|
@@ -89,20 +92,43 @@ There are a couple points to consider:
|
|
89
92
|
|
90
93
|
1. Wrap your entire command in a single or double quoted string.
|
91
94
|
1. Use `&&` to create compound commands.
|
92
|
-
1.
|
95
|
+
1. 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:
|
93
96
|
|
94
|
-
|
97
|
+
```
|
98
|
+
$ rspec_n 5 -c 'rm -rf tmp && bundle exec rspec' --order defined
|
99
|
+
```
|
100
|
+
|
101
|
+
### Control the File Output
|
95
102
|
|
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.
|
103
|
+
rspec_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.
|
97
104
|
|
98
105
|
$ rspec_n 5 --no-file
|
99
106
|
|
100
107
|
**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.
|
101
108
|
|
102
|
-
|
109
|
+
### Stop on First Failure
|
103
110
|
|
104
111
|
You can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. All remaining iterations are skipped.
|
105
112
|
|
113
|
+
### Run Specs in Parallel
|
114
|
+
|
115
|
+
rspec_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.
|
116
|
+
|
117
|
+
## Configuration
|
118
|
+
|
119
|
+
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.
|
120
|
+
|
121
|
+
Example file format:
|
122
|
+
|
123
|
+
```text
|
124
|
+
--no-file
|
125
|
+
-s
|
126
|
+
--order defined
|
127
|
+
-c "rm -rf tmp && bundle exec rspec"
|
128
|
+
```
|
129
|
+
|
130
|
+
The config file can be multi line or single line.
|
131
|
+
|
106
132
|
## Understanding the Results
|
107
133
|
|
108
134
|
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`.
|
data/lib/rspec_n/constants.rb
CHANGED
@@ -4,6 +4,6 @@ module RspecN
|
|
4
4
|
DEFAULT_COMMAND = 'bundle exec rspec'.freeze
|
5
5
|
DEFAULT_RSPEC_STARTER_COMMAND = 'bin/start_rspec'.freeze
|
6
6
|
# rubocop:disable Layout/LineLength
|
7
|
-
DEFAULT_RAILS_COMMAND = 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:
|
7
|
+
DEFAULT_RAILS_COMMAND = 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load && bundle exec rspec'.freeze
|
8
8
|
# rubocop:enable Layout/LineLength
|
9
9
|
end
|
data/lib/rspec_n/runner.rb
CHANGED
data/lib/rspec_n/version.rb
CHANGED
data/rspec_n.gemspec
CHANGED
@@ -32,13 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.bindir = "exe"
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
|
-
spec.required_ruby_version = '>=
|
35
|
+
spec.required_ruby_version = '>= 3.0'
|
36
36
|
|
37
|
-
spec.
|
38
|
-
spec.add_development_dependency "pry", "~> 0.14.0"
|
39
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
40
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
-
|
42
|
-
spec.add_dependency "colorize", "~> 0.8.0"
|
37
|
+
spec.add_dependency "colorize", "~> 1.1.0"
|
43
38
|
spec.add_dependency "cri", "~> 2.15.3"
|
44
39
|
end
|
metadata
CHANGED
@@ -1,85 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- roberts1000
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pry
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.14.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.14.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '13.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.0'
|
69
13
|
- !ruby/object:Gem::Dependency
|
70
14
|
name: colorize
|
71
15
|
requirement: !ruby/object:Gem::Requirement
|
72
16
|
requirements:
|
73
17
|
- - "~>"
|
74
18
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
19
|
+
version: 1.1.0
|
76
20
|
type: :runtime
|
77
21
|
prerelease: false
|
78
22
|
version_requirements: !ruby/object:Gem::Requirement
|
79
23
|
requirements:
|
80
24
|
- - "~>"
|
81
25
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
26
|
+
version: 1.1.0
|
83
27
|
- !ruby/object:Gem::Dependency
|
84
28
|
name: cri
|
85
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +46,7 @@ executables:
|
|
102
46
|
extensions: []
|
103
47
|
extra_rdoc_files: []
|
104
48
|
files:
|
49
|
+
- ".github/pull_request_template.md"
|
105
50
|
- ".github/workflows/check_pull_request.yml"
|
106
51
|
- ".gitignore"
|
107
52
|
- ".rspec"
|
@@ -143,14 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
88
|
requirements:
|
144
89
|
- - ">="
|
145
90
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
91
|
+
version: '3.0'
|
147
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
93
|
requirements:
|
149
94
|
- - ">="
|
150
95
|
- !ruby/object:Gem::Version
|
151
96
|
version: '0'
|
152
97
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
98
|
+
rubygems_version: 3.5.6
|
154
99
|
signing_key:
|
155
100
|
specification_version: 4
|
156
101
|
summary: A ruby gem that runs RSpec N times.
|