Sha256: 92b75b93ce88b1301dd0d7f3938edf93b12033e17b9792721b142af5ff97d03d

Contents?: true

Size: 541 Bytes

Versions: 3

Compression:

Stored size: 541 Bytes

Contents

module Riot
  # Asserts that the result of the test equals matches against the proved expression
  #   asserts("test") { "12345" }.matches(/\d+/)
  #   should("test") { "12345" }.matches(/\d+/)
  class MatchesMacro < AssertionMacro
    register :matches

    def evaluate(actual, expected)
      expected = %r[#{Regexp.escape(expected)}] if expected.kind_of?(String)
      if actual.to_s =~ expected
        pass(new_message.matches(expected))
      else
        fail(expected_message(expected).to_match(actual))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riot-0.11.4 lib/riot/assertion_macros/matches.rb
riot-0.11.4.pre lib/riot/assertion_macros/matches.rb
riot-0.11.3 lib/riot/assertion_macros/matches.rb