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.1.9 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/test/cli_facade_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/test/cli_facade_test.rb