Sha256: 742aca91beac7a4c6d2200485af4c8c76feda1a44606fa2673edfd81364ecb35
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
require 'open3' require 'climate_control' require 'timeout' describe 'bin/yq' do # Contract Or[nil,String] => self def run_bin(args = '', input = nil) status = nil output = '' cmd = "bin/yq #{args}" Open3.popen2e(cmd) do |i, oe, t| pid = t.pid if input i.puts input i.close end Timeout.timeout(1.0) do oe.each do |v| output << v end 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[ ] before do required_vars.each do |v| ClimateControl.env[v] = v.downcase end end required_vars.map do |v| it "dies unless given ENV[#{v}]" do ClimateControl.env[v] = nil out_err, status = run_bin expect(out_err).to match(/#{v} must be specified/) expect(status).to_not be_success end end it 'supplies help' do 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 it '.foo.bar' do out_err, status = run_bin('.foo.bar', yaml) expect(out_err).to match('baz: value') expect(status).to be_success end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yq-0.5.0 | spec/yq_bin_spec.rb |
yq-0.4.1 | spec/yq_bin_spec.rb |