rspec-bash-x 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: 74cf305ed10730b811f278b17e84579525ca2f75
4
- data.tar.gz: 69fafdc217a018885b31b568ac0a7f95c0752bdb
3
+ metadata.gz: 3143908ceef94f9985ca5a4234aa841fb2eb5ea1
4
+ data.tar.gz: 2af3b25aad667a9405d148e6b119ed85296a73e3
5
5
  SHA512:
6
- metadata.gz: 335ba43a3659066d595d1dd6e085c6ba6f1503e5d24730adf808764c1a0a0394ccebf4d31d07185517b15cf05b577e265019f3b968f1b04252a08ed8143c87b5
7
- data.tar.gz: 39decb1ca2a1193e0c7eb4046d572e8454dd9e8b289f1bff4db8efbf53bf9bfca8c2492b8b5d2bd8acf0eeaf346aad8d3580e09a39ce9c539e5d70ac620762bf
6
+ metadata.gz: e448146c650e50bd0a29deb61b4a1b0a3d549fbc9cbc6ab0d466f65ca89051a401fd09571222814dc3f923188171d2fabe5748617b0221bfc12f0231cc1fb8b3
7
+ data.tar.gz: 341db330bcd0436793bc122af9eff45c6d87b0e6c32750fa29e988635ab9611c5721c23a8e8b706d914ab600d5e934ee60b9fc7f2640adc38ae4d541cce95fea
@@ -0,0 +1,3 @@
1
+ ## 1.2.0
2
+
3
+ - ScriptEvaluator#run_script now accepts `env:` hash after command arguments
@@ -9,7 +9,7 @@ module RSpec
9
9
  # the descriptors are available as 62 (child read) and 63 (child write)
10
10
  #
11
11
  # @param [Array<String>] cmd
12
- def self.popen3X(cmd, read_fd: 62, write_fd: 63, &block)
12
+ def self.popen3X(cmd, read_fd: 62, write_fd: 63, env: {}, &block)
13
13
  in_r, in_w = IO.pipe
14
14
  out_r, out_w = IO.pipe
15
15
  err_r, err_w = IO.pipe
@@ -23,13 +23,13 @@ module RSpec
23
23
  opts[read_fd] = r2b_r
24
24
  opts[write_fd] = b2r_w
25
25
 
26
- env = {
26
+ combined_env = env.merge({
27
27
  "BASHIT_R_FD" => "#{read_fd}",
28
28
  "BASHIT_W_FD" => "#{write_fd}"
29
- }
29
+ })
30
30
 
31
31
  ::Open3.send(:popen_run,
32
- [env] + cmd,
32
+ [combined_env] + cmd,
33
33
  opts,
34
34
  [in_r, out_w, err_w, r2b_r, b2r_w], # child_io
35
35
  [in_w, out_r, err_r, r2b_w, b2r_r], # parent_io
@@ -25,7 +25,7 @@ module RSpec
25
25
  # @param [Number?] options.write_fd
26
26
  # @param [Number?] options.throttle
27
27
  def eval(script, args = [], **opts)
28
- file = Tempfile.new('rspec_bash')
28
+ file = opts.fetch(:file, Tempfile.new('rspec_bash'))
29
29
  file.write(script.to_s)
30
30
  file.close
31
31
  verbose = opts.fetch(:verbose, Bash.configuration.verbose)
@@ -35,7 +35,8 @@ module RSpec
35
35
 
36
36
  Bash::Open3.popen3X([ '/usr/bin/env', 'bash', file.path ].concat(args), {
37
37
  read_fd: opts.fetch(:read_fd, Bash.configuration.read_fd),
38
- write_fd: opts.fetch(:write_fd, Bash.configuration.write_fd)
38
+ write_fd: opts.fetch(:write_fd, Bash.configuration.write_fd),
39
+ env: opts.fetch(:env, {})
39
40
  }) do |input, stdout, stderr, r2b, b2r, wait_thr|
40
41
  workers = []
41
42
 
@@ -83,7 +84,7 @@ module RSpec
83
84
  try_hard "shut off workers" do workers.map(&:join) end
84
85
  try_hard "kill them all" do workers.map(&:kill) end
85
86
  try_hard "clean up temp bus file" do bus_file.unlink end
86
- try_hard "clean up source file" do file.unlink end
87
+ try_hard "clean up source file" do file.unlink unless opts.key?(:file) end
87
88
 
88
89
  script.track_exit_code wait_thr.value.exitstatus
89
90
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Bash
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-bash-x
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-support