spec/yq_bin_spec.rb in yq-0.4.0 vs spec/yq_bin_spec.rb in yq-0.4.1
- old
+ new
@@ -2,34 +2,32 @@
require 'climate_control'
require 'timeout'
describe 'bin/yq' do
# Contract Or[nil,String] => self
- def run_bin(args = "", input = nil)
+ def run_bin(args = '', input = nil)
status = nil
- output = ""
+ output = ''
cmd = "bin/yq #{args}"
Open3.popen2e(cmd) do |i, oe, t|
- begin
- pid = t.pid
+ pid = t.pid
- if input
- i.puts input
- i.close
- end
+ if input
+ i.puts input
+ i.close
+ end
- Timeout.timeout(0.5) do
- oe.each { |v|
- output << v
- }
+ Timeout.timeout(1.0) do
+ oe.each do |v|
+ output << v
end
- rescue Timeout::Error
- LOGGER.warn "Timing out #{t.inspect} after 1 second"
- Process.kill(15, pid)
- ensure
- status = t.value
end
+ rescue Timeout::Error
+ LOGGER.warn "Timing out #{t.inspect} after 1 second"
+ Process.kill(15, pid)
+ ensure
+ status = t.value
end
[output, status]
end
required_vars = %w[
@@ -49,20 +47,20 @@
expect(status).to_not be_success
end
end
it 'supplies help' do
- out_err, status = run_bin("--help")
+ out_err, status = run_bin('--help')
expect(out_err).to match(/Usage: yq/)
expect(status).to be_success
end
describe 'parses' do
- let(:yaml) { <<-EOF }
-foo:
- bar:
- baz: value
-EOF
+ let(:yaml) { <<~EOF }
+ foo:
+ bar:
+ baz: value
+ EOF
it '.foo.bar' do
out_err, status = run_bin('.foo.bar', yaml)
expect(out_err).to match('baz: value')
expect(status).to be_success