Method: Ray.describe_matcher

Defined in:
lib/ray/dsl/matcher.rb

.describe_matcher(name) {|*args| ... } ⇒ Object

Examples:

Ray.describe_matcher(:match) do |regex|
  lambda { |str| str =~ regex }
end

Yields:

  • The block is called when creating the matcher.

Yield Parameters:

  • *args

    Arguments passed to the matcher.

Yield Returns:

  • (Proc)

    A proc returning taking a single argument and returning true when its argument should be matched by the matcher.



65
66
67
68
69
70
71
72
73
# File 'lib/ray/dsl/matcher.rb', line 65

def describe_matcher(name, &create_block)
  Matchers.module_eval do
    define_method(name) do |*args|
      DSL::Matcher.new(&create_block.call(*args))
    end

    module_function name
  end
end