Sha256: 8b3c0cb91dfabcd684dc692c10afae5fbd6b83f1ca9edd55079c5c879f3f1a71

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

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

    unless @old_actual.respond_to? :output
      raise "Expected #{@old_actual} to respond to #output"
    end

    @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

10 entries across 10 versions & 3 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/matchers/command/have_output.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/matchers/command/have_output.rb
aruba-2.2.0 lib/aruba/matchers/command/have_output.rb
aruba-2.1.0 lib/aruba/matchers/command/have_output.rb
aruba-2.0.1 lib/aruba/matchers/command/have_output.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/matchers/command/have_output.rb
aruba-2.0.0 lib/aruba/matchers/command/have_output.rb
aruba-1.1.2 lib/aruba/matchers/command/have_output.rb
aruba-1.1.1 lib/aruba/matchers/command/have_output.rb
aruba-1.1.0 lib/aruba/matchers/command/have_output.rb