rspec-interactive 0.9.1 → 0.9.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/rspec-interactive +6 -6
- data/examples/config.rb +7 -0
- data/lib/rspec-interactive/client_output.rb +17 -0
- data/lib/rspec-interactive/pry.rb +12 -0
- data/lib/rspec-interactive/rspec_core_example.rb +15 -0
- data/lib/rspec-interactive/stdio.rb +39 -0
- data/lib/rspec-interactive/version.rb +1 -1
- data/lib/rspec-interactive.rb +80 -50
- data/lib/teamcity/spec/runner/formatter/teamcity/formatter.rb +0 -8
- data/rspec-interactive.gemspec +0 -1
- data/runner/Gemfile +5 -0
- data/runner/Gemfile.lock +14 -0
- data/{bin → runner}/rspec-interactive-run +2 -3
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f3d7cb90e4271d19e1eb1a835a9c759084d12baf1f7404bedc521d8ff54047
|
4
|
+
data.tar.gz: 98688109728bbaa18e0b64339987fc0d2320331095ad09f2761d2162254ad868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0fbe89b3308f29db1302f28b265c0374a6b5c586b32b5c2bee2351d035faaf82c5f5d0362bb95158966d5ea9354de404dc126efd7b899d1bb9d2f8bee40edde
|
7
|
+
data.tar.gz: a8bbeaf1ca9e8f51b975cde6bf51be7cc5c6a57b1266bc4ee527c1e1ffcf995b9ac8c78ac77fe1a8ca79b937c4c31d712c9d58119ca4283854da8a6c4f78ccc9
|
data/Gemfile.lock
CHANGED
data/bin/rspec-interactive
CHANGED
@@ -4,20 +4,20 @@ require 'optparse'
|
|
4
4
|
require 'rspec-interactive'
|
5
5
|
|
6
6
|
@options = {
|
7
|
-
server:
|
8
|
-
|
7
|
+
server: true,
|
8
|
+
server_port: RSpec::Interactive::DEFAULT_PORT
|
9
9
|
}
|
10
10
|
|
11
11
|
parser = OptionParser.new do |opts|
|
12
12
|
opts.banner = "Starts an interactive RSpec shell.\n\n"\
|
13
|
-
"Usage: bundle exec rspec-interactive [--config config-file] [--server [--port <port>]
|
13
|
+
"Usage: bundle exec rspec-interactive [--config config-file] [--no-server] [--port <port>]"
|
14
14
|
|
15
15
|
opts.on("-c", "--config <config-file>", String, "Optional. Path to the RSpec Interactive config file.") do |config_file|
|
16
16
|
@options[:config_file] = config_file
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on("-
|
20
|
-
@options[:server] =
|
19
|
+
opts.on("--no-server", "Optional. Disable server.") do
|
20
|
+
@options[:server] = false
|
21
21
|
end
|
22
22
|
|
23
23
|
opts.on("-p", "--port <port>", Integer, "Optional. Server port. Defaults to #{RSpec::Interactive::DEFAULT_PORT}.") do |port|
|
@@ -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[:
|
29
|
+
RSpec::Interactive.start(config_file: @options[:config_file], server: @options[:server], port: @options[:server_port])
|
data/examples/config.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Core
|
5
|
+
class Example
|
6
|
+
alias_method :old_run, :run
|
7
|
+
|
8
|
+
def run(example_group_instance, reporter)
|
9
|
+
execution_result.started_at = RSpec::Core::Time.now
|
10
|
+
old_run(example_group_instance, reporter)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Interactive
|
3
|
+
class Stdio
|
4
|
+
def self.capture(output)
|
5
|
+
raise ArgumentError, 'missing block' unless block_given?
|
6
|
+
|
7
|
+
stdout, stderr = STDOUT.dup, STDERR.dup
|
8
|
+
|
9
|
+
IO.pipe do |stdout_read, stdout_write|
|
10
|
+
IO.pipe do |stderr_read, stderr_write|
|
11
|
+
STDOUT.reopen(stdout_write)
|
12
|
+
STDERR.reopen(stderr_write)
|
13
|
+
|
14
|
+
stdout_write.close
|
15
|
+
stderr_write.close
|
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
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
yield
|
28
|
+
ensure
|
29
|
+
STDOUT.reopen stdout
|
30
|
+
STDERR.reopen stderr
|
31
|
+
end
|
32
|
+
|
33
|
+
thread.join
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/rspec-interactive.rb
CHANGED
@@ -7,13 +7,17 @@ require 'shellwords'
|
|
7
7
|
require 'socket'
|
8
8
|
require 'teamcity/spec/runner/formatter/teamcity/formatter'
|
9
9
|
|
10
|
+
require 'rspec-interactive/client_output'
|
10
11
|
require 'rspec-interactive/config'
|
11
12
|
require 'rspec-interactive/input_completer'
|
13
|
+
require 'rspec-interactive/pry'
|
12
14
|
require 'rspec-interactive/refresh_command'
|
13
15
|
require 'rspec-interactive/rspec_command'
|
14
16
|
require 'rspec-interactive/rspec_config_cache'
|
17
|
+
require 'rspec-interactive/rspec_core_example'
|
15
18
|
require 'rspec-interactive/rubo_cop_command'
|
16
19
|
require 'rspec-interactive/runner'
|
20
|
+
require 'rspec-interactive/stdio'
|
17
21
|
|
18
22
|
module RSpec
|
19
23
|
module Interactive
|
@@ -42,7 +46,7 @@ module RSpec
|
|
42
46
|
@updated_files = []
|
43
47
|
@stty_save = %x`stty -g`.chomp
|
44
48
|
@file_change_mutex = Mutex.new
|
45
|
-
@
|
49
|
+
@command_mutex = Mutex.new
|
46
50
|
@output_stream = output_stream
|
47
51
|
@input_stream = input_stream
|
48
52
|
@error_stream = error_stream
|
@@ -54,12 +58,19 @@ module RSpec
|
|
54
58
|
check_rails
|
55
59
|
configure_pry
|
56
60
|
|
61
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
57
62
|
@config_cache.record_configuration { @configuration.configure_rspec.call }
|
63
|
+
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
64
|
+
if end_time - start_time > 5
|
65
|
+
@output_stream.puts "Configuring RSpec took #{(end_time - start_time).round} seconds."
|
66
|
+
end
|
67
|
+
|
58
68
|
start_file_watcher
|
59
69
|
|
60
70
|
if server
|
71
|
+
@output_stream.puts "Listening on port #{port}."
|
61
72
|
server_thread = Thread.start do
|
62
|
-
server = TCPServer.new
|
73
|
+
server = TCPServer.new port
|
63
74
|
|
64
75
|
while client = server.accept
|
65
76
|
request = client.gets
|
@@ -146,63 +157,70 @@ module RSpec
|
|
146
157
|
end
|
147
158
|
|
148
159
|
def self.rspec(args)
|
149
|
-
@
|
150
|
-
|
151
|
-
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
160
|
+
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
152
161
|
|
153
|
-
|
162
|
+
refresh
|
154
163
|
|
155
|
-
|
156
|
-
|
164
|
+
# Stop saving history in case a new Pry session is started for debugging.
|
165
|
+
Pry.config.history_save = false
|
157
166
|
|
158
|
-
|
159
|
-
|
167
|
+
# RSpec::Interactive-specific RSpec configuration
|
168
|
+
configure_rspec
|
160
169
|
|
161
|
-
|
162
|
-
|
163
|
-
|
170
|
+
# Run.
|
171
|
+
exit_code = @runner.run
|
172
|
+
@runner = nil
|
164
173
|
|
165
|
-
|
166
|
-
|
174
|
+
# Reenable history
|
175
|
+
Pry.config.history_save = true
|
167
176
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
+
# Reset
|
178
|
+
RSpec.clear_examples
|
179
|
+
RSpec.reset
|
180
|
+
@config_cache.replay_configuration
|
181
|
+
rescue Interrupt => e
|
182
|
+
@runner&.quit
|
183
|
+
raise e
|
184
|
+
ensure
|
185
|
+
@runner = nil
|
177
186
|
end
|
178
187
|
|
179
188
|
def self.rspec_for_server(client, args)
|
180
|
-
@
|
181
|
-
#
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
189
|
+
@command_mutex.synchronize do
|
190
|
+
# Prevent the debugger from being used. The server isn't interactive.
|
191
|
+
disable_pry = ENV['DISABLE_PRY']
|
192
|
+
ENV['DISABLE_PRY'] = 'true'
|
193
|
+
|
194
|
+
output = ClientOutput.new(client)
|
195
|
+
Stdio.capture(ClientOutput.new(client)) do
|
196
|
+
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
197
|
+
|
198
|
+
refresh
|
199
|
+
|
200
|
+
# RSpec::Interactive-specific RSpec configuration
|
201
|
+
configure_rspec
|
202
|
+
|
203
|
+
# RubyMine specifies --format. That causes a formatter to be added. It does not override
|
204
|
+
# the existing formatter (if one is set by default). Clear any formatters but resetting
|
205
|
+
# the loader.
|
206
|
+
RSpec.configuration.instance_variable_set(
|
207
|
+
:@formatter_loader,
|
208
|
+
RSpec::Core::Formatters::Loader.new(RSpec::Core::Reporter.new(RSpec.configuration)))
|
209
|
+
|
210
|
+
# Always use the teamcity formatter, even though RubyMine always specifies it.
|
211
|
+
# This make manual testing of rspec-interactive easier.
|
212
|
+
RSpec.configuration.formatter = Spec::Runner::Formatter::TeamcityFormatter
|
213
|
+
|
214
|
+
# Run.
|
215
|
+
exit_code = @runner.run
|
216
|
+
|
217
|
+
# Reset
|
218
|
+
RSpec.clear_examples
|
219
|
+
RSpec.reset
|
220
|
+
@config_cache.replay_configuration
|
221
|
+
end
|
222
|
+
ensure
|
223
|
+
ENV['DISABLE_PRY'] = disable_pry
|
206
224
|
end
|
207
225
|
end
|
208
226
|
|
@@ -214,5 +232,17 @@ module RSpec
|
|
214
232
|
end
|
215
233
|
end
|
216
234
|
|
235
|
+
def self.eval(&block)
|
236
|
+
if Thread.current.thread_variable_get('holding_lock')
|
237
|
+
yield
|
238
|
+
else
|
239
|
+
@command_mutex.synchronize do
|
240
|
+
Thread.current.thread_variable_set('holding_lock', true)
|
241
|
+
yield
|
242
|
+
ensure
|
243
|
+
Thread.current.thread_variable_set('holding_lock', false)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
217
247
|
end
|
218
248
|
end
|
data/rspec-interactive.gemspec
CHANGED
data/runner/Gemfile
ADDED
data/runner/Gemfile.lock
ADDED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
-
require 'rspec-interactive'
|
5
4
|
require 'shellwords'
|
6
5
|
require 'socket'
|
7
6
|
|
@@ -25,8 +24,8 @@ parser = OptionParser.new do |opts|
|
|
25
24
|
end.parse
|
26
25
|
|
27
26
|
server = TCPSocket.open(@options[:host], @options[:port])
|
28
|
-
server.puts ARGV.map{|arg| Shellwords.escape arg}.join(' ')
|
27
|
+
server.puts ARGV.map{ |arg| Shellwords.escape arg }.join(' ')
|
29
28
|
while response = server.gets do
|
30
|
-
puts
|
29
|
+
puts response
|
31
30
|
end
|
32
31
|
server.close
|
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.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Dower
|
@@ -71,7 +71,6 @@ email:
|
|
71
71
|
- nicholasdower@gmail.com
|
72
72
|
executables:
|
73
73
|
- rspec-interactive
|
74
|
-
- rspec-interactive-run
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
77
76
|
files:
|
@@ -83,25 +82,32 @@ files:
|
|
83
82
|
- Rakefile
|
84
83
|
- bin/console
|
85
84
|
- bin/rspec-interactive
|
86
|
-
- bin/rspec-interactive-run
|
87
85
|
- bin/setup
|
88
86
|
- bin/test
|
87
|
+
- examples/config.rb
|
89
88
|
- examples/debugged_spec.rb
|
90
89
|
- examples/failing_spec.rb
|
91
90
|
- examples/other_passing_spec.rb
|
92
91
|
- examples/passing_spec.rb
|
93
92
|
- examples/spec_with_syntax_error.rb
|
94
93
|
- lib/rspec-interactive.rb
|
94
|
+
- lib/rspec-interactive/client_output.rb
|
95
95
|
- lib/rspec-interactive/config.rb
|
96
96
|
- lib/rspec-interactive/input_completer.rb
|
97
|
+
- lib/rspec-interactive/pry.rb
|
97
98
|
- lib/rspec-interactive/refresh_command.rb
|
98
99
|
- lib/rspec-interactive/rspec_command.rb
|
99
100
|
- lib/rspec-interactive/rspec_config_cache.rb
|
101
|
+
- lib/rspec-interactive/rspec_core_example.rb
|
100
102
|
- lib/rspec-interactive/rubo_cop_command.rb
|
101
103
|
- lib/rspec-interactive/runner.rb
|
104
|
+
- lib/rspec-interactive/stdio.rb
|
102
105
|
- lib/rspec-interactive/version.rb
|
103
106
|
- lib/teamcity/spec/runner/formatter/teamcity/formatter.rb
|
104
107
|
- rspec-interactive.gemspec
|
108
|
+
- runner/Gemfile
|
109
|
+
- runner/Gemfile.lock
|
110
|
+
- runner/rspec-interactive-run
|
105
111
|
- scripts/release.sh
|
106
112
|
- scripts/run-with-local-dep.sh
|
107
113
|
- tests/debugged_spec_test.rb
|