rspec-interactive 0.9.2 → 0.9.3

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
2
  SHA256:
3
- metadata.gz: 17f3d7cb90e4271d19e1eb1a835a9c759084d12baf1f7404bedc521d8ff54047
4
- data.tar.gz: 98688109728bbaa18e0b64339987fc0d2320331095ad09f2761d2162254ad868
3
+ metadata.gz: ca3d9ea9bc7a43930a9d3400a30b1c9d0bb06cc6691b70340966c8543b830646
4
+ data.tar.gz: 6f22c4c95eb720509cabb7cd3edd18277b1b68f96bdca32ab7f55ff6197c3e11
5
5
  SHA512:
6
- metadata.gz: f0fbe89b3308f29db1302f28b265c0374a6b5c586b32b5c2bee2351d035faaf82c5f5d0362bb95158966d5ea9354de404dc126efd7b899d1bb9d2f8bee40edde
7
- data.tar.gz: a8bbeaf1ca9e8f51b975cde6bf51be7cc5c6a57b1266bc4ee527c1e1ffcf995b9ac8c78ac77fe1a8ca79b937c4c31d712c9d58119ca4283854da8a6c4f78ccc9
6
+ metadata.gz: f39caa7d3669358769a1aa5f8c901bfbfafbef2d9e5854e14a3331f87bfb5065cf42c3609dcb5d84940371811ae35b6168ed46effa99da032e9d4dae8e0a85d0
7
+ data.tar.gz: 426d3c1feaec48508dfc48712914c40e278641c669a789b9902fa8a307c3ac349ed4cb580b008be8527d664cde94865d5e33b127a21192bf872f91261f3a93bc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-interactive (0.9.1)
4
+ rspec-interactive (0.9.2)
5
5
  listen
6
6
  pry
7
7
  rspec-core
@@ -5,8 +5,8 @@ module RSpec
5
5
  @client = client
6
6
  end
7
7
 
8
- def puts(str = "")
9
- @client.puts(str&.to_s || '')
8
+ def print(str = "")
9
+ @client.print(str&.to_s || '')
10
10
  end
11
11
 
12
12
  def string
@@ -14,23 +14,28 @@ module RSpec
14
14
  stdout_write.close
15
15
  stderr_write.close
16
16
 
17
- thread = Thread.new do
18
- until stdout_read.eof? && stderr_read.eof? do
19
- line = stdout_read.gets
20
- output.puts line if line
21
- line = stderr_read.gets
22
- output.puts if line
17
+ stdout_thread = Thread.new do
18
+ while line = stdout_read.gets do
19
+ output.print(line)
20
+ end
21
+ end
22
+
23
+ stderr_thread = Thread.new do
24
+ while line = stderr_read.gets do
25
+ output.print(line)
23
26
  end
24
27
  end
25
28
 
26
29
  begin
27
30
  yield
28
31
  ensure
32
+ # TODO: should the threads be killed here?
29
33
  STDOUT.reopen stdout
30
34
  STDERR.reopen stderr
31
35
  end
32
36
 
33
- thread.join
37
+ stdout_thread.join
38
+ stderr_thread.join
34
39
  end
35
40
  end
36
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Interactive
5
- VERSION = "0.9.2"
5
+ VERSION = "0.9.3"
6
6
  end
7
7
  end
@@ -56,6 +56,7 @@ module RSpec
56
56
  load config_file if config_file
57
57
 
58
58
  check_rails
59
+ trap_interrupt
59
60
  configure_pry
60
61
 
61
62
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -103,6 +104,17 @@ module RSpec
103
104
  end
104
105
  end
105
106
 
107
+ def self.trap_interrupt
108
+ trap('INT') do
109
+ if @runner
110
+ # We are on a different thread. There is a race here. Ignore nil.
111
+ @runner&.quit
112
+ else
113
+ raise Interrupt
114
+ end
115
+ end
116
+ end
117
+
106
118
  def self.start_file_watcher
107
119
  return if @configuration.watch_dirs.empty?
108
120
 
@@ -116,6 +128,9 @@ module RSpec
116
128
  end
117
129
 
118
130
  def self.configure_pry
131
+ # Prevent Pry from trapping too. It will break ctrl-c handling.
132
+ Pry.config.should_trap_interrupts = false
133
+
119
134
  # Set up IO.
120
135
  Pry.config.input = Readline
121
136
  Pry.config.output = @output_stream
@@ -178,9 +193,6 @@ module RSpec
178
193
  RSpec.clear_examples
179
194
  RSpec.reset
180
195
  @config_cache.replay_configuration
181
- rescue Interrupt => e
182
- @runner&.quit
183
- raise e
184
196
  ensure
185
197
  @runner = nil
186
198
  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.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Dower