aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/alaveteli_external_command_spec.rb
blob: 18afeda33637e4b505c253680f064b880003fda5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'alaveteli_external_command'

script_dir = File.join(File.dirname(__FILE__), 'alaveteli_external_command_scripts')
segfault_script = File.join(script_dir, 'segfault.sh')
error_script = File.join(script_dir, 'error.sh')

describe "when running external commands" do

    it "should detect a non-zero exit status" do
        $stderr.should_receive(:puts).with(/Error from/)
        t = AlaveteliExternalCommand.run(error_script)
        assert_nil t
    end

    it "should detect when an external command crashes" do
        $stderr.should_receive(:puts).with(/exited abnormally/)
        t = AlaveteliExternalCommand.run(segfault_script)
        assert_nil t
    end

end