Sha256: 043ab09bdb0afcc09d6abc6f4c7eef186d3583438229c05db2029ee87b888428
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative File.join('..', 'matchers_base') unless defined?(::Matchi::MatchersBase) module Matchi module Matchers # **Regular expressions** matcher. module Match # The matcher. class Matcher include MatchersBase # Initialize the matcher with an instance of Regexp. # # @example Username matcher. # Matchi::Matchers::Match::Matcher.new(/^[a-z0-9_-]{3,16}$/) # # @param expected [#match] A regular expression. def initialize(expected) @expected = expected end # Boolean comparison between the actual value and the expected value. # # @example Is it matching /^foo$/ regex? # match = Matchi::Matchers::Match::Matcher.new(/^foo$/) # match.matches? { 'foo' } # => true # # @yieldreturn [#object_id] the actual value to compare to the expected # one. # # @return [Boolean] Comparison between actual and expected values. def matches? @expected.match(yield).nil?.equal?(false) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
matchi-1.0.4 | lib/matchi/matchers/match.rb |
matchi-1.0.3 | lib/matchi/matchers/match.rb |