Sha256: 1a1ae1896e052707c9dbed7cc0f40513cb31a299340a8dcddce77c4987835c8d

Contents?: true

Size: 1.38 KB

Versions: 69

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path("../common", __FILE__)
require "gem_publisher/cli_facade"

module GemPublisher
  class CliFacadeTest < MiniTest::Unit::TestCase
    def test_should_raise_exception_if_command_failed
      status = stub(:exitstatus => 1)
      Open3.stubs(:capture3).returns(["stdout", "stderr", status])
      assert_raises CliFacade::Error do
        CliFacade.new.execute("status")
      end
    end

    def test_should_include_all_output_in_error
      status = stub(:exitstatus => 1)
      Open3.stubs(:capture3).returns(["stdout", "stderr", status])
      err = assert_raises CliFacade::Error do
        CliFacade.new.execute("status")
      end
      assert_equal "stderr\nstdout", err.message

      Open3.stubs(:capture3).returns(["stdout", "", status])
      err = assert_raises CliFacade::Error do
        CliFacade.new.execute("status")
      end
      assert_equal "stdout", err.message
    end

    def test_should_return_stdout_if_command_succeeded
      status = stub(:exitstatus => 0)
      Open3.stubs(:capture3).returns(["stdout", "stderr", status])
      assert_equal "stdout", CliFacade.new.execute("status")
    end

    def test_should_escape_and_pass_in_all_commands
      status = stub(:exitstatus => 0)
      Open3.expects(:capture3).
        with("foo bar \\*").
        returns(["stdout", "stderr", status])
      CliFacade.new.execute("foo", "bar", "*")
    end
  end
end

Version data entries

69 entries across 65 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb