rspec_n 1.1.0 → 1.4.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: 02e086ee01e65f0ac9e1352f77e8ed372a999284
4
- data.tar.gz: 9a2b8f3caaf24bb2812dd8f90520df1edf5ab6e3
2
+ SHA256:
3
+ metadata.gz: 7fa5af32a552646670769dd832d01ba4e1b4eaed5099048e2653fdb63936af16
4
+ data.tar.gz: 18a3426eebc20db6bbaa680b8653b3dd656f0f7e6e8889fc9be4fdc6825f8ee4
5
5
  SHA512:
6
- metadata.gz: 7f896ea775b492f458322bbffc031346e2cb5406e47d6d46103b1ddc251e9b632b4b733ba4ed8d44501da9501834869c7929fc1dccb9a230c1321d2dc2d501a5
7
- data.tar.gz: eb1ecd8d5a36d39572fec169a4997e347f3328496aab16960b3db7aab41f472d26ee7c02c91ecf8e7432b0effcb1b27c75276b89b24f4ab2728fd64a0efa404a
6
+ metadata.gz: ef6b53c0016bd508a7e025c05b5af63105ae5ff88d050aff494535ad039ab1fd9d12952cb601bb8f13f3fd2c6df9bee261127f1916831095d8da7bbfe3638af6
7
+ data.tar.gz: a7edc252c7d543200e6583c264dcc8a041a90fe45aa332df0ba5323a6db3155cad464a45f6d34252bc7f3eaa75855b72b3336628e52e16d8fdbafcca1e380a49
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,5 +1,11 @@
1
1
  inherit_gem:
2
2
  rubocop_plus: config/rubocop.yml
3
3
 
4
+ AllCops:
5
+ TargetRubyVersion: 2.6
6
+
4
7
  Style/Documentation:
5
8
  Enabled: false
9
+
10
+ Rails:
11
+ Enabled: false
data/.travis.yml CHANGED
@@ -3,5 +3,11 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 2.0.1
6
+ - 2.6
7
+ - 2.7
8
+ - 3.0
9
+ before_install: gem install bundler -v 2.2.17
10
+ notifications:
11
+ email:
12
+ on_success: never # default: change
13
+ on_failure: never # default: always
data/CHANGELOG.md CHANGED
@@ -1,14 +1,46 @@
1
1
  # CHANGELOG
2
2
 
3
+ Issues are tracked at https://github.com/roberts1000/rubocop_plus/issues. Changes marked as **(Internal)** support development/refactoring.
4
+
5
+ ## 1.4.0 (May 16, 2021)
6
+
7
+ 1. [#64](../../issues/64): Use `pry` `~> 0.14.0`. **(Internal)**
8
+ 1. [#66](../../issues/66): Update ruby & bundler versions in `.travis.yml`. **(Internal)**
9
+ 1. [#68](../../issues/68): Make Ruby 2.6 the minimum supported version.
10
+ 1. [#73](../../issues/73): Use `rake` `~> 13.0`. **(Internal)**
11
+ 1. [#78](../../issues/78): Require `Pathname`.
12
+ 1. [#83](../../issues/83): Use `rubocop_plus` `~> 2.0`. **(Internal)**
13
+
14
+ ## 1.3.0 (Jan 13, 2020)
15
+
16
+ 1. [#49](../../issues/49): Make `--order project` work.
17
+ 1. [#55](../../issues/55): Add `--dir` and `--timestamp` output options.
18
+ 1. [#57](../../issues/57): Redesign the `CHANGELOG.md`.
19
+
20
+ ## 1.2.2 (Jun 22, 2019)
21
+
22
+ 1. [#36](../../issues/36): Add instructions for installing `rspec_n` in project Gemfiles.
23
+ 1. [#38](../../issues/38): Stop `--order rand` from being added to the final command when a custom order is specified.
24
+ 1. [#41](../../issues/41): Remove locking to a specify version of Ruby in development. **(Internal)**
25
+ 1. [#43](../../issues/43): Use pry 0.12.x for development. **(Internal)**
26
+
27
+ ## 1.2.1 (Mar 06, 2019)
28
+
29
+ 1. [#30](../../issues/30): Make `-v` and `--version` work again.
30
+
31
+ ## 1.2.0 (Mar 03, 2019)
32
+
33
+ 1. [#26](../../issues/26): Write the command that was used to run rspec_n to the output files.
34
+
3
35
  ## 1.1.0 (Mar 03, 2019)
4
36
 
5
- 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))
6
- 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))
7
- 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))
37
+ 1. [#19](../../issues/19): Add **Result Counts** column which shows the result counts for each run (e.g. "400 examples, 2 failures, 3 pending").
38
+ 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`).
39
+ 1. [#23](../../issues/23): Rename the `Result Counts` column to `Results` and remove the existing `Results` column.
8
40
 
9
41
  ## 1.0.0 (Feb 18, 2019)
10
42
 
11
- 1. (New) Add initial core logic. ([Issue #1](https://github.com/roberts1000/rspec_n/issues/1))
12
- 1. (New) Add initial CLI. ([Issue #4](https://github.com/roberts1000/rspec_n/issues/4))
13
- 1. (New) Write results of each iteration to a separate file. ([Issue #5](https://github.com/roberts1000/rspec_n/issues/5))
14
- 1. (New) Add `-s` option to stop on first failure. ([Issue #6](https://github.com/roberts1000/rspec_n/issues/6))
43
+ 1. [#1](../../issues/1): Add initial core logic.
44
+ 1. [#4](../../issues/4): Add initial CLI.
45
+ 1. [#5](../../issues/5): Write results of each iteration to a separate file.
46
+ 1. [#6](../../issues/6): Add `-s` option to stop on first failure.
data/Gemfile CHANGED
@@ -1,10 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- ruby '2.3.7'
4
-
5
3
  # Specify your gem's dependencies in rspec_n.gemspec
6
4
  gemspec
7
-
8
- group :development do
9
- gem 'rubocop_plus', "~> 1.0", require: false
10
- end
data/README.md CHANGED
@@ -1,24 +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 automated test suites.
4
4
 
5
5
  ![example](https://user-images.githubusercontent.com/2053901/53691471-c6956880-3d4c-11e9-8248-68bbb4c24786.png)
6
6
 
7
- ## Version Policy
7
+ ## Version Strategy
8
8
 
9
9
  Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html).
10
10
 
11
- ## Supported Rubies
11
+ Ruby versions that reach EOL will be removed without a major version bump.
12
12
 
13
- Ruby 2.3.7+ is supported.
13
+ ## Supported Ruby Versions
14
+
15
+ Ruby 2.6.0+ is supported.
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.*
28
+
29
+ #### Usage in a Gemfile
30
+
31
+ If you want to add rspec_n to your Gemfile, use the `require: false` option so rspec_n files aren'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.
32
+
33
+ ```ruby
34
+ gem 'rspec_n', require: false
35
+ ```
22
36
 
23
37
  ## Usage
24
38
 
@@ -26,16 +40,16 @@ The simplest way to run rspec_n is to give it a positive integer which tells it
26
40
 
27
41
  $ rspec_n 5
28
42
 
29
- 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 each iteration completes, output is 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.
30
44
 
31
- You can also list one or more paths to target specs. You can do anything you would normally do when giving RSpec paths:
45
+ You can also list one or more paths to target specs. You can do anything you would normally do when giving RSpec paths:
32
46
 
33
47
  $ rspec_n 5 spec/path/to/something_spec.rb
34
48
  $ rspec_n 5 spec/path/to/folder spec/path/to/some/other/file_spec.rb
35
49
  $ rspec_n 5 spec/path/to/folder
36
50
  $ rspec_n 5 spec/path/to/something_spec.rb:5
37
51
 
38
- 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 sent to RSpec to force it to run specs in random order. You can use a `defined` order if you don't want randomness:
39
53
 
40
54
  $ rspec_n 5 --order defined
41
55
 
@@ -45,50 +59,76 @@ Or, let the configuration files in the project determine the order:
45
59
 
46
60
  #### Automatic Command Selection
47
61
 
48
- 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:
62
+ 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:
49
63
 
50
64
  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`.
51
65
  2. Everything else: `bundle exec rspec`.
52
66
 
53
67
  #### Use Custom Command to Start RSpec
54
68
 
55
- 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:
69
+ Use the `-c` option if you want to specify your own command. The following example deletes the `tmp` folder before starting RSpec:
56
70
 
57
71
  $ rspec_n 5 -c 'rm -rf tmp && bundle exec rspec'
58
72
 
59
73
  There are couple points to consider:
60
74
 
61
- 1. Wrap your entire command in a single or double quoted string so rspec_n can acturately determine the command.
62
- 1. You can use the `&&` operator to join commands.
63
- 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.
75
+ 1. Wrap your entire command in a single or double quoted string.
76
+ 1. Use the `&&` operator to join commands.
77
+ 1. rspec_n was created to help discover flaky test suites so it adds `--order rand` to your custom command by default. You must use `--order defined` or `--order project` if you want something else.
64
78
 
65
79
  #### Control File Output
66
80
 
67
- 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.
81
+ rspec_n writes output for each iteration in a sequence of files `rspec_n_iteration.1`, `rspec_n_iteration.2`, etc... If you want to disable this, add the `--no-file` option to the command.
68
82
 
69
83
  $ rspec_n 5 --no-file
70
84
 
71
- **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.
85
+ **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.
72
86
 
73
87
  #### Stop on First Failure
74
88
 
75
- You can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. Any remaining iterations will be skipped.
89
+ You can tell rspec_n to abort the first time an iteration fails by using the `-s` flag. All remaining iterations are skipped.
76
90
 
77
91
  ## Understanding the Results
78
92
 
79
- 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.
93
+ 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`.
80
94
 
81
- 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.
95
+ 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.
96
+
97
+ 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`.
82
98
 
83
99
  ## Development
84
100
 
85
- 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.
101
+ ### Setup
102
+
103
+ Install dependencies:
86
104
 
87
- 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).
105
+ $ bin/setup
106
+
107
+ That's it!
108
+
109
+ ### Run Automated Tests
110
+
111
+ Run the automated test suite with:
112
+
113
+ $ rake spec
114
+
115
+ ### Start a Console
116
+
117
+ Choose one of the following to start a conole with the gem loaded:
118
+
119
+ ```bash
120
+ $ bin/console # for Pry
121
+ $ rake console # for IRB
122
+ ```
88
123
 
89
124
  ## Contributing
90
125
 
91
- Bug reports and pull requests are welcome on GitHub at https://github.com/roberts1000/rspec_n.
126
+ Contributions are welcome. Please us the following process when submitting work:
127
+
128
+ 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.
129
+ 1. Fork the project.
130
+ 1. Create a branch. The name of the branch should start with the issue number that the branch will address.
131
+ 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] `.
92
132
 
93
133
  ## License
94
134
 
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ 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
10
  # exec "pry -r rspec_n -I ./lib"
10
11
  exec "irb -r rspec_n -I ./lib"
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,6 +15,8 @@ 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"
19
+ require "rspec_n/version"
18
20
  require "rspec_n/constants"
19
21
  require "rspec_n/errors/bad_option"
20
22
 
@@ -40,6 +42,13 @@ command = Cri::Command.define do
40
42
 
41
43
  flag nil, "no-file", "Do not write iteration output to files"
42
44
 
45
+ flag nil, "timestamp", "Write iteration output to a timestamped directory, which can " \
46
+ "prevent accidental loss. NOTE: It is up to the user to periodically clean up files."
47
+
48
+ command_description = "Write iteration output to files in the provided directory " \
49
+ "rather than the current working directory. Can be used along with the timestamp flag."
50
+ option :d, :dir, command_description, argument: :required
51
+
43
52
  flag :s, "stop-fast", "Stop when an iteration reports a failure."
44
53
 
45
54
  command_description =
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
@@ -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,20 +12,24 @@ 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
- def write(run)
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")
28
- f.write("Duration: #{convert_seconds_to_hms(run.duration_seconds)}\n\n")
31
+ f.write("Duration: #{convert_seconds_to_hms(run.duration_seconds)}\n")
32
+ f.write("Command: #{command}\n\n")
29
33
  f.write(run.rspec_stdout)
30
34
  f.write(run.rspec_stderr)
31
35
  end
@@ -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
@@ -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,9 @@ 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
50
+ command += " #{@spec_path}" if @spec_path
51
+ command += " --order #{@order}" if should_append_order?(command)
52
+ command
48
53
  end
49
54
 
50
55
  def guessed_command
@@ -63,5 +68,20 @@ module RspecN
63
68
  app_file_name = "config/application.rb"
64
69
  File.file?(app_file_name) && File.readlines(app_file_name).grep(/Rails::Application/).any?
65
70
  end
71
+
72
+ def should_append_order?(command)
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)
85
+ end
66
86
  end
67
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
@@ -55,7 +55,7 @@ module RspecN
55
55
  run.stop_clock
56
56
  @display_formatter.show_post_run_info(run)
57
57
  found_failure ||= run.failed?
58
- @file_formatter.write(run)
58
+ @file_formatter.write(run, @command)
59
59
  end
60
60
  end
61
61
 
@@ -1,3 +1,3 @@
1
1
  module RspecN
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
data/rspec_n.gemspec CHANGED
@@ -33,12 +33,13 @@ Gem::Specification.new do |spec|
33
33
  spec.bindir = "exe"
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
- spec.required_ruby_version = '>= 2.3.7'
36
+ spec.required_ruby_version = '>= 2.6.0'
37
37
 
38
38
  spec.add_development_dependency "bundler", "~> 2.0"
39
- spec.add_development_dependency "pry", "~> 0.11.2"
40
- spec.add_development_dependency "rake", "~> 12.0"
39
+ spec.add_development_dependency "pry", "~> 0.14.0"
40
+ spec.add_development_dependency "rake", "~> 13.0"
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "rubocop_plus", "~> 2.0"
42
43
 
43
44
  spec.add_dependency "colorize", "~> 0.8.0"
44
45
  spec.add_dependency "cri", "~> 2.15.3"
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.1.0
4
+ version: 1.4.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-03-03 00:00:00.000000000 Z
11
+ date: 2021-05-16 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.11.2
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.11.2
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
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop_plus
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: colorize
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,15 +156,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
144
158
  - !ruby/object:Gem::Version
145
- version: 2.3.7
159
+ version: 2.6.0
146
160
  required_rubygems_version: !ruby/object:Gem::Requirement
147
161
  requirements:
148
162
  - - ">="
149
163
  - !ruby/object:Gem::Version
150
164
  version: '0'
151
165
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.14
166
+ rubygems_version: 3.2.17
154
167
  signing_key:
155
168
  specification_version: 4
156
169
  summary: A ruby gem that runs RSpec N times.