# encoding: utf-8 require 'spec_helper' describe Runner do context '#initialize' do it 'expects a command string' do Runner.new('echo') end end context '#run' do it 'runs a command' do runner = Runner.new('echo') expect { runner.run }.not_to raise_error end it 'fails on error file not found' do runner = Runner.new('asdfasdf asfd') expect { runner.run }.to raise_error RuntimeError end it 'fails on error status code' do runner = Runner.new('exit 1') expect { runner.run }.to raise_error RuntimeError end end context '#result' do it 'returns stdout as array' do runner = Runner.new("echo -E \"hello\nworld\"") expect(runner.result).to eq(["hello", "world"]) end end end