Sha256: 51ba0a7cf319769fd8f5e68b4d2766bb9e8af9ad3db9d1598b983a886709f81a

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

# @!method match_output_string(string)
#   This matchers checks if the output string of a command matches regular expression.
#
#   @param [String] string
#     The value of the output string
#
#   @return [Boolean] The result
#
#     False:
#     * if the output string does not match regex
#     True:
#     * if the output string matches regex
#
#   @example Use matcher
#     RSpec.describe do
#       it { expect(last_command_started).to have_output an_output_string_matching regex) }
#       it { expect(last_command_started).to have_output match_output_string regex) }
#     end
RSpec::Matchers.define :match_output_string do |expected|
  match do |actual|
    actual.force_encoding("UTF-8")
    @expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE)
    @actual   = sanitize_text(actual)

    values_match? @expected, @actual
  end

  diffable

  description { "output string matches: #{description_of expected}" }
end

RSpec::Matchers.alias_matcher :an_output_string_matching, :match_output_string
RSpec::Matchers.alias_matcher :a_file_name_matching, :match_output_string
RSpec::Matchers.alias_matcher :file_content_matching, :match_output_string

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/string/match_output_string.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/matchers/string/match_output_string.rb
aruba-2.2.0 lib/aruba/matchers/string/match_output_string.rb
aruba-2.1.0 lib/aruba/matchers/string/match_output_string.rb
aruba-2.0.1 lib/aruba/matchers/string/match_output_string.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/matchers/string/match_output_string.rb
aruba-2.0.0 lib/aruba/matchers/string/match_output_string.rb
aruba-1.1.2 lib/aruba/matchers/string/match_output_string.rb
aruba-1.1.1 lib/aruba/matchers/string/match_output_string.rb
aruba-1.1.0 lib/aruba/matchers/string/match_output_string.rb