module Mongomatic::Expectations::Helper
Private Instance Methods
define_expectations()
click to toggle source
# File lib/mongomatic/expectations.rb, line 7 def define_expectations Expectation.subclasses.each do |klass| if Expectation.define_to_be?(klass) instance_eval %Q{ def be_#{klass.name.downcase}(value, message, opts = {}) #{klass}.new(self, value, message, opts).to_be end } end if Expectation.define_to_not_be?(klass) instance_eval %Q{ def not_be_#{klass.name.downcase}(value, message, opts = {}) #{klass}.new(self, value, message, opts).to_not_be end } end end end
expectations(&block)
click to toggle source
# File lib/mongomatic/expectations.rb, line 43 def expectations(&block) define_expectations block.call undefine_expectations end
undefine_expectations()
click to toggle source
# File lib/mongomatic/expectations.rb, line 26 def undefine_expectations Expectation.subclasses.each do |klass| instance_eval %Q{ if respond_to? "be_#{klass.name.downcase}" class << self remove_method "be_#{klass.name.downcase}" end end if respond_to? "not_be_#{klass.name.downcase}" class << self remove_method "not_be_#{klass.name.downcase}" end end } end end