Given(/^a fax job$/) do dir = 'Documents' @job = File.join(dir, 'example.json') content = { 'type' => 'fax', 'file' => @letter, 'phone' => '0123456789' } create_dir(dir) write_file(@job, content.to_json) end Given(/^a doubled fax interface$/) do double_cmd('lp') end When(/^I run postman$/) do cmd = 'postman --jobdir Documents' run_simple(unescape(cmd)) end When(/^I run postman in noop mode$/) do cmd = 'postman --jobdir Documents --noop' run_simple(unescape(cmd)) end def fax_cmd cmd = "lp -d Fax -o phone=00123456789 \"#{@letter}\"".shellsplit end Then(/^the letter should have been faxed$/) do expect(history).to include(fax_cmd), history.to_pretty end Then(/^the letter should not have been faxed$/) do expect(history).to_not include(fax_cmd), history.to_pretty end Then(/^the fax should have been logged$/) do [ 'Letter delivered', @job, '0123456789' ].each { |expected| assert_partial_output(expected, all_output) } end