awesome_spawn 1.4.1 → 1.5.0

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
- SHA1:
3
- metadata.gz: 2377955010be58dc1a2612d2293c2b423721fbdc
4
- data.tar.gz: 294a70bb931c7eda8f4ae676f9635202679175b3
2
+ SHA256:
3
+ metadata.gz: 5dff33751b72552d7d01e1bfa6e024881148c8d64e309daaa2504107aa6b28f9
4
+ data.tar.gz: 2d10fb491e209ba595dc1e8eb3751901d45ec427ddc56e3b3108606350881dab
5
5
  SHA512:
6
- metadata.gz: 0c3671bcf020eb3c28750fcfdd67f19387100bf43064f9e1359f2bf690d7e984b7eceaa33d8ea198e47b42ecb01c27eae89f73c7f3bde5ef7aab915c4192d7ab
7
- data.tar.gz: 1c512c6c1a18ca52bf255f1626b281f38c94c74ef17c9dae8bf220c0617ac36ff024f6d08ea0589790d583b532c9613f0b65d20a2ae573dbecf274c0e7168fcf
6
+ metadata.gz: 9b2ab733dc7226ac633d416500a8ddcec2d44a835431645560997acf3621636ad94286eb6431e92fdad88212ec151ad0046371d6c05006eed2d8dcd6e9bf1164
7
+ data.tar.gz: f4754e31a144048fc5988a664d997da432ac7af5883234ffd7ee4e205d620eab9e715d7980cdb6668f1a28f369cfffeb798867a56186be2a45222bb18387b263
@@ -62,6 +62,7 @@ module AwesomeSpawn
62
62
  # @option options [Hash,Array] :params The command line parameters. See
63
63
  # {#build_command_line} for how to specify params.
64
64
  # @option options [String] :in_data Data to be passed on stdin.
65
+ # @option options [Boolean] :combined_output Combine STDOUT/STDERR streams from run command
65
66
  # @option options [Hash<String,String>] :env Additional environment variables for sub process
66
67
  #
67
68
  # @raise [NoSuchFileError] if the `command` is not found
@@ -100,8 +101,10 @@ module AwesomeSpawn
100
101
 
101
102
  if command_result.failure?
102
103
  message = CommandResultError.default_message(command, command_result.exit_status)
104
+ error = command_result.error.nil? || command_result.error.empty? ? command_result.output : command_result.error
105
+
103
106
  logger.error("AwesomeSpawn: #{message}")
104
- logger.error("AwesomeSpawn: #{command_result.error}")
107
+ logger.error("AwesomeSpawn: #{error}")
105
108
  raise CommandResultError.new(message, command_result)
106
109
  end
107
110
 
@@ -116,7 +119,13 @@ module AwesomeSpawn
116
119
  private
117
120
 
118
121
  def launch(env, command, spawn_options)
119
- output, error, status = Open3.capture3(env, command, spawn_options)
122
+ capture2e = spawn_options.delete(:combined_output)
123
+ if capture2e
124
+ output, status = Open3.capture2e(env, command, spawn_options)
125
+ error = ""
126
+ else
127
+ output, error, status = Open3.capture3(env, command, spawn_options)
128
+ end
120
129
  return output, error, status && status.exitstatus
121
130
  end
122
131
 
@@ -12,7 +12,7 @@ module AwesomeSpawn
12
12
  #
13
13
  # - `{:k => "value"}` generates `-k value`
14
14
  # - `[[:k, "value"]]` generates `-k value`
15
- # - `{:k => "value"}` generates `-k=value`
15
+ # - `{:k= => "value"}` generates `-k=value`
16
16
  # - `[[:k=, "value"]]` generates `-k=value` <br /><br />
17
17
  #
18
18
  # - `{:key => "value"}` generates `--key value`
@@ -8,6 +8,7 @@ module AwesomeSpawn
8
8
  attr_reader :result
9
9
 
10
10
  def initialize(message, result)
11
+ message += " error was: #{result.error}" if !result.nil? && !result.error.empty?
11
12
  super(message)
12
13
  @result = result
13
14
  end
@@ -11,11 +11,11 @@ module AwesomeSpawn
11
11
  allow(Open3).to receive(:capture3).and_call_original
12
12
  end
13
13
 
14
- def stub_good_run
14
+ def stub_good_run(command, options = {})
15
15
  stub_run(:good, :run, command, options)
16
16
  end
17
17
 
18
- def stub_bad_run
18
+ def stub_bad_run(command, options = {})
19
19
  stub_run(:bad, :run, command, options)
20
20
  end
21
21
 
@@ -30,15 +30,14 @@ module AwesomeSpawn
30
30
  private
31
31
 
32
32
  def stub_run(mode, method, command, options)
33
- output = options[:output] || ""
34
- error = options[:error] || (mode == :bad ? "Failure" : "")
35
- exit_status = options[:exit_status] || (mode == :bad ? 1 : 0)
33
+ options = options.dup
34
+ output = options.delete(:output) || ""
35
+ error = options.delete(:error) || (mode == :bad ? "Failure" : "")
36
+ exit_status = options.delete(:exit_status) || (mode == :bad ? 1 : 0)
36
37
 
37
- params = options[:params]
38
- command_line = AwesomeSpawn.build_command_line(command, params)
38
+ command_line = AwesomeSpawn.build_command_line(command, options[:params])
39
39
 
40
- args = [command]
41
- args << {:params => params} if params
40
+ args = [command, options]
42
41
 
43
42
  result = CommandResult.new(command_line, output, error, exit_status)
44
43
  if method == :run! && mode == :bad
@@ -1,3 +1,3 @@
1
1
  module AwesomeSpawn
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
@@ -11,22 +11,22 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-06-22 00:00:00.000000000 Z
14
+ date: 2020-02-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '1.3'
22
+ version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.3'
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,6 @@ executables: []
80
80
  extensions: []
81
81
  extra_rdoc_files: []
82
82
  files:
83
- - ".rspec"
84
83
  - ".yardopts"
85
84
  - LICENSE.txt
86
85
  - README.md
@@ -92,12 +91,6 @@ files:
92
91
  - lib/awesome_spawn/null_logger.rb
93
92
  - lib/awesome_spawn/spec_helper.rb
94
93
  - lib/awesome_spawn/version.rb
95
- - spec/awesome_spawn_spec.rb
96
- - spec/command_line_builder_spec.rb
97
- - spec/command_result_error_spec.rb
98
- - spec/command_result_spec.rb
99
- - spec/no_such_file_error_spec.rb
100
- - spec/spec_helper.rb
101
94
  homepage: https://github.com/ManageIQ/awesome_spawn
102
95
  licenses:
103
96
  - MIT
@@ -117,16 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
110
  - !ruby/object:Gem::Version
118
111
  version: '0'
119
112
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.4.5.1
113
+ rubygems_version: 3.0.3
122
114
  signing_key:
123
115
  specification_version: 4
124
116
  summary: AwesomeSpawn is a module that provides some useful features over Ruby's Kernel.spawn.
125
- test_files:
126
- - spec/awesome_spawn_spec.rb
127
- - spec/command_line_builder_spec.rb
128
- - spec/command_result_error_spec.rb
129
- - spec/command_result_spec.rb
130
- - spec/no_such_file_error_spec.rb
131
- - spec/spec_helper.rb
132
- - ".rspec"
117
+ test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
- require 'pathname' # For Pathname specific specs
3
-
4
- describe AwesomeSpawn do
5
- subject { described_class }
6
-
7
- shared_examples_for "parses" do
8
- it "supports no options" do
9
- allow(subject).to receive(:launch).with({}, "true", {}).and_return(["", "", 0])
10
- subject.send(run_method, "true")
11
- end
12
-
13
- it "supports option :params and :env" do
14
- allow(subject).to receive(:launch).with({"VAR" => "x"}, "true --user bob", {}).and_return(["", "", 0])
15
- subject.send(run_method, "true", :params => {:user => "bob"}, :env => {"VAR" => "x"})
16
- end
17
-
18
- it "wont modify passed in options" do
19
- options = {:params => {:user => "bob"}}
20
- orig_options = options.dup
21
- allow(subject).to receive(:launch).with({}, "true --user bob", {}).and_return(["", "", 0])
22
- subject.send(run_method, "true", options)
23
- expect(orig_options).to eq(options)
24
- end
25
-
26
- it "wont modify passed in options[:params]" do
27
- params = {:user => "bob"}
28
- orig_params = params.dup
29
- allow(subject).to receive(:launch).with({}, "true --user bob", {}).and_return(["", "", 0])
30
- subject.send(run_method, "true", :params => params)
31
- expect(orig_params).to eq(params)
32
- end
33
-
34
- it "warns about option :in" do
35
- expect do
36
- subject.send(run_method, "true", :in => "/dev/null")
37
- end.to raise_error(ArgumentError, "options cannot contain :in")
38
- end
39
-
40
- it "warns about option :out" do
41
- expect do
42
- subject.send(run_method, "true", :out => "/dev/null")
43
- end.to raise_error(ArgumentError, "options cannot contain :out")
44
- end
45
-
46
- it "warns about option :err" do
47
- expect do
48
- subject.send(run_method, "true", :err => "/dev/null")
49
- end.to raise_error(ArgumentError, "options cannot contain :err")
50
- end
51
-
52
- it "warns about option :err when in an array" do
53
- expect do
54
- subject.send(run_method, "true", [:err, :out, 3] => "/dev/null")
55
- end.to raise_error(ArgumentError, "options cannot contain :err, :out")
56
- end
57
- end
58
-
59
- shared_examples_for "executes" do
60
- before do
61
- # Re-enable actual spawning just for these specs.
62
- enable_spawning
63
- end
64
-
65
- it "runs command" do
66
- expect(subject.send(run_method, "true")).to be_kind_of AwesomeSpawn::CommandResult
67
- end
68
-
69
- it "detects bad commands" do
70
- expect do
71
- subject.send(run_method, "XXXXX --user=bob")
72
- end.to raise_error(AwesomeSpawn::NoSuchFileError, "No such file or directory - XXXXX")
73
- end
74
-
75
- describe "parameters" do
76
- it "changes directory" do
77
- result = subject.send(run_method, "pwd", :chdir => "..")
78
- expect(result.exit_status).to eq(0)
79
- expect(result.output.chomp).to eq(File.expand_path("..", Dir.pwd))
80
- end
81
-
82
- it "passes input" do
83
- result = subject.send(run_method, "cat", :in_data => "line1\nline2")
84
- expect(result.exit_status).to eq(0)
85
- expect(result.output).to eq("line1\nline2")
86
- end
87
-
88
- it "sets environment" do
89
- result = subject.send(run_method, "echo ${ABC}", :env => {"ABC" => "yay!"})
90
- expect(result.exit_status).to eq(0)
91
- expect(result.output).to eq("yay!\n")
92
- end
93
- end
94
-
95
- describe "result" do
96
- it "contains #command_line" do
97
- expect(subject.send(run_method, "echo", :params => %w(x)).command_line).to eq("echo x")
98
- end
99
-
100
- it "contains #exit_status" do
101
- expect(subject.send(run_method, "true").exit_status).to eq(0)
102
- end
103
-
104
- it "contains #output" do
105
- expect(subject.send(run_method, "echo \"Hello World\"").output).to eq("Hello World\n")
106
- end
107
-
108
- it "contains #output when output redirected to stderr)" do
109
- expect(subject.send(run_method, "echo \"Hello World\" >&2").output).to eq("")
110
- end
111
-
112
- it "contains #error when no error" do
113
- expect(subject.send(run_method, "echo", :params => ["Hello World"]).error).to eq("")
114
- end
115
-
116
- it "contains #error" do
117
- expect(subject.send(run_method, "echo \"Hello World\" >&2").error).to eq("Hello World\n")
118
- end
119
- end
120
- end
121
-
122
- shared_examples_for "executes with failures" do
123
- context "result with a bad command" do
124
- before do
125
- # Re-enable actual spawning just for these specs.
126
- enable_spawning
127
- end
128
-
129
- it "contains #command_line" do
130
- expect(subject.send(run_method, "echo x && false").command_line).to eq("echo x && false")
131
- end
132
-
133
- it "contains #exit_status" do
134
- expect(subject.send(run_method, "false").exit_status).to eq(1)
135
- end
136
-
137
- it "contains #output" do
138
- expect(subject.send(run_method, "echo 'bad' && false").output).to eq("bad\n")
139
- end
140
-
141
- it "contains #error" do
142
- expect(subject.send(run_method, "echo 'bad' >&2 && false").error).to eq("bad\n")
143
- end
144
- end
145
- end
146
-
147
- describe ".build_command_line" do
148
- it "supports no parameters" do
149
- expect(subject.build_command_line("cmd")).to eq("cmd")
150
- end
151
-
152
- it "supports single long parameter" do
153
- expect(subject.build_command_line("cmd", :status => true)).to eq("cmd --status true")
154
- end
155
-
156
- it "supports multiple long parameters" do
157
- expect(subject.build_command_line("cmd", :status => true, :fast => false)).to eq("cmd --status true --fast false")
158
- end
159
- end
160
-
161
- describe ".run" do
162
- let(:run_method) { "run" }
163
- include_examples "parses"
164
- include_examples "executes"
165
- include_examples "executes with failures"
166
- end
167
-
168
- describe ".run!" do
169
- let(:run_method) { "run!" }
170
- include_examples "parses"
171
- include_examples "executes"
172
-
173
- it "raises errors on failure" do
174
- expect { subject.send(run_method, "false") }.to raise_error do |error|
175
- expect(error).to be_kind_of AwesomeSpawn::CommandResultError
176
- expect(error.result).to be_kind_of AwesomeSpawn::CommandResult
177
- end
178
- end
179
- end
180
- end
@@ -1,291 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AwesomeSpawn::CommandLineBuilder do
4
- subject { described_class.new }
5
-
6
- context "#build" do
7
- def assert_params(params, expected_params)
8
- expect(subject.build("true", params)).to eq "true #{expected_params}".strip
9
- end
10
-
11
- it "without params" do
12
- expect(subject.build("true")).to eq "true"
13
- end
14
-
15
- it "with nil" do
16
- expect(subject.build("true", nil)).to eq "true"
17
- end
18
-
19
- it "with empty" do
20
- expect(subject.build("true", "")).to eq "true"
21
- end
22
-
23
- it "with empty" do
24
- expect(subject.build("true", [])).to eq "true"
25
- end
26
-
27
- it "with Pathname command" do
28
- actual = subject.build(Pathname.new("/usr/bin/ruby"))
29
- expect(actual).to eq "/usr/bin/ruby"
30
- end
31
-
32
- it "with Pathname command and params" do
33
- actual = subject.build(Pathname.new("/usr/bin/ruby"), "-v" => nil)
34
- expect(actual).to eq "/usr/bin/ruby -v"
35
- end
36
-
37
- it "with Pathname in params" do
38
- options = ["-d", Pathname.new("script.rb")]
39
-
40
- actual = subject.build(Pathname.new("/usr/bin/ruby"), options)
41
- expect(actual).to eq "/usr/bin/ruby -d script.rb"
42
- end
43
-
44
- context "with Hash" do
45
- it "that is empty" do
46
- assert_params({}, "")
47
- end
48
-
49
- it "with normal params" do
50
- assert_params({"--user" => "bob"}, "--user bob")
51
- end
52
-
53
- it "with key with tailing '='" do
54
- assert_params({"--user=" => "bob"}, "--user=bob")
55
- end
56
-
57
- it "with single letter symbol" do
58
- assert_params({:a => "val"}, "-a val")
59
- end
60
-
61
- it "with single letter symbol" do
62
- assert_params({:a= => "val"}, "-a=val")
63
- end
64
-
65
- it "with value requiring sanitization" do
66
- assert_params({"--pass" => "P@$s w0rd%"}, "--pass P@\\$s\\ w0rd\\%")
67
- end
68
-
69
- it "with key requiring sanitization" do
70
- assert_params({"--h&x0r=" => "xxx"}, "--h\\&x0r=xxx")
71
- end
72
-
73
- it "with key as Symbol" do
74
- assert_params({:abc => "def"}, "--abc def")
75
- end
76
-
77
- it "with key as Symbol with tailing '='" do
78
- assert_params({:abc= => "def"}, "--abc=def")
79
- end
80
-
81
- it "with key as Symbol with underscore" do
82
- assert_params({:abc_def => "ghi"}, "--abc-def ghi")
83
- end
84
-
85
- it "with key as Symbol with underscore and tailing '='" do
86
- assert_params({:abc_def= => "ghi"}, "--abc-def=ghi")
87
- end
88
-
89
- it "with key as nil" do
90
- assert_params({nil => "def"}, "def")
91
- end
92
-
93
- it "with value as nil" do
94
- assert_params({"--abc" => nil}, "--abc")
95
- end
96
-
97
- it "with key and value nil" do
98
- assert_params({nil => nil}, "")
99
- end
100
-
101
- it "with key of '--'" do
102
- assert_params({"--" => nil}, "--")
103
- end
104
-
105
- it "with value as Symbol" do
106
- assert_params({"--abc" => :def}, "--abc def")
107
- end
108
-
109
- it "with value as Array" do
110
- assert_params({"--abc" => ["def", "ghi"]}, "--abc def ghi")
111
- end
112
-
113
- it "with value as Fixnum" do
114
- assert_params({"--abc" => 1}, "--abc 1")
115
- end
116
-
117
- it "with value as Fixnum Array" do
118
- assert_params({"--abc" => [1, 2]}, "--abc 1 2")
119
- end
120
-
121
- it "with value as Range" do
122
- assert_params({"--abc" => (1..4)}, "--abc 1 2 3 4")
123
- end
124
-
125
- it "with value as Pathname" do
126
- assert_params({"--abc" => Pathname.new("/usr/bin/ruby")}, "--abc /usr/bin/ruby")
127
- end
128
- end
129
-
130
- context "with associative Array" do
131
- it "that is empty" do
132
- assert_params([], "")
133
- end
134
-
135
- it "that is nested empty" do
136
- assert_params([[]], "")
137
- end
138
-
139
- it "with normal params" do
140
- assert_params([["--user", "bob"]], "--user bob")
141
- end
142
-
143
- it "with key with tailing '='" do
144
- assert_params([["--user=", "bob"]], "--user=bob")
145
- end
146
-
147
- it "with value requiring sanitization" do
148
- assert_params([["--pass", "P@$s w0rd%"]], "--pass P@\\$s\\ w0rd\\%")
149
- end
150
-
151
- it "with key requiring sanitization" do
152
- assert_params([["--h&x0r=", "xxx"]], "--h\\&x0r=xxx")
153
- end
154
-
155
- it "with key as Symbol" do
156
- assert_params([[:abc, "def"]], "--abc def")
157
- end
158
-
159
- it "with key as Symbol with tailing '='" do
160
- assert_params([[:abc=, "def"]], "--abc=def")
161
- end
162
-
163
- it "with key as Symbol with underscore" do
164
- assert_params([[:abc_def, "ghi"]], "--abc-def ghi")
165
- end
166
-
167
- it "with key as Symbol with underscore and tailing '='" do
168
- assert_params([[:abc_def=, "ghi"]], "--abc-def=ghi")
169
- end
170
-
171
- it "with key as nil" do
172
- assert_params([[nil, "def"]], "def")
173
- end
174
-
175
- it "with value as nil" do
176
- assert_params([["--abc", nil]], "--abc")
177
- end
178
-
179
- it "with key and value nil" do
180
- assert_params([[nil, nil]], "")
181
- end
182
-
183
- it "with key as nil and multiple values" do
184
- assert_params([[nil, "def", "ghi"]], "def ghi")
185
- end
186
-
187
- it "with key of '--'" do
188
- assert_params([["--", nil]], "--")
189
- end
190
-
191
- it "with key alone" do
192
- assert_params([["--abc"]], "--abc")
193
- end
194
-
195
- it "with key as Symbol alone" do
196
- assert_params([[:abc]], "--abc")
197
- end
198
-
199
- it "with key as a bareword" do
200
- assert_params(["--abc"], "--abc")
201
- end
202
-
203
- it "with key as bareword Symbol" do
204
- assert_params([:abc], "--abc")
205
- end
206
-
207
- it "with value as a bareword" do
208
- assert_params(["abc"], "abc")
209
- end
210
-
211
- it "with entry as a nested Hash" do
212
- assert_params([{:abc_def= => "ghi"}], "--abc-def=ghi")
213
- end
214
-
215
- it "with value as Symbol" do
216
- assert_params([["--abc" => :def]], "--abc def")
217
- end
218
-
219
- it "with value as Array" do
220
- assert_params([["--abc", ["def", "ghi"]]], "--abc def ghi")
221
- end
222
-
223
- it "with value as Array and extra nils" do
224
- assert_params([["--abc", [nil, "def", nil, "ghi", nil]]], "--abc def ghi")
225
- end
226
-
227
- it "with value as flattened Array" do
228
- assert_params([["--abc", "def", "ghi"]], "--abc def ghi")
229
- end
230
-
231
- it "with value as Fixnum" do
232
- assert_params([["--abc", 1]], "--abc 1")
233
- end
234
-
235
- it "with value as Fixnum Array" do
236
- assert_params([["--abc", [1, 2]]], "--abc 1 2")
237
- end
238
-
239
- it "with value as Range" do
240
- assert_params([["--abc", (1..4)]], "--abc 1 2 3 4")
241
- end
242
-
243
- it "with value as Pathname" do
244
- assert_params([["--abc", Pathname.new("/usr/bin/ruby")]], "--abc /usr/bin/ruby")
245
- end
246
-
247
- it "with duplicate keys" do
248
- assert_params([["--abc", 1], ["--abc", 2]], "--abc 1 --abc 2")
249
- end
250
- end
251
-
252
- context "with multiple params" do # real-world cases
253
- let(:expected) { "log feature -E --oneline --grep abc" }
254
-
255
- it "as full Hash" do
256
- params = {"log" => nil, "feature" => nil, "-E" => nil, :oneline => nil, "--grep" => "abc"}
257
- assert_params(params, expected)
258
- end
259
-
260
- it "as grouped Hash" do
261
- params = {nil => ["log", "feature"], "-E" => nil, :oneline => nil, :grep => "abc"}
262
- assert_params(params, expected)
263
- end
264
-
265
- it "as associative Array" do
266
- params = [[nil, "log", "feature"], ["-E", nil], [:oneline, nil], [:grep, "abc"]]
267
- assert_params(params, expected)
268
- end
269
-
270
- it "as associative Array without nil values" do
271
- params = [["log", "feature"], ["-E"], [:oneline], [:grep, "abc"]]
272
- assert_params(params, expected)
273
- end
274
-
275
- it "as mixed Array with barewords" do
276
- params = ["log", "feature", "-E", :oneline, [:grep, "abc"]]
277
- assert_params(params, expected)
278
- end
279
-
280
- it "as mixed Array" do
281
- params = ["log", "feature", "-E", :oneline, :grep, "abc"]
282
- assert_params(params, expected)
283
- end
284
-
285
- it "as mixed Array with nested Hashes" do
286
- params = ["log", "feature", "-E", :oneline, {:grep => "abc"}]
287
- assert_params(params, expected)
288
- end
289
- end
290
- end
291
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AwesomeSpawn::CommandResultError do
4
- context "basic false command" do
5
- before { enable_spawning }
6
- subject do
7
- begin
8
- AwesomeSpawn.run!("false")
9
- rescue => e
10
- return e
11
- end
12
- end
13
-
14
- it { expect(subject.message).to eq("false exit code: 1") }
15
- it { expect(subject.result).to be_a_failure }
16
- end
17
-
18
- it ".default_message" do
19
- expect(described_class.default_message("some message", 123)).to eq "some message exit code: 123"
20
- end
21
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AwesomeSpawn::CommandResult do
4
- context "succeeding object" do
5
- subject { described_class.new("aaa", "bbb", "ccc", 0) }
6
-
7
- it "should set attributes" do
8
- expect(subject.command_line).to eq("aaa")
9
- expect(subject.output).to eq("bbb")
10
- expect(subject.error).to eq("ccc")
11
- expect(subject.exit_status).to eq(0)
12
- expect(subject.inspect).to match(/^#<AwesomeSpawn::CommandResult:[0-9a-fx]+ @exit_status=0>$/)
13
- end
14
-
15
- it "should not display sensitive information" do
16
- expect(subject.inspect).to_not include("aaa")
17
- expect(subject.inspect).to_not include("bbb")
18
- expect(subject.inspect).to_not include("ccc")
19
- end
20
-
21
- it { expect(subject).to be_a_success }
22
- it { expect(subject).not_to be_a_failure }
23
- end
24
-
25
- context "failing object" do
26
- subject { described_class.new("aaa", "bbb", "ccc", 1) }
27
-
28
- it { expect(subject).not_to be_a_success }
29
- it { expect(subject).to be_a_failure }
30
- end
31
-
32
- context "another failing object" do
33
- subject { described_class.new("aaa", "bbb", "ccc", 100) }
34
-
35
- it { expect(subject).not_to be_a_success }
36
- it { expect(subject).to be_a_failure }
37
- end
38
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AwesomeSpawn::NoSuchFileError do
4
- before do
5
- enable_spawning
6
- end
7
-
8
- context "single word command" do
9
- subject { caught_exception_for("falsey") }
10
- it { expect(subject.message).to eq("No such file or directory - falsey") }
11
- it { expect(subject.to_s).to eq("No such file or directory - falsey") }
12
- it { expect(subject).to be_a(described_class) }
13
- end
14
-
15
- context "multi word command" do
16
- subject { caught_exception_for(" flat --arg 1 --arg 2") }
17
- it { expect(subject.message).to eq("No such file or directory - flat") }
18
- it { expect(subject.to_s).to eq("No such file or directory - flat") }
19
- it { expect(subject).to be_a(described_class) }
20
- end
21
-
22
- def caught_exception_for(command)
23
- AwesomeSpawn.run!(command)
24
- rescue => e
25
- return e
26
- end
27
- end
@@ -1,30 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
-
8
- require 'awesome_spawn/spec_helper'
9
-
10
- RSpec.configure do |config|
11
- config.run_all_when_everything_filtered = true
12
- config.filter_run :focus
13
-
14
- # Run specs in random order to surface order dependencies. If you find an
15
- # order dependency and want to debug it, you can fix the order by providing
16
- # the seed, which is printed after each run.
17
- # --seed 1234
18
- config.order = 'random'
19
-
20
- include AwesomeSpawn::SpecHelper
21
- config.before { disable_spawning }
22
- end
23
-
24
- begin
25
- require 'coveralls'
26
- Coveralls.wear!
27
- rescue LoadError
28
- end
29
-
30
- require 'awesome_spawn'