Sha256: 9eadbdf2d9c001b854476c2a525af5de29519c54e39dd7eca0563554f304a931

Contents?: true

Size: 550 Bytes

Versions: 2

Compression:

Stored size: 550 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 =~ expected
        pass("matches #{expected.inspect}")
      else
        fail("expected #{expected.inspect} to match #{actual.inspect}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riot-0.10.11 lib/riot/assertion_macros/matches.rb
riot-0.10.10 lib/riot/assertion_macros/matches.rb