module RSpec::Matchers::DSL
Defines the custom matcher DSL.
Public Instance Methods
define(name, &declarations)
click to toggle source
Defines a custom matcher. @see RSpec::Matchers
# File lib/rspec/matchers/dsl.rb, line 7 def define(name, &declarations) warn_about_block_args(name, declarations) define_method name do |*expected, &block_arg| RSpec::Matchers::DSL::Matcher.new(name, declarations, self, *expected, &block_arg) end end
Also aliased as: matcher
Private Instance Methods
warn_about_block_args(name, declarations)
click to toggle source
# File lib/rspec/matchers/dsl.rb, line 18 def warn_about_block_args(name, declarations) declarations.parameters.each do |type, arg_name| next unless type == :block RSpec.warning("Your `#{name}` custom matcher receives a block argument (`#{arg_name}`), " "but due to limitations in ruby, RSpec cannot provide the block. Instead, " "use the `block_arg` method to access the block") end end