rspec-interactive 0.9.10 → 0.9.13

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: 1e00d8b9955bf056a3967733d54b89fdece90829b006b7d831de803670e33295
4
- data.tar.gz: a5494e1160b97aa0b6c3e883e8457c5a6e6c2c54df1f26cd4d96c1ef15a4bbee
3
+ metadata.gz: 463e635fc01d274aaaa0857835637651842862761bda52cf9f91e3474754f2e3
4
+ data.tar.gz: 996b14c18d7c8d26446e6c0bac18b0c566952c78d2cba365346a716021fa9a95
5
5
  SHA512:
6
- metadata.gz: be9f403faf9fbfa42e38b0a07c70a4a338bc45cc6d9dc679e262653d3bc0a72d4ee1e15341b1693db3b51b0d2436da71b54525d22066fddd02d71a658c3ffb04
7
- data.tar.gz: 0f9c77f7d09b008164bf802fa5507b46d6bb43de0d37e5b8aadc414751d919dc9347bf37262b65503e617259e9414a41d6c2e8fa082f77c8328790177b21fad0
6
+ metadata.gz: 7c0ebae7aca82565ee027992003259a7abd4f1f0f049be0a1e8c31d382459f72eb9b3ea9b7000d8eddbe4236f47e036e442897e0a78558ee548946bb8de1cdd8
7
+ data.tar.gz: a1cae8c47176dd0f315335bbf8f63885653ae5f6e248aab2d885d9a38d6ee90124a5091dbfefa468b20c8307beeec7b4cc0f58202a2f0a5a473f2928cb5a9b63
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-interactive (0.9.9)
4
+ rspec-interactive (0.9.12)
5
5
  pry
6
6
  rspec-core
7
7
  rspec-teamcity (= 1.0.0)
@@ -11,6 +11,7 @@ GEM
11
11
  specs:
12
12
  coderay (1.1.3)
13
13
  diff-lcs (1.4.4)
14
+ ffi (1.15.5)
14
15
  ffi (1.15.5-java)
15
16
  method_source (1.0.0)
16
17
  pry (0.14.1)
@@ -5,7 +5,7 @@ require 'rspec-interactive'
5
5
 
6
6
  @options = {
7
7
  server: true,
8
- server_port: RSpec::Interactive::DEFAULT_PORT
8
+ port: RSpec::Interactive::DEFAULT_PORT
9
9
  }
10
10
 
11
11
  parser = OptionParser.new do |opts|
@@ -26,4 +26,4 @@ parser = OptionParser.new do |opts|
26
26
 
27
27
  end.parse!
28
28
 
29
- RSpec::Interactive.start(config_file: @options[:config_file], server: @options[:server], port: @options[:server_port])
29
+ RSpec::Interactive.start(config_file: @options[:config_file], server: @options[:server], port: @options[:port])
@@ -0,0 +1,22 @@
1
+ require 'rspec/core/option_parser'
2
+
3
+ # RSpec::Core::Parser calls abort on parse error. This kills the process.
4
+ # Here we replace abort so that it will raise instead.
5
+
6
+ # In some cases abort is called in response to an exception. If we simply raise,
7
+ # the original exception will be logged as the cause. This will lead to duplicate
8
+ # messaging. Here we define our own exception so that we can ensure no cause is
9
+ # logged.
10
+ class ParseError < StandardError
11
+ def cause
12
+ nil
13
+ end
14
+ end
15
+
16
+ module RSpec::Core
17
+ class Parser
18
+ def abort(msg)
19
+ raise ParseError.new(msg)
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Interactive
5
- VERSION = "0.9.10"
5
+ VERSION = "0.9.13"
6
6
  end
7
7
  end
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'pry'
4
4
  require 'readline'
5
5
  require 'rspec/core'
6
+ require 'set'
6
7
  require 'shellwords'
7
8
  require 'socket'
8
9
  require 'teamcity/spec/runner/formatter/teamcity/formatter'
@@ -15,6 +16,7 @@ require 'rspec-interactive/refresh_command'
15
16
  require 'rspec-interactive/rspec_command'
16
17
  require 'rspec-interactive/rspec_config_cache'
17
18
  require 'rspec-interactive/rspec_core_example'
19
+ require 'rspec-interactive/rspec_core_parser'
18
20
  require 'rspec-interactive/rubo_cop_command'
19
21
  require 'rspec-interactive/runner'
20
22
  require 'rspec-interactive/stdio'
@@ -63,9 +65,15 @@ module RSpec
63
65
 
64
66
  @startup_thread = Thread.start do
65
67
  Thread.current.report_on_exception = false
68
+
66
69
  if server
67
70
  @server_thread = Thread.start do
68
- server = TCPServer.new port
71
+ begin
72
+ server = TCPServer.new port
73
+ rescue StandardError => e
74
+ log_exception(@output_stream, e)
75
+ exit 1
76
+ end
69
77
 
70
78
  while true
71
79
  break unless client = server.accept
@@ -90,9 +98,12 @@ module RSpec
90
98
  @startup_output = StringOutput.new
91
99
  output = ThreadedOutput.new(thread_map: { Thread.current => @startup_output }, default: @output_stream)
92
100
 
101
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
93
102
  Stdio.capture(stdout: output, stderr: output) do
94
103
  @config_cache.record_configuration { @configuration.configure_rspec.call }
95
104
  end
105
+ finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
106
+ @startup_duration = (finish - start).round
96
107
  end
97
108
 
98
109
  Pry.start
@@ -287,13 +298,23 @@ module RSpec
287
298
  def self.await_startup(output: @output_stream)
288
299
  return true unless @startup_thread
289
300
 
301
+ waited = false
290
302
  if @startup_thread.alive?
291
303
  output.puts 'waiting for configure_rspec...'
304
+ waited = true
292
305
  end
293
306
 
294
307
  begin
295
308
  @startup_thread.join
296
309
  @startup_thread = nil
310
+ if waited
311
+ if @startup_duration == 1
312
+ output.puts("configure_rspec took 1 second")
313
+ else
314
+ output.puts("configure_rspec took #{@startup_duration} seconds")
315
+ end
316
+ end
317
+
297
318
  print_startup_output(output: output)
298
319
  true
299
320
  rescue Interrupt
@@ -312,9 +333,11 @@ module RSpec
312
333
  end
313
334
 
314
335
  def self.print_startup_output(output: @output_stream)
315
- return if @startup_output.nil? || @startup_output.string.empty?
336
+ return if @startup_output.nil?
316
337
 
317
- output.puts(@startup_output.string)
338
+ unless @startup_output.string.empty?
339
+ output.puts(@startup_output.string)
340
+ end
318
341
  @startup_output = nil
319
342
  end
320
343
 
@@ -0,0 +1,17 @@
1
+ require_relative 'support/test_helper'
2
+
3
+ Test.test "parse error" do
4
+ await_prompt
5
+ input "rspec --foo"
6
+ await_prompt
7
+ input "exit"
8
+ await_termination
9
+ expect_equal "output", output.gsub(/^from .*lib\/rspec-interactive/, 'from [...]'), <<~EOF
10
+ [1] pry(main)> rspec --foo
11
+ ParseError: invalid option: --foo
12
+
13
+ Please use --help for a listing of valid options
14
+ from [...]/rspec_core_parser.rb:19:in `abort'
15
+ [1] pry(main)> exit
16
+ EOF
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Dower
@@ -85,6 +85,7 @@ files:
85
85
  - lib/rspec-interactive/rspec_command.rb
86
86
  - lib/rspec-interactive/rspec_config_cache.rb
87
87
  - lib/rspec-interactive/rspec_core_example.rb
88
+ - lib/rspec-interactive/rspec_core_parser.rb
88
89
  - lib/rspec-interactive/rubo_cop_command.rb
89
90
  - lib/rspec-interactive/runner.rb
90
91
  - lib/rspec-interactive/stdio.rb
@@ -105,6 +106,7 @@ files:
105
106
  - tests/failing_spec_test.rb
106
107
  - tests/glob_test.rb
107
108
  - tests/line_number_test.rb
109
+ - tests/parse_error_test.rb
108
110
  - tests/passing_spec_test.rb
109
111
  - tests/rerun_failed_specs_test.rb
110
112
  - tests/spec_with_syntax_error_test.rb