Sha256: 8a3ae3f943b7d6d2f59d840179abaf83c69dfbacdfc675bbfa8e98b6cf9ab4e4

Contents?: true

Size: 1.56 KB

Versions: 46

Compression:

Stored size: 1.56 KB

Contents

$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
require 'test/unit'
require 'tools'

require 'autobuild'
require 'tmpdir'
require 'fileutils'
require 'flexmock/test_unit'

class TC_Subcommand < Test::Unit::TestCase
EXAMPLE_1 = <<EOF
This is a file
It will be the first part of the two-part cat
EOF

EXAMPLE_2 = <<EOF
This is another file
It will be the second part of the two-part cat
EOF

    attr_reader :tmpdir
    attr_reader :source1, :source2
    def setup
        @tmpdir = Autobuild.logdir = TestTools.tempdir

        # Write example files
        @source1 = File.join(tmpdir, 'source1')
        @source2 = File.join(tmpdir, 'source2')
        File.open(source1, 'w+') { |f| f.write(EXAMPLE_1) }
        File.open(source2, 'w+') { |f| f.write(EXAMPLE_2) }

        super
    end

    def teardown
        super
        TestTools.clean
    end

    def test_behaviour_on_unexpected_error
        flexmock(Autobuild::Subprocess).should_receive(:exec).and_raise(::Exception)
        assert_raises(Autobuild::SubcommandFailed) { Autobuild::Subprocess.run('test', 'test', 'does_not_exist') }
    end
    def test_behaviour_on_inexistent_command
        assert_raises(Autobuild::SubcommandFailed) { Autobuild::Subprocess.run('test', 'test', 'does_not_exist') }
    end
    def test_behaviour_on_interrupt
        flexmock(Autobuild::Subprocess).should_receive(:exec).and_raise(Interrupt)
        assert_raises(Interrupt) { Autobuild::Subprocess.run('test', 'test', 'does_not_exist') }
    end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
autobuild-1.8.3 test/test_subcommand.rb
autobuild-1.8.2 test/test_subcommand.rb
autobuild-1.8.1 test/test_subcommand.rb
autobuild-1.8.0 test/test_subcommand.rb
autobuild-1.7.12.rc6 test/test_subcommand.rb
autobuild-1.7.12.rc5 test/test_subcommand.rb
autobuild-1.7.12.rc4 test/test_subcommand.rb
autobuild-1.7.12.rc3 test/test_subcommand.rb
autobuild-1.7.12.rc2 test/test_subcommand.rb
autobuild-1.7.12.rc1 test/test_subcommand.rb
autobuild-1.7.12.b1 test/test_subcommand.rb
autobuild-1.7.11 test/test_subcommand.rb
autobuild-1.7.11.rc7 test/test_subcommand.rb
autobuild-1.7.11.rc6 test/test_subcommand.rb
autobuild-1.7.11.rc5 test/test_subcommand.rb
autobuild-1.7.11.rc4 test/test_subcommand.rb
autobuild-1.7.11.rc3 test/test_subcommand.rb
autobuild-1.7.11.rc2 test/test_subcommand.rb
autobuild-1.7.11.rc1 test/test_subcommand.rb
autobuild-1.7.10 test/test_subcommand.rb