Sha256: 6c10a23ac5522d757bedc64762ed9bdb3a48dc8e6dd1766c142e807e959afc55

Contents?: true

Size: 1.18 KB

Versions: 32

Compression:

Stored size: 1.18 KB

Contents

# @!method match_output_string(string)
#   This matchers checks if the output string of a command matches regular expression.
#
#   @param [Integer] status
#     The value of the exit status
#
#   @return [TrueClass, FalseClass] 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|
    @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

if RSpec::Expectations::Version::STRING >= '3.0'
  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
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
aruba-0.14.14 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.13 lib/aruba/matchers/string/match_output_string.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.12 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.11 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.10 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.9 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.8 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.7 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.6 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.5 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.4 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.3 lib/aruba/matchers/string/match_output_string.rb
aruba-1.0.0.pre.alpha.2 lib/aruba/matchers/string/match_output_string.rb
aruba-1.0.0.pre.alpha.1 lib/aruba/matchers/string/match_output_string.rb
aruba-win-fix-0.14.2 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.2 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.1 lib/aruba/matchers/string/match_output_string.rb
aruba-0.14.0 lib/aruba/matchers/string/match_output_string.rb
aruba-0.13.0 lib/aruba/matchers/string/match_output_string.rb