specbandit 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71f7dd0be00bb60fb8a8c09864f1f3a2545edea4e31efe8436065ef621bd0bac
4
- data.tar.gz: ec658ea6137ada721f37e2a1d31acffc1eba290045e58c83ab3e6dc80afe251d
3
+ metadata.gz: dd0cef232a7dfa2dd4109d150bd63dbdaac27f65c87e9a9c4a8c495678fdc8f0
4
+ data.tar.gz: c0a7505268abdc305f6d095fd75788ee5180c4e911972af8f95397bb57241358
5
5
  SHA512:
6
- metadata.gz: 0a9425785bbfb9a5fcad00c7cbd8c19c9050dbbd141d69c76e258fc0318105910378ef0bce4080a7af5963c8a3653ff6415666c6d920b56067acbd4f09ed4425
7
- data.tar.gz: 685376873d376c2f7763859b9c5c4d55dd2194684668386bf2cb6b0749baa1f59d9e0c00224b686ba8721c5e71afb1fd2814c86cad297f90f3a711c7c1dd0207
6
+ metadata.gz: 93c598ec5a9e0a542c0f86159ba3a70f7d7712b4c7f1c0bdf264cd9316363b483470986af3f6b619d326a52ce6d14cbd4c3ffff91e681d8c7eb7ddb8f1a2e150
7
+ data.tar.gz: 7974be5fd63f662d6db8a3b99cf00aeb7a0f75b0742c74a585c8cb7388686673507e2b23e0eb836cf1ec5c6b698585ef5eba0ec106b9436f6927409cbc59c85e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specbandit
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -116,10 +116,7 @@ module Specbandit
116
116
  end
117
117
 
118
118
  def run_rspec_batch(files)
119
- # Clear example state from previous batches so RSpec can run cleanly
120
- # in the same process. This preserves configuration but resets
121
- # the world (example groups, examples, shared groups, etc.).
122
- RSpec.clear_examples
119
+ reset_rspec_state
123
120
 
124
121
  args = files + rspec_opts
125
122
  err = StringIO.new
@@ -134,5 +131,33 @@ module Specbandit
134
131
  rspec_err = err&.string
135
132
  output.print(rspec_err) unless rspec_err.nil? || rspec_err.empty?
136
133
  end
134
+
135
+ # Reset RSpec state between batches so each batch runs cleanly.
136
+ #
137
+ # RSpec.clear_examples resets example groups, the reporter, filters, and
138
+ # the start-time clock -- but it leaves three critical pieces of state
139
+ # that cause cascading failures when running multiple batches in the
140
+ # same process:
141
+ #
142
+ # 1. output_stream -- After batch #1, Runner#configure sets
143
+ # output_stream to a StringIO. On batch #2+, the guard
144
+ # `if output_stream == $stdout` is permanently false, so the new
145
+ # `out` is never used. All RSpec output silently goes to the stale
146
+ # batch-1 StringIO.
147
+ #
148
+ # 2. wants_to_quit -- If any batch triggers a load error or fail-fast,
149
+ # this flag is set to true. On subsequent batches, Runner#setup
150
+ # returns immediately and Runner#run does exit_early -- specs are
151
+ # never loaded or run.
152
+ #
153
+ # 3. non_example_failure -- Once set, exit_code() unconditionally
154
+ # returns the failure exit code, even if all examples passed.
155
+ #
156
+ def reset_rspec_state
157
+ RSpec.clear_examples
158
+ RSpec.world.wants_to_quit = false
159
+ RSpec.world.non_example_failure = false
160
+ RSpec.configuration.output_stream = $stdout
161
+ end
137
162
  end
138
163
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specbandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferran Basora