Sha256: 2dea85a9de59c25a777156af3ac76f842222395e498c8c67652a23a4f94f02b2

Contents?: true

Size: 536 Bytes

Versions: 7

Compression:

Stored size: 536 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(new_message.matches(expected))
      else
        fail(expected_message(expected).to_match(actual))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
riot-0.11.2 lib/riot/assertion_macros/matches.rb
riot-0.11.1 lib/riot/assertion_macros/matches.rb
riot-0.11.0 lib/riot/assertion_macros/matches.rb
riot-0.10.13 lib/riot/assertion_macros/matches.rb
riot-0.10.13.pre lib/riot/assertion_macros/matches.rb
riot-0.10.12 lib/riot/assertion_macros/matches.rb
riot-0.10.12.pre lib/riot/assertion_macros/matches.rb