Sha256: b3c3a935887cd31c3f02e6232547f2c6e14b1e1ccc978679c2f4d5d032839026

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

require 'aruba/matchers/base/message_indenter'

# @!method have_output
#   This matchers checks if <command> has created output
#
#   @return [Boolean] The result
#
#     false:
#     * if command has not created output
#     true:
#     * if command created output
#
#   @example Use matcher
#
#     RSpec.describe do
#       it { expect(last_command_started).to have_output }
#     end
RSpec::Matchers.define :have_output do |expected|
  match do |actual|
    @old_actual = actual

    next false unless @old_actual.respond_to? :output

    @old_actual.stop

    @actual = sanitize_text(actual.output)

    values_match?(expected, @actual)
  end

  diffable

  description { "have output: #{description_of expected}" }

  failure_message do |_actual|
    "expected `#{@old_actual.commandline}` to have output #{description_of expected}\n" \
      "but was:\n#{Aruba::Matchers::Base::MessageIndenter.indent_multiline_message @actual}"
  end
end

RSpec::Matchers.alias_matcher :a_command_having_output, :have_output

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aruba-1.0.0.pre.alpha.4 lib/aruba/matchers/command/have_output.rb
aruba-1.0.0.pre.alpha.3 lib/aruba/matchers/command/have_output.rb