rspec-abq 1.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29210d070dba423ba2bb9aad82deb1df9e4a4fb01e70bec05b1d728d20e29d5e
4
- data.tar.gz: 1771fe5b152192dd256b29cc412526fc275c381c1c697cec4a51b6ae5a4b0174
3
+ metadata.gz: ed680f830f8937cce3a3732e0a03ca62da77ff054cd23e26dcd59f54b019b51b
4
+ data.tar.gz: 1042ac324987d4659bab86194dd2e4a59eeb439f7c0794c76d771c68c3a7e4ea
5
5
  SHA512:
6
- metadata.gz: 8f89f037b50d88458b443c534ec78e20d9bbf4661d81cf68774f2bd7438a588cace8a991dfe101d1a4424a98956e186ba20f65d51f47d837ff5237dbf4b00a4f
7
- data.tar.gz: 22bf4931dc4ee3639334e1e91451e0577591c215ad279802560d8ae7256b56a31a93fcb495b932f9e490658aa2e1bc23e1100c29ed735b0515312f1e9dae2c6f
6
+ metadata.gz: e4c3adc4d24036d2c838057ad7f25b033d39f35d0a1a7b681291b7523ef47c262a29dbbc2a28b46fa7244db2896fdf0a19560922d6f6c46a5a488069e5f4e265
7
+ data.tar.gz: d97a1f0fd596dff067b8b87efb7b36a422bd99a512f47df38b1e70643b2c8df258b25c89343d1bb0ceabcb61b99602888ff7378becd526cab5892fc2bae83152
data/README.md CHANGED
@@ -38,7 +38,7 @@ require 'rspec/abq'
38
38
 
39
39
  This gem is actively tested against
40
40
 
41
- - rubies 2.6-3.1
41
+ - rubies 2.7-3.1
42
42
  - rspecs 3.5-3.12
43
43
 
44
44
  as well as a handful of rspec plugins:
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Abq
3
3
  # current version!
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.2"
5
5
  end
6
6
  end
data/lib/rspec/abq.rb CHANGED
@@ -148,8 +148,20 @@ module RSpec
148
148
  Extensions.setup!
149
149
  end
150
150
 
151
+ # Base ABQ error.
152
+ Error = Class.new(StandardError)
153
+
151
154
  # raised when check_configuration fails
152
- UnsupportedConfigurationError = Class.new(StandardError)
155
+ UnsupportedConfigurationError = Class.new(Error)
156
+
157
+ # Failed to connect and initialize handshake.
158
+ ConnectionFailed = Class.new(Error)
159
+
160
+ # Communication between abq sockets follows the following protocol:
161
+ # - The first 4 bytes an unsigned 32-bit integer (big-endian) representing
162
+ # the size of the rest of the message.
163
+ # - The rest of the message is a JSON-encoded payload.
164
+ ConnectionBroken = Class.new(Error)
153
165
 
154
166
  # raises if RSpec is configured in a way that's incompatible with rspec-abq
155
167
  def self.check_configuration!(config)
@@ -214,12 +226,16 @@ module RSpec
214
226
 
215
227
  # Creates the socket to communicate with the worker and sends the worker the protocol
216
228
  # @!visibility private
217
- def self.socket
218
- @socket ||= TCPSocket.new(*ENV[ABQ_SOCKET].split(":")).tap do |socket|
219
- # Messages sent to/received from the ABQ worker should be done so ASAP.
220
- # Since we're on a local network, we don't care about packet reduction here.
221
- socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
222
- protocol_write(NATIVE_RUNNER_SPAWNED_MESSAGE, socket)
229
+ def self.socket(connect_timeout: 5)
230
+ @socket ||= begin
231
+ Socket.tcp(*ENV[ABQ_SOCKET].split(":"), connect_timeout: connect_timeout).tap do |socket|
232
+ # Messages sent to/received from the ABQ worker should be done so ASAP.
233
+ # Since we're on a local network, we don't care about packet reduction here.
234
+ socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
235
+ protocol_write(NATIVE_RUNNER_SPAWNED_MESSAGE, socket)
236
+ end
237
+ rescue
238
+ raise ConnectionFailed, "Unable to connect to ABQ socket #{ENV[ABQ_SOCKET]}"
223
239
  end
224
240
  end
225
241
 
@@ -245,25 +261,18 @@ module RSpec
245
261
  end
246
262
  end
247
263
 
248
- # Communication between abq sockets follows the following protocol:
249
- # - The first 4 bytes an unsigned 32-bit integer (big-endian) representing
250
- # the size of the rest of the message.
251
- # - The rest of the message is a JSON-encoded payload.
252
- class AbqConnBroken < StandardError
253
- end
254
-
255
264
  # Writes a message to an Abq socket using the 4-byte header protocol.
256
265
  #
257
266
  # @param socket [TCPSocket]
258
267
  # @param msg
259
268
  def self.protocol_write(msg, socket = Abq.socket)
260
269
  json_msg = JSON.dump msg
261
- begin
262
- socket.write [json_msg.bytesize].pack("N")
263
- socket.write json_msg
264
- rescue
265
- raise AbqConnBroken
266
- end
270
+ socket.write [json_msg.bytesize].pack("N")
271
+ socket.write json_msg
272
+ rescue SystemCallError, IOError
273
+ raise ConnectionBroken
274
+ rescue
275
+ raise Error
267
276
  end
268
277
 
269
278
  # Writes a message to an Abq socket using the 4-byte header protocol.
@@ -273,10 +282,16 @@ module RSpec
273
282
  def self.protocol_read(socket = Abq.socket)
274
283
  len_bytes = socket.read 4
275
284
  return :abq_done if len_bytes.nil?
285
+
276
286
  len = len_bytes.unpack1("N")
277
287
  json_msg = socket.read len
278
288
  return :abq_done if json_msg.nil?
289
+
279
290
  JSON.parse json_msg
291
+ rescue SystemCallError, IOError
292
+ raise ConnectionBroken
293
+ rescue
294
+ raise Error
280
295
  end
281
296
  end
282
297
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-abq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayaz Hafiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-10 00:00:00.000000000 Z
12
+ date: 1980-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-core
@@ -63,44 +63,44 @@ dependencies:
63
63
  name: capybara
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.36.0
68
+ version: 3.38.0
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.36.0
75
+ version: 3.38.0
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: selenium-webdriver
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 4.1.0
82
+ version: 4.8.0
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 4.1.0
89
+ version: 4.8.0
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: nokogiri
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.13.10
96
+ version: 1.14.2
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.13.10
103
+ version: 1.14.2
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: webdrivers
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -135,14 +135,14 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 5.6.5
138
+ version: 6.1.0
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 5.6.5
145
+ version: 6.1.0
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: capybara-inline-screenshot
148
148
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  - !ruby/object:Gem::Version
216
216
  version: '0'
217
217
  requirements: []
218
- rubygems_version: 3.3.7
218
+ rubygems_version: 3.2.26
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: RSpec::Abq allows for parallel rspec runs using abq