Sha256: 8099007e8c713ef6a1efe43f8fd1b8bef767c422a8f358157df612ffa10265be

Contents?: true

Size: 1.33 KB

Versions: 37

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"
require "capistrano/doctor/output_helpers"

module Capistrano
  module Doctor
    describe OutputHelpers do
      include OutputHelpers

      # Force color for the purpose of these tests
      before { ENV.stubs(:[]).with("SSHKIT_COLOR").returns("1") }

      it "prints titles in blue with newlines and without indentation" do
        expect { title("Hello!") }.to\
          output("\e[0;34;49m\nHello!\n\e[0m\n").to_stdout
      end

      it "prints warnings in yellow with 4-space indentation" do
        expect { warning("Yikes!") }.to\
          output("    \e[0;33;49mYikes!\e[0m\n").to_stdout
      end

      it "overrides puts to indent 4 spaces per line" do
        expect { puts("one\ntwo") }.to output("    one\n    two\n").to_stdout
      end

      it "formats tables with indent, aligned columns and per-row color" do
        data = [
          ["one", ".", "1"],
          ["two", "..", "2"],
          ["three", "...", "3"]
        ]
        block = proc do |record, row|
          row.yellow if record.first == "two"
          row << record[0]
          row << record[1]
          row << record[2]
        end
        expected_output = <<-OUT
    one   .   1
    \e[0;33;49mtwo   ..  2\e[0m
    three ... 3
        OUT
        expect { table(data, &block) }.to output(expected_output).to_stdout
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
capistrano-3.19.2 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.19.1 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.19.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.18.1 spec/lib/capistrano/doctor/output_helpers_spec.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/spec/lib/capistrano/doctor/output_helpers_spec.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.18.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.17.3 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.17.2 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.17.1 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.17.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.16.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.15.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.14.1 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.14.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.13.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.12.1 spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.12.0 spec/lib/capistrano/doctor/output_helpers_spec.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/capistrano-3.11.0/spec/lib/capistrano/doctor/output_helpers_spec.rb
capistrano-3.11.2 spec/lib/capistrano/doctor/output_helpers_spec.rb