rspec-interactive 0.9.3 → 0.9.6

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: ca3d9ea9bc7a43930a9d3400a30b1c9d0bb06cc6691b70340966c8543b830646
4
- data.tar.gz: 6f22c4c95eb720509cabb7cd3edd18277b1b68f96bdca32ab7f55ff6197c3e11
3
+ metadata.gz: 448fb430c0970d2d6f3dc12a3a1b6577dde234516d0d7f3fdccc735be784919b
4
+ data.tar.gz: 650d41f575295fb43d1c97930ae49e4a7fe34aac1d4cb1ca2a7d3fe6a1cb25c6
5
5
  SHA512:
6
- metadata.gz: f39caa7d3669358769a1aa5f8c901bfbfafbef2d9e5854e14a3331f87bfb5065cf42c3609dcb5d84940371811ae35b6168ed46effa99da032e9d4dae8e0a85d0
7
- data.tar.gz: 426d3c1feaec48508dfc48712914c40e278641c669a789b9902fa8a307c3ac349ed4cb580b008be8527d664cde94865d5e33b127a21192bf872f91261f3a93bc
6
+ metadata.gz: d5a4b51199209d0d248e1fc26a2d7e3cb4abf993eb2a61775162eda5107a2a97529bdd58867cb1e870a9c10f9da7c3ef60ce0ccd4ad484f6f900f9c2b0708a6f
7
+ data.tar.gz: f57523af399e9ca55303101479fbc0940c60095a0ffe93a2092255954fe5be3003bfc82c41c7a416df72a12d72fd4aae0d578b5d7f6da85c1385a9f620950227
data/.gitignore CHANGED
@@ -2,3 +2,5 @@ rspec-interactive-*.gem
2
2
  .rspec_interactive_history
3
3
  .rspec_interactive_config
4
4
  .idea
5
+ vendor
6
+ .bundle
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby '3.0.0'
4
-
5
3
  source "https://rubygems.org"
6
4
 
7
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-interactive (0.9.2)
4
+ rspec-interactive (0.9.5)
5
5
  listen
6
6
  pry
7
7
  rspec-core
@@ -13,6 +13,7 @@ GEM
13
13
  coderay (1.1.3)
14
14
  diff-lcs (1.4.4)
15
15
  ffi (1.15.5)
16
+ ffi (1.15.5-java)
16
17
  listen (3.7.1)
17
18
  rb-fsevent (~> 0.10, >= 0.10.3)
18
19
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -20,6 +21,10 @@ GEM
20
21
  pry (0.14.1)
21
22
  coderay (~> 1.1)
22
23
  method_source (~> 1.0)
24
+ pry (0.14.1-java)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
27
+ spoon (~> 0.0)
23
28
  rb-fsevent (0.11.1)
24
29
  rb-inotify (0.10.1)
25
30
  ffi (~> 1.0)
@@ -38,16 +43,16 @@ GEM
38
43
  rspec-support (3.9.4)
39
44
  rspec-teamcity (1.0.0)
40
45
  rspec (>= 2.99, >= 2.14.2, < 4)
46
+ spoon (0.0.6)
47
+ ffi
41
48
 
42
49
  PLATFORMS
50
+ universal-java-11
43
51
  x86_64-darwin-20
44
52
 
45
53
  DEPENDENCIES
46
54
  rspec-expectations
47
55
  rspec-interactive!
48
56
 
49
- RUBY VERSION
50
- ruby 3.0.0p0
51
-
52
57
  BUNDLED WITH
53
58
  2.2.17
@@ -6,7 +6,15 @@ module RSpec
6
6
  end
7
7
 
8
8
  def print(str = "")
9
- @client.print(str&.to_s || '')
9
+ @client.print(str.to_s)
10
+ end
11
+
12
+ def write(str = "")
13
+ @client.print(str.to_s)
14
+ end
15
+
16
+ def puts(str = "")
17
+ @client.print(str.to_s + "\n")
10
18
  end
11
19
 
12
20
  def string
@@ -1,10 +1,18 @@
1
1
  module RSpec
2
2
  module Interactive
3
3
  class Stdio
4
- def self.capture(output)
4
+ def self.capture2(stdout:, stderr:)
5
+ old_stdout, old_stderr = $stdout, $stderr
6
+ $stdout, $stderr = stdout, stderr
7
+ yield
8
+ ensure
9
+ $stdout, $stderr = old_stdout, old_stderr
10
+ end
11
+
12
+ def self.capture(stdout:, stderr:)
5
13
  raise ArgumentError, 'missing block' unless block_given?
6
14
 
7
- stdout, stderr = STDOUT.dup, STDERR.dup
15
+ old_stdout, old_stderr = STDOUT.dup, STDERR.dup
8
16
 
9
17
  IO.pipe do |stdout_read, stdout_write|
10
18
  IO.pipe do |stderr_read, stderr_write|
@@ -16,13 +24,13 @@ module RSpec
16
24
 
17
25
  stdout_thread = Thread.new do
18
26
  while line = stdout_read.gets do
19
- output.print(line)
27
+ stdout.print(line)
20
28
  end
21
29
  end
22
30
 
23
31
  stderr_thread = Thread.new do
24
32
  while line = stderr_read.gets do
25
- output.print(line)
33
+ stderr.print(line)
26
34
  end
27
35
  end
28
36
 
@@ -30,8 +38,8 @@ module RSpec
30
38
  yield
31
39
  ensure
32
40
  # TODO: should the threads be killed here?
33
- STDOUT.reopen stdout
34
- STDERR.reopen stderr
41
+ STDOUT.reopen old_stdout
42
+ STDERR.reopen old_stderr
35
43
  end
36
44
 
37
45
  stdout_thread.join
@@ -0,0 +1,23 @@
1
+ module RSpec
2
+ module Interactive
3
+ class StringOutput
4
+ attr_reader :string
5
+
6
+ def initialize
7
+ @string = ''
8
+ end
9
+
10
+ def write(name, str = "")
11
+ @string += str.to_s
12
+ end
13
+
14
+ def puts(str = "")
15
+ @string += str.to_s + "\n"
16
+ end
17
+
18
+ def print(str = "")
19
+ @string += str.to_s
20
+ end
21
+ end
22
+ end
23
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Interactive
5
- VERSION = "0.9.3"
5
+ VERSION = "0.9.6"
6
6
  end
7
7
  end
@@ -18,6 +18,7 @@ require 'rspec-interactive/rspec_core_example'
18
18
  require 'rspec-interactive/rubo_cop_command'
19
19
  require 'rspec-interactive/runner'
20
20
  require 'rspec-interactive/stdio'
21
+ require 'rspec-interactive/string_output'
21
22
 
22
23
  module RSpec
23
24
  module Interactive
@@ -56,35 +57,33 @@ module RSpec
56
57
  load config_file if config_file
57
58
 
58
59
  check_rails
59
- trap_interrupt
60
+ maybe_trap_interrupt
60
61
  configure_pry
61
62
 
62
- start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
63
- @config_cache.record_configuration { @configuration.configure_rspec.call }
64
- end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
65
- if end_time - start_time > 5
66
- @output_stream.puts "Configuring RSpec took #{(end_time - start_time).round} seconds."
67
- end
68
-
69
- start_file_watcher
63
+ @startup_thread = Thread.start do
64
+ @startup_output = StringOutput.new
65
+ Stdio.capture2(stdout: @startup_output, stderr: @startup_output) do
66
+ @config_cache.record_configuration { @configuration.configure_rspec.call }
67
+ start_file_watcher
68
+ end
70
69
 
71
- if server
72
- @output_stream.puts "Listening on port #{port}."
73
- server_thread = Thread.start do
74
- server = TCPServer.new port
70
+ if server
71
+ @server_thread = Thread.start do
72
+ server = TCPServer.new port
75
73
 
76
- while client = server.accept
77
- request = client.gets
78
- args = Shellwords.split(request)
79
- rspec_for_server(client, args)
80
- client.close
74
+ while client = server.accept
75
+ request = client.gets
76
+ args = Shellwords.split(request)
77
+ rspec_for_server(client, args)
78
+ client.close
79
+ end
81
80
  end
82
81
  end
83
82
  end
84
83
 
85
84
  Pry.start
86
85
  @listener.stop if @listener
87
- server_thread.exit if server_thread
86
+ @server_thread.exit if @server_thread
88
87
  0
89
88
  end
90
89
 
@@ -96,15 +95,17 @@ module RSpec
96
95
  end
97
96
  end
98
97
 
99
- def self.configure_rspec(error_stream: @error_stream, output_stream: @output_stream)
100
- RSpec.configure do |config|
101
- config.error_stream = error_stream
102
- config.output_stream = output_stream
103
- config.start_time = RSpec::Core::Time.now
104
- end
105
- end
98
+ def self.maybe_trap_interrupt
99
+ return unless RbConfig::CONFIG['ruby_install_name'] == 'jruby'
100
+
101
+ # When on JRuby, Pry traps interrupts and raises an Interrupt exception.
102
+ # Unfortunately, raising Interrupt is not enough when RSpec is running since it
103
+ # will only cause the current example to fail. We want to kill RSpec entirely
104
+ # if it is running so here we disable Pry's handling and rewrite it to include
105
+ # special handling for RSpec.
106
+
107
+ Pry.config.should_trap_interrupts = false
106
108
 
107
- def self.trap_interrupt
108
109
  trap('INT') do
109
110
  if @runner
110
111
  # We are on a different thread. There is a race here. Ignore nil.
@@ -128,9 +129,6 @@ module RSpec
128
129
  end
129
130
 
130
131
  def self.configure_pry
131
- # Prevent Pry from trapping too. It will break ctrl-c handling.
132
- Pry.config.should_trap_interrupts = false
133
-
134
132
  # Set up IO.
135
133
  Pry.config.input = Readline
136
134
  Pry.config.output = @output_stream
@@ -161,14 +159,24 @@ module RSpec
161
159
  end
162
160
 
163
161
  def self.parse_args(args)
164
- args.flat_map do |arg|
165
- if arg.match(/[\*\?\[]/)
166
- glob = Dir.glob(arg)
167
- glob.empty? ? [arg] : glob
162
+ i = 0
163
+ parsed_args = []
164
+ until i == args.length
165
+ case args[i]
166
+ when /[\*\?\[]/
167
+ glob = Dir.glob(args[i])
168
+ parsed_args.concat(glob.empty? ? args[i] : glob)
169
+ when '--pattern'
170
+ # RubyMine passes --pattern when running all specs in a dir.
171
+ # We don't want to expand this since it is used as a glob by RSpec.
172
+ parsed_args.concat(args[i..(i + 1)])
173
+ i += 1
168
174
  else
169
- [arg]
175
+ parsed_args << args[i]
170
176
  end
177
+ i += 1
171
178
  end
179
+ parsed_args
172
180
  end
173
181
 
174
182
  def self.rspec(args)
@@ -180,10 +188,15 @@ module RSpec
180
188
  Pry.config.history_save = false
181
189
 
182
190
  # RSpec::Interactive-specific RSpec configuration
183
- configure_rspec
191
+ RSpec.configure do |config|
192
+ config.error_stream = @error_stream
193
+ config.output_stream = @output_stream
194
+ config.start_time = RSpec::Core::Time.now
195
+ end
184
196
 
185
197
  # Run.
186
198
  exit_code = @runner.run
199
+ ensure
187
200
  @runner = nil
188
201
 
189
202
  # Reenable history
@@ -193,8 +206,6 @@ module RSpec
193
206
  RSpec.clear_examples
194
207
  RSpec.reset
195
208
  @config_cache.replay_configuration
196
- ensure
197
- @runner = nil
198
209
  end
199
210
 
200
211
  def self.rspec_for_server(client, args)
@@ -204,13 +215,17 @@ module RSpec
204
215
  ENV['DISABLE_PRY'] = 'true'
205
216
 
206
217
  output = ClientOutput.new(client)
207
- Stdio.capture(ClientOutput.new(client)) do
218
+ Stdio.capture(stdout: output, stderr: output) do
208
219
  @runner = RSpec::Interactive::Runner.new(parse_args(args))
209
220
 
210
221
  refresh
211
222
 
212
223
  # RSpec::Interactive-specific RSpec configuration
213
- configure_rspec
224
+ RSpec.configure do |config|
225
+ config.error_stream = @error_stream
226
+ config.output_stream = @output_stream
227
+ config.start_time = RSpec::Core::Time.now
228
+ end
214
229
 
215
230
  # RubyMine specifies --format. That causes a formatter to be added. It does not override
216
231
  # the existing formatter (if one is set by default). Clear any formatters but resetting
@@ -250,6 +265,17 @@ module RSpec
250
265
  else
251
266
  @command_mutex.synchronize do
252
267
  Thread.current.thread_variable_set('holding_lock', true)
268
+ if @startup_thread
269
+ if @startup_thread.alive?
270
+ @output_stream.puts 'waiting for configure_rspec...'
271
+ end
272
+ @startup_thread.join
273
+ @startup_thread = nil
274
+ unless @startup_output.string.empty?
275
+ @output_stream.puts(@startup_output.string)
276
+ end
277
+ @startup_output = nil
278
+ end
253
279
  yield
254
280
  ensure
255
281
  Thread.current.thread_variable_set('holding_lock', false)
data/runner/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # RSpec Interactive Runner
2
+
3
+ Use this directory as the working directory in RubyMine run configurations.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Dower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -102,11 +102,13 @@ files:
102
102
  - lib/rspec-interactive/rubo_cop_command.rb
103
103
  - lib/rspec-interactive/runner.rb
104
104
  - lib/rspec-interactive/stdio.rb
105
+ - lib/rspec-interactive/string_output.rb
105
106
  - lib/rspec-interactive/version.rb
106
107
  - lib/teamcity/spec/runner/formatter/teamcity/formatter.rb
107
108
  - rspec-interactive.gemspec
108
109
  - runner/Gemfile
109
110
  - runner/Gemfile.lock
111
+ - runner/README.md
110
112
  - runner/rspec-interactive-run
111
113
  - scripts/release.sh
112
114
  - scripts/run-with-local-dep.sh