Module: Speccify::Extension

Defined in:
lib/speccify.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



193
194
195
196
197
198
199
200
201
# File 'lib/speccify.rb', line 193

def method_missing(name, *args, &block)
  if (name.to_s =~ /^be_(.+)/)
    Speccify::Functions::build_matcher(name, args) do |given, matcher, args|
      given.send(($1 + "?").to_sym)
    end
  else
    raise NoMethodError.new(name.to_s)
  end
end

Instance Method Details

#def_matcher(matcher_name, &block) ⇒ Object



187
188
189
190
191
# File 'lib/speccify.rb', line 187

def def_matcher(matcher_name, &block)
  self.class.send :define_method, matcher_name do |*args|
    Speccify::Functions::build_matcher(matcher_name, args, &block)
  end
end