Sha256: 29278c2686b900e65d20ad92fe661040a6ceaf046b18bdc43744b3af9524f753

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Capistrano::Application do

  it "provides a --trace option which enables SSHKit/NetSSH trace output"

  it "provides a --format option which enables the choice of output formatting"

  it "identifies itself as cap and not rake" do
    pending "Waiting for: https://github.com/jimweirich/rake/pull/204"
    out, _ = capture_io do
      flags '--help', '-h'
    end
    out.should match(/\bcap [ -f capfile ]\b/)
  end

  it "overrides the rake method, but still prints the rake version" do
    out, _ = capture_io do
      flags '--version', '-V'
    end
    out.should match(/\bCapistrano Version\b/)
    out.should match(/\b#{Capistrano::VERSION}\b/)
    out.should match(/\bRake Version\b/)
    out.should match(/\b#{RAKEVERSION}\b/)
  end

  def flags(*sets)
    sets.each do |set|
      ARGV.clear
      @exit = catch(:system_exit) { command_line(*set) }
    end
    yield(subject.options) if block_given?
  end

  def command_line(*options)
    options.each { |opt| ARGV << opt }
    def subject.exit(*args)
      throw(:system_exit, :exit)
    end
    subject.instance_eval do
      handle_options
    end
    subject.options
  end

  def capture_io
    require 'stringio'

    orig_stdout, orig_stderr         = $stdout, $stderr
    captured_stdout, captured_stderr = StringIO.new, StringIO.new
    $stdout, $stderr                 = captured_stdout, captured_stderr

    yield

    return captured_stdout.string, captured_stderr.string
  ensure
    $stdout = orig_stdout
    $stderr = orig_stderr
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
capistrano-3.0.1 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre14 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre13 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre12 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre11 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre10 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre7 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre6 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre5 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre4 spec/lib/capistrano/application_spec.rb
capistrano-3.0.0.pre3 spec/lib/capistrano/application_spec.rb